ConfigWindow.xaml.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public MainWindow mainWindow;
  21. private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
  22. {
  23. InitializeComponent();
  24. this.DataContext = appConfig;
  25. RightCard.Content = about;
  26. this.Topmost = true;
  27. this.mainWindow = mainWindow;
  28. }
  29. /// <summary>
  30. /// 移动窗口
  31. /// </summary>
  32. /// <param name="sender"></param>
  33. /// <param name="e"></param>
  34. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  35. {
  36. if (e.LeftButton == MouseButtonState.Pressed)
  37. {
  38. DragMove();
  39. }
  40. }
  41. /// <summary>
  42. /// 点击关闭按钮
  43. /// </summary>
  44. /// <param name="sender"></param>
  45. /// <param name="e"></param>
  46. private void Close_Button_Click(object sender, RoutedEventArgs e)
  47. {
  48. this.Close();
  49. }
  50. private void MemuClick(object sender, RoutedEventArgs e)
  51. {
  52. SideMenuItem smi = sender as SideMenuItem;
  53. switch (smi.Tag.ToString())
  54. {
  55. case "Motion":
  56. RightCard.Content = motion;
  57. break;
  58. case "Theme":
  59. RightCard.Content = theme;
  60. break;
  61. default:
  62. RightCard.Content = about;
  63. break;
  64. }
  65. }
  66. private static System.Windows.Window window = null;
  67. public static void Show(AppConfig appConfig, MainWindow mainWindow)
  68. {
  69. if (window == null || !window.Activate())
  70. {
  71. window = new ConfigWindow(appConfig, mainWindow);
  72. }
  73. window.Show();
  74. }
  75. }
  76. }