using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StekloMaster
{
    public partial class Form23 : Form
    {
        public Form23()
        {
            InitializeComponent();
        }
        string putin = "";
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Вы действительно хотите удалить всю базу?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Directory.Delete(putin + "\\baza",true);
                Directory.CreateDirectory(putin + "\\baza");
            }
        }

        private void Form23_Shown(object sender, EventArgs e)
        {
            if (Application.StartupPath.IndexOf("comp") != -1)
            {
                putin = Application.StartupPath.Substring(0, Application.StartupPath.IndexOf("\\comp"));
            }
            else
            {
                putin = Application.StartupPath;
            }
            button2.Focus();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (Form f in Application.OpenForms)
            {
                if (f.Name == "Form1")
                {
                    Form1 gh = f as Form1;
                    gh.button38.Visible = true;
                    return;
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            foreach (Form f in Application.OpenForms)
            {
                if (f.Name == "Form1")
                {
                    Form1 gh = f as Form1;
                    gh.button38.Visible = false;
                    return;
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Вы действительно хотите удалить файл настроек pdf принтера?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                File.Delete(Application.StartupPath + "\\printpdf.akv");
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Вы действительно хотите очистить логи обновлений?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Directory.Delete(Application.StartupPath + "\\logs", true);
                Directory.CreateDirectory(Application.StartupPath + "\\logs");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process p = System.Diagnostics.Process.Start("update", "https://lit-it.ru/programs/steklomaster/" + Application.ProductName + ".exe|" + Application.ProductName + ".exe");
            Application.Exit();
        }

        private void button7_Click(object sender, EventArgs e)
        {

            File.WriteAllText(Application.StartupPath + "\\md5.akv", "update", Encoding.UTF8);
            Application.Restart();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            File.WriteAllText(Application.StartupPath + "\\scaner.akv", "", Encoding.UTF8);
            Application.Restart();
        }
    }
}
