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

namespace WinBox
{
    public partial class CloseForm : Form
    {
        private MainForm mainForm = null;
        public CloseForm()
        {
            InitializeComponent();
        }

        public CloseForm(MainForm mainForm)
        {
            this.mainForm = mainForm;
            InitializeComponent();
        }

        private void CloseForm_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MainForm mainForm = new MainForm(this);
            this.Hide();
            mainForm.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            try
            {
                RunBat("C:\\Lingjiao\\winBoxNode\\stop.bat");
            }
            catch (Exception ex)
            {
            }
        }

        private void RunBat(string batPath)
        {
            Process pro = new Process();
            FileInfo file = new FileInfo(batPath);
            pro.StartInfo.WorkingDirectory = file.Directory.FullName;
            pro.StartInfo.FileName = batPath;
            pro.StartInfo.CreateNoWindow = false;
            pro.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            pro.Start();
            pro.Close();
        }

        private void CloseForm_FormClosing(object sender, FormClosingEventArgs e)
        {
          
        }

        private void CloseForm_FormClosed(object sender, FormClosedEventArgs e)
        {
             try
                {
                    RunBat("C:\\Lingjiao\\winBoxNode\\stop.bat");
                }
              catch (Exception ex)
                {
                }
        }
    }
}
