ConfigWindow.xaml.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. UFG.Visibility = Visibility.Collapsed;
  38. UFG.Visibility = Visibility.Visible;
  39. }
  40. /// <summary>
  41. /// 点击关闭按钮
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. private void Close_Button_Click(object sender, RoutedEventArgs e)
  46. {
  47. this.Close();
  48. }
  49. private void MemuClick(object sender, RoutedEventArgs e)
  50. {
  51. SideMenuItem smi = sender as SideMenuItem;
  52. switch (smi.Tag.ToString())
  53. {
  54. case "Motion":
  55. UFG.Visibility = Visibility.Collapsed;
  56. RightCard.Content = motion;
  57. UFG.Visibility = Visibility.Visible;
  58. break;
  59. case "Theme":
  60. UFG.Visibility = Visibility.Collapsed;
  61. RightCard.Content = theme;
  62. UFG.Visibility = Visibility.Visible;
  63. break;
  64. case "Other":
  65. UFG.Visibility = Visibility.Collapsed;
  66. RightCard.Content = other;
  67. UFG.Visibility = Visibility.Visible;
  68. break;
  69. default:
  70. UFG.Visibility = Visibility.Collapsed;
  71. RightCard.Content = about;
  72. UFG.Visibility = Visibility.Visible;
  73. break;
  74. }
  75. }
  76. /// <summary>
  77. /// 移动窗口
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  82. {
  83. if (e.LeftButton == MouseButtonState.Pressed)
  84. {
  85. this.DragMove();
  86. }
  87. }
  88. private static System.Windows.Window window = null;
  89. public static void Show(AppConfig appConfig, MainWindow mainWindow)
  90. {
  91. if (window == null || !window.Activate())
  92. {
  93. window = new ConfigWindow(appConfig, mainWindow);
  94. }
  95. window.Show();
  96. Keyboard.Focus(window);
  97. }
  98. public void OnKeyDown(object sender, KeyEventArgs e)
  99. {
  100. if (e.Key == Key.Escape)
  101. {
  102. this.DataContext = null;
  103. this.Close();
  104. }
  105. }
  106. }
  107. }