ConfigWindow.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 
  2. using GeekDesk.Control.UserControls;
  3. using GeekDesk.Control.UserControls.Config;
  4. using GeekDesk.ViewModel;
  5. using HandyControl.Controls;
  6. using HandyControl.Data;
  7. using System;
  8. using System.Windows;
  9. using System.Windows.Input;
  10. namespace GeekDesk.Control.Windows
  11. {
  12. /// <summary>
  13. /// ConfigDialog.xaml 的交互逻辑
  14. /// </summary>
  15. public partial class ConfigWindow
  16. {
  17. private static AboutControl about = new AboutControl();
  18. private static ThemeControl theme = new ThemeControl();
  19. private static MotionControl motion = new MotionControl();
  20. private static OtherControl other = new OtherControl();
  21. public MainWindow mainWindow;
  22. private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
  23. {
  24. InitializeComponent();
  25. this.DataContext = appConfig;
  26. RightCard.Content = about;
  27. this.Topmost = true;
  28. this.mainWindow = mainWindow;
  29. }
  30. /// <summary>
  31. /// 移动窗口
  32. /// </summary>
  33. /// <param name="sender"></param>
  34. /// <param name="e"></param>
  35. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  36. {
  37. if (e.LeftButton == MouseButtonState.Pressed)
  38. {
  39. DragMove();
  40. }
  41. }
  42. /// <summary>
  43. /// 点击关闭按钮
  44. /// </summary>
  45. /// <param name="sender"></param>
  46. /// <param name="e"></param>
  47. private void Close_Button_Click(object sender, RoutedEventArgs e)
  48. {
  49. this.Close();
  50. }
  51. private void MemuClick(object sender, RoutedEventArgs e)
  52. {
  53. SideMenuItem smi = sender as SideMenuItem;
  54. switch (smi.Tag.ToString())
  55. {
  56. case "Motion":
  57. RightCard.Content = motion;
  58. break;
  59. case "Theme":
  60. RightCard.Content = theme;
  61. break;
  62. case "Other":
  63. RightCard.Content = other;
  64. break;
  65. default:
  66. RightCard.Content = about;
  67. break;
  68. }
  69. }
  70. private static System.Windows.Window window = null;
  71. public static void Show(AppConfig appConfig, MainWindow mainWindow)
  72. {
  73. if (window == null || !window.Activate())
  74. {
  75. window = new ConfigWindow(appConfig, mainWindow);
  76. }
  77. window.Show();
  78. }
  79. }
  80. }