ConfigWindow.xaml.cs 3.8 KB

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