OtherControl.xaml.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using GeekDesk.Constant;
  2. using GeekDesk.MyThread;
  3. using GeekDesk.Util;
  4. using GeekDesk.ViewModel;
  5. //using ShowSeconds;
  6. using System;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Management;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Input;
  13. namespace GeekDesk.Control.UserControls.Config
  14. {
  15. /// <summary>
  16. /// OtherControl.xaml 的交互逻辑
  17. /// </summary>
  18. public partial class OtherControl : UserControl
  19. {
  20. public OtherControl()
  21. {
  22. InitializeComponent();
  23. this.Loaded += OtherControl_Loaded;
  24. }
  25. private void OtherControl_Loaded(object sender, RoutedEventArgs e)
  26. {
  27. Sort_Check();
  28. }
  29. private void SelfStartUpBox_Click(object sender, RoutedEventArgs e)
  30. {
  31. AppConfig appConfig = MainWindow.appData.AppConfig;
  32. RegisterUtil.SetSelfStarting(appConfig.SelfStartUp, Constants.MY_NAME);
  33. }
  34. /// <summary>
  35. /// 移动窗口
  36. /// </summary>
  37. /// <param name="sender"></param>
  38. /// <param name="e"></param>
  39. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  40. {
  41. if (e.LeftButton == MouseButtonState.Pressed)
  42. {
  43. Window.GetWindow(this).DragMove();
  44. }
  45. }
  46. private void SortType_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  47. {
  48. RadioButton rb = sender as RadioButton;
  49. SortType type = (SortType)int.Parse(rb.Tag.ToString());
  50. SortType resType = type;
  51. switch (type)
  52. {
  53. case SortType.CUSTOM:
  54. break;
  55. case SortType.COUNT_UP:
  56. if (rb.IsChecked == true)
  57. {
  58. CountLowSort.IsChecked = true;
  59. CountUpSort.Visibility = Visibility.Collapsed;
  60. CountLowSort.Visibility = Visibility.Visible;
  61. resType = SortType.COUNT_LOW;
  62. }
  63. break;
  64. case SortType.COUNT_LOW:
  65. if (rb.IsChecked == true)
  66. {
  67. CountUpSort.IsChecked = true;
  68. CountLowSort.Visibility = Visibility.Collapsed;
  69. CountUpSort.Visibility = Visibility.Visible;
  70. resType = SortType.COUNT_UP;
  71. }
  72. break;
  73. case SortType.NAME_UP:
  74. if (rb.IsChecked == true)
  75. {
  76. NameLowSort.IsChecked = true;
  77. NameUpSort.Visibility = Visibility.Collapsed;
  78. NameLowSort.Visibility = Visibility.Visible;
  79. resType = SortType.NAME_LOW;
  80. }
  81. break;
  82. case SortType.NAME_LOW:
  83. if (rb.IsChecked == true)
  84. {
  85. NameUpSort.IsChecked = true;
  86. NameLowSort.Visibility = Visibility.Collapsed;
  87. NameUpSort.Visibility = Visibility.Visible;
  88. resType = SortType.NAME_UP;
  89. }
  90. break;
  91. }
  92. MainWindow.appData.AppConfig.IconSortType = resType;
  93. CommonCode.SortIconList();
  94. }
  95. private void Sort_Check()
  96. {
  97. if (NameLowSort.IsChecked == true)
  98. {
  99. NameUpSort.Visibility = Visibility.Collapsed;
  100. NameLowSort.Visibility = Visibility.Visible;
  101. }
  102. if (CountLowSort.IsChecked == true)
  103. {
  104. CountUpSort.Visibility = Visibility.Collapsed;
  105. CountLowSort.Visibility = Visibility.Visible;
  106. }
  107. }
  108. private void BakDataFile(object sender, RoutedEventArgs e)
  109. {
  110. CommonCode.BakAppData();
  111. }
  112. private void ShowSeconds_Click(object sender, RoutedEventArgs e)
  113. {
  114. //if (MainWindow.appData.AppConfig.SecondsWindow == true)
  115. //{
  116. // //StartSecondsWindow();
  117. // //SecondsWindow.ShowWindow();
  118. // MouseHookThread.Dispose();
  119. // MouseHookThread.Hook();
  120. //}
  121. //else
  122. //{
  123. // MouseHookThread.Dispose();
  124. // MouseHookThread.Hook();
  125. //}
  126. MouseHookThread.Dispose();
  127. MouseHookThread.Hook();
  128. }
  129. public static void StopSecondsWindow()
  130. {
  131. if (MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
  132. {
  133. MessageUtil.SendMsgByWName(
  134. "ShowSeconds_Main_" + Constants.MY_UUID,
  135. "Shutdown"
  136. );
  137. }
  138. }
  139. //public static void StartSecondsWindow()
  140. //{
  141. // try
  142. // {
  143. // using (var objOS = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
  144. // {
  145. // foreach (ManagementObject objMgmt in objOS.Get())
  146. // {
  147. // if (objMgmt.Properties["Caption"].Value != null)
  148. // {
  149. // string caption = objMgmt.Properties["Caption"].Value.ToString(); ;
  150. // LogUtil.WriteLog("获取的系统版本号为:" + caption);
  151. // if (caption.Contains("Windows 11"))
  152. // {
  153. // //找到ShowSeconds插件
  154. // FileInfo fi = FileUtil.GetFileByNameWithDir("ShowSeconds.exe", Constants.PLUGINS_PATH);
  155. // if (fi == null)
  156. // {
  157. // HandyControl.Controls.MessageBox.Show("未安装程序插件:ShowSeconds");
  158. // }
  159. // else
  160. // {
  161. // //检查是否在运行
  162. // if (!MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
  163. // {
  164. // using (Process p = new Process())
  165. // {
  166. // p.StartInfo.FileName = fi.FullName;
  167. // p.StartInfo.WorkingDirectory = fi.FullName.Substring(0, fi.FullName.LastIndexOf("\\"));
  168. // p.Start();
  169. // }
  170. // }
  171. // }
  172. // }
  173. // }
  174. // }
  175. // }
  176. // }
  177. // catch (Exception ex) { }
  178. //}
  179. }
  180. }