HelperForm.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.Optimize)
  23. {
  24. OptimizeForm f = new OptimizeForm(!chkPrint.Checked, !chkSensors.Checked);
  25. f.ShowDialog();
  26. f.BringToFront();
  27. this.Close();
  28. }
  29. if (_type == MessageType.Startup)
  30. {
  31. _main.RemoveAllStartupItems();
  32. }
  33. if (_type == MessageType.Restart)
  34. {
  35. Utilities.Reboot();
  36. }
  37. if (_type == MessageType.Hosts)
  38. {
  39. _main.RemoveAllHostsEntries();
  40. }
  41. if (_type == MessageType.Integrator)
  42. {
  43. _main.RemoveAllDesktopItems();
  44. }
  45. }
  46. internal HelperForm(MainForm main, MessageType m, string text)
  47. {
  48. InitializeComponent();
  49. Options.ApplyTheme(this);
  50. _main = main;
  51. _type = m;
  52. lblMessage.Text = text;
  53. if (_type == MessageType.Error)
  54. {
  55. btnNo.Visible = false;
  56. btnYes.Text = "OK";
  57. this.AcceptButton = btnNo;
  58. this.AcceptButton = btnYes;
  59. this.CancelButton = btnNo;
  60. this.CancelButton = btnYes;
  61. }
  62. if (_type == MessageType.Optimize)
  63. {
  64. chkPrint.Checked = true;
  65. chkPrint.Visible = true;
  66. chkSensors.Checked = true;
  67. chkSensors.Visible = true;
  68. }
  69. }
  70. private void btnNo_Click(object sender, EventArgs e)
  71. {
  72. this.Close();
  73. }
  74. private void btnYes_Click(object sender, EventArgs e)
  75. {
  76. Confirm();
  77. this.Close();
  78. }
  79. private void Messager_Load(object sender, EventArgs e)
  80. {
  81. CheckForIllegalCrossThreadCalls = false;
  82. this.BringToFront();
  83. }
  84. }
  85. }