ConfigWindow.xaml.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using GeekDesk.Control.UserControls.Config;
  2. using GeekDesk.Interface;
  3. using GeekDesk.ViewModel;
  4. using HandyControl.Controls;
  5. using System.Collections.Generic;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Input;
  9. namespace GeekDesk.Control.Windows
  10. {
  11. /// <summary>
  12. /// ConfigDialog.xaml 的交互逻辑
  13. /// </summary>
  14. public partial class ConfigWindow : IWindowCommon
  15. {
  16. private static readonly AboutControl about = new AboutControl();
  17. private static readonly ThemeControl theme = new ThemeControl();
  18. private static readonly MotionControl motion = new MotionControl();
  19. private static readonly OtherControl other = new OtherControl();
  20. private static List<UserControl> ucList = new List<UserControl>();
  21. static ConfigWindow()
  22. {
  23. ucList.Add(about);
  24. ucList.Add(theme);
  25. ucList.Add(motion);
  26. ucList.Add(other);
  27. }
  28. public MainWindow mainWindow;
  29. private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
  30. {
  31. InitializeComponent();
  32. //BG.Source = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
  33. this.DataContext = appConfig;
  34. RightCard.Content = about;
  35. this.Topmost = true;
  36. this.mainWindow = mainWindow;
  37. }
  38. /// <summary>
  39. /// 点击关闭按钮
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="e"></param>
  43. private void Close_Button_Click(object sender, RoutedEventArgs e)
  44. {
  45. this.Close();
  46. }
  47. private void MemuClick(object sender, RoutedEventArgs e)
  48. {
  49. SideMenuItem smi = sender as SideMenuItem;
  50. switch (smi.Tag.ToString())
  51. {
  52. case "Motion":
  53. UFG.Visibility = Visibility.Collapsed;
  54. RightCard.Content = motion;
  55. UFG.Visibility = Visibility.Visible;
  56. break;
  57. case "Theme":
  58. UFG.Visibility = Visibility.Collapsed;
  59. RightCard.Content = theme;
  60. UFG.Visibility = Visibility.Visible;
  61. break;
  62. case "Other":
  63. UFG.Visibility = Visibility.Collapsed;
  64. RightCard.Content = other;
  65. UFG.Visibility = Visibility.Visible;
  66. break;
  67. default:
  68. UFG.Visibility = Visibility.Collapsed;
  69. RightCard.Content = about;
  70. UFG.Visibility = Visibility.Visible;
  71. break;
  72. }
  73. }
  74. /// <summary>
  75. /// 移动窗口
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  80. {
  81. if (e.LeftButton == MouseButtonState.Pressed)
  82. {
  83. this.DragMove();
  84. }
  85. }
  86. private static System.Windows.Window window = null;
  87. public static void Show(AppConfig appConfig, MainWindow mainWindow)
  88. {
  89. if (window == null || !window.Activate())
  90. {
  91. window = new ConfigWindow(appConfig, mainWindow);
  92. }
  93. window.Show();
  94. Keyboard.Focus(window);
  95. }
  96. public void OnKeyDown(object sender, KeyEventArgs e)
  97. {
  98. if (e.Key == Key.Escape)
  99. {
  100. this.DataContext = null;
  101. this.Close();
  102. }
  103. }
  104. }
  105. }