HelperForm.cs 1.9 KB

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