MainForm.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ProjectManagementSystem.Enterance;
  2. using System.Diagnostics;
  3. using System.Windows.Forms;
  4. namespace ProjectManagementSystem
  5. {
  6. public partial class MainForm : Form
  7. {
  8. public MainForm()
  9. {
  10. InitializeComponent();
  11. }
  12. private void MainForm_Load(object sender, System.EventArgs e)
  13. {
  14. WindowState = FormWindowState.Minimized; ShowInTaskbar = false;
  15. SystemEnterance systemEnterance = new SystemEnterance();
  16. }
  17. private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
  18. {
  19. e.Cancel = true; WindowState = FormWindowState.Minimized; ShowInTaskbar = false;
  20. }
  21. private void 关闭系统ToolStripMenuItem_Click(object sender, System.EventArgs e)
  22. {
  23. Process[] process = Process.GetProcesses();
  24. Process currentProcess = Process.GetCurrentProcess();
  25. for (int i = 0; i < process.Length; i++)
  26. {
  27. if (process[i].ProcessName == currentProcess.ProcessName)
  28. {
  29. process[i].Kill();
  30. }
  31. }
  32. Dispose(); Close();
  33. }
  34. private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
  35. {
  36. if (e.Button == MouseButtons.Right)
  37. {
  38. contextMenuStrip1.Location = new System.Drawing.Point(MousePosition.X, MousePosition.Y);
  39. contextMenuStrip1.Show();
  40. }
  41. }
  42. }
  43. }