ConfigWindow.xaml.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 readonly AboutControl about = new AboutControl();
  18. private static readonly ThemeControl theme = new ThemeControl();
  19. private static readonly MotionControl motion = new MotionControl();
  20. private static readonly 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 Close_Button_Click(object sender, RoutedEventArgs e)
  36. {
  37. this.Close();
  38. }
  39. private void MemuClick(object sender, RoutedEventArgs e)
  40. {
  41. SideMenuItem smi = sender as SideMenuItem;
  42. switch (smi.Tag.ToString())
  43. {
  44. case "Motion":
  45. RightCard.Content = motion;
  46. break;
  47. case "Theme":
  48. RightCard.Content = theme;
  49. break;
  50. case "Other":
  51. RightCard.Content = other;
  52. break;
  53. default:
  54. RightCard.Content = about;
  55. break;
  56. }
  57. }
  58. /// <summary>
  59. /// 移动窗口
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  64. {
  65. if (e.LeftButton == MouseButtonState.Pressed)
  66. {
  67. this.DragMove();
  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. }