HelperForm.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. namespace Optimizer
  3. {
  4. public partial class HelperForm : System.Windows.Forms.Form
  5. {
  6. MainForm _main;
  7. MessageType _type;
  8. private void Confirm()
  9. {
  10. if (_type == MessageType.Error)
  11. {
  12. this.Close();
  13. }
  14. if (_type == MessageType.Startup)
  15. {
  16. _main.RemoveAllStartupItems();
  17. }
  18. if (_type == MessageType.Restart)
  19. {
  20. Utilities.Reboot();
  21. }
  22. if (_type == MessageType.Hosts)
  23. {
  24. _main.RemoveAllHostsEntries();
  25. }
  26. if (_type == MessageType.Integrator)
  27. {
  28. _main.RemoveAllDesktopItems();
  29. }
  30. }
  31. internal HelperForm(MainForm main, MessageType m, string text)
  32. {
  33. InitializeComponent();
  34. Options.ApplyTheme(this);
  35. _main = main;
  36. _type = m;
  37. lblMessage.Text = text;
  38. if (_type == MessageType.Error)
  39. {
  40. btnNo.Visible = false;
  41. btnYes.Text = "OK";
  42. this.AcceptButton = btnNo;
  43. this.AcceptButton = btnYes;
  44. this.CancelButton = btnNo;
  45. this.CancelButton = btnYes;
  46. }
  47. }
  48. private void btnNo_Click(object sender, EventArgs e)
  49. {
  50. this.Close();
  51. }
  52. private void btnYes_Click(object sender, EventArgs e)
  53. {
  54. Confirm();
  55. this.Close();
  56. }
  57. private void Messager_Load(object sender, EventArgs e)
  58. {
  59. CheckForIllegalCrossThreadCalls = false;
  60. this.BringToFront();
  61. }
  62. }
  63. }