Form4.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace Process_Digger
  6. {
  7. public partial class FormSettings : Form
  8. {
  9. public FormSettings()
  10. {
  11. InitializeComponent();
  12. }
  13. private void FormSettings_Load(object sender, EventArgs e)
  14. {
  15. this.TopMost = Properties.Settings.Default.topMost;
  16. comboTheme.SelectedIndex = Properties.Settings.Default.theme;
  17. checkBox1.Checked = Properties.Settings.Default.topMost;
  18. setTheme();
  19. }
  20. private void btnConfirm_Click(object sender, EventArgs e)
  21. {
  22. if (comboTheme.SelectedIndex != Properties.Settings.Default.theme)
  23. Properties.Settings.Default.theme = comboTheme.SelectedIndex;
  24. Properties.Settings.Default.topMost = checkBox1.Checked;
  25. Properties.Settings.Default.Save();
  26. Program.f1.checkTheme();
  27. this.Close();
  28. }
  29. void setTheme()
  30. {
  31. switch (Properties.Settings.Default.theme)
  32. {
  33. case 0: //авто
  34. {
  35. try
  36. {
  37. RegistryKey lightThemeStatus = Registry.CurrentUser.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Themes").OpenSubKey("Personalize");
  38. if (Convert.ToInt32(lightThemeStatus.GetValue("AppsUseLightTheme")) == 0)
  39. {
  40. setDarkTheme();
  41. }
  42. }
  43. catch { }
  44. break;
  45. }
  46. case 2: //темная
  47. {
  48. setDarkTheme();
  49. break;
  50. }
  51. case 3: //черная(AMOLED)
  52. {
  53. break;
  54. }
  55. }
  56. }
  57. void setDarkTheme()
  58. {
  59. this.BackColor = Color.FromArgb(25, 25, 25);
  60. label2.ForeColor = Color.White;
  61. checkBox1.ForeColor = Color.White;
  62. comboTheme.ForeColor = Color.White;
  63. comboTheme.BackColor = Color.FromArgb(32, 32, 32);
  64. comboTheme.FlatStyle = FlatStyle.Popup;
  65. btnConfirm.ForeColor = Color.White;
  66. btnConfirm.BackColor = Color.FromArgb(32, 32, 32);
  67. }
  68. }
  69. }