12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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)
- {
- Rectangle rect = Screen.GetWorkingArea(this);
- this.Height = rect.Height;
- this.Width = rect.Width;
- this.Location = new Point(0, 0);
- //this.Owner.Hide();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.mainForm.Show();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
- DialogResult dr = MessageBox.Show("如果有下载课程操作会被终止,确认要退出吗", "退出",messButton);
- if (dr == DialogResult.OK)//如果点击“确定”按钮
- {
- 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)
- {
- }
- }
- }
- }
|