OptimizeForm.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 OptimizeForm : Form
  13. {
  14. bool DisablePrintServices = false;
  15. bool DisableSensorServices = false;
  16. public OptimizeForm(bool flag, bool flag2)
  17. {
  18. InitializeComponent();
  19. DisablePrintServices = flag;
  20. DisableSensorServices = flag;
  21. }
  22. private void ApplyAll()
  23. {
  24. if (MainForm.wv != WindowsVersion.Unsupported)
  25. {
  26. try
  27. {
  28. // universal
  29. Optimize.PerformanceTweaks();
  30. Optimize.DisableNetworkThrottling();
  31. Optimize.DisableDefender();
  32. Optimize.DisableSystemRestore();
  33. if (DisablePrintServices)
  34. {
  35. Optimize.DisablePrintSpooler();
  36. }
  37. else
  38. {
  39. Optimize.EnablePrintSpooler();
  40. }
  41. Optimize.DisableMediaPlayerSharing();
  42. Optimize.BlockSkypeAds();
  43. Optimize.DisableErrorReporting();
  44. Optimize.DisableHomeGroup();
  45. Optimize.DisableSuperfetch();
  46. Optimize.DisableTelemetryTasks();
  47. Optimize.DisableOfficeTelemetryTasks();
  48. // Windows-specific
  49. if ((MainForm.wv == WindowsVersion.Windows7) || (MainForm.wv == WindowsVersion.WindowsServer2008))
  50. {
  51. Optimize.RemoveWindows10Icon();
  52. }
  53. if ((MainForm.wv == WindowsVersion.Windows8) || (MainForm.wv == WindowsVersion.WindowsServer2012))
  54. {
  55. Optimize.RemoveWindows10Icon();
  56. Optimize.DisableOneDrive();
  57. }
  58. if ((MainForm.wv == WindowsVersion.Windows10) || (MainForm.wv == WindowsVersion.WindowsServer2016))
  59. {
  60. Optimize.RestoreLegacyVolumeSlider();
  61. Optimize.DisableCortana();
  62. Optimize.DisableXboxLive();
  63. Optimize.DisableAutomaticUpdates();
  64. Optimize.DisableDiagnosticsTracking();
  65. Optimize.DisableWAPPush();
  66. Optimize.DisableDataTelemetry();
  67. if (DisableSensorServices)
  68. {
  69. Optimize.DisableSensorServices();
  70. }
  71. else
  72. {
  73. Optimize.EnableSensorServices();
  74. }
  75. Optimize.UninstallOneDrive();
  76. Optimize.DisablePrivacyOptions();
  77. Optimize.DisableGameBar();
  78. Optimize.DisableSyncProviderNotifications();
  79. Optimize.DisableStartMenuAds();
  80. Optimize.DisableSilentAppInstall();
  81. Optimize.DisableMyPeople();
  82. Optimize.ExcludeDrivers();
  83. Optimize.DisableWindowsInk();
  84. Optimize.DisableSpellingAndTypingFeatures();
  85. }
  86. }
  87. catch //(Exception error)
  88. {
  89. //MessageBox.Show(error.Message);
  90. }
  91. finally
  92. {
  93. this.Close();
  94. }
  95. }
  96. this.Close();
  97. }
  98. private void Helper_Load(object sender, EventArgs e)
  99. {
  100. CheckForIllegalCrossThreadCalls = false;
  101. Options.ApplyTheme(this);
  102. dotter.Start();
  103. Task t = new Task(() => ApplyAll());
  104. t.Start();
  105. }
  106. private void dotter_Tick(object sender, EventArgs e)
  107. {
  108. switch (label2.Text)
  109. {
  110. case "":
  111. label2.Text = ".";
  112. break;
  113. case ".":
  114. label2.Text = "..";
  115. break;
  116. case "..":
  117. label2.Text = "...";
  118. break;
  119. case "...":
  120. label2.Text = "";
  121. break;
  122. }
  123. }
  124. }
  125. }