ConfigWindow.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using GeekDesk.Control.UserControls.Config;
  2. using GeekDesk.Interface;
  3. using GeekDesk.Util;
  4. using GeekDesk.ViewModel;
  5. using HandyControl.Controls;
  6. using System.Collections.Generic;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Input;
  10. namespace GeekDesk.Control.Windows
  11. {
  12. /// <summary>
  13. /// ConfigDialog.xaml 的交互逻辑
  14. /// </summary>
  15. public partial class ConfigWindow : IWindowCommon
  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. private static List<UserControl> ucList = new List<UserControl>();
  22. static ConfigWindow()
  23. {
  24. ucList.Add(about);
  25. ucList.Add(theme);
  26. ucList.Add(motion);
  27. ucList.Add(other);
  28. }
  29. public MainWindow mainWindow;
  30. private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
  31. {
  32. InitializeComponent();
  33. //BG.Source = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
  34. this.DataContext = appConfig;
  35. RightCard.Content = about;
  36. WindowUtil.SetOwner(this, mainWindow);
  37. this.mainWindow = mainWindow;
  38. UFG.Visibility = Visibility.Collapsed;
  39. UFG.Visibility = Visibility.Visible;
  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. UFG.Visibility = Visibility.Collapsed;
  57. RightCard.Content = motion;
  58. UFG.Visibility = Visibility.Visible;
  59. break;
  60. case "Theme":
  61. UFG.Visibility = Visibility.Collapsed;
  62. RightCard.Content = theme;
  63. UFG.Visibility = Visibility.Visible;
  64. break;
  65. case "Other":
  66. UFG.Visibility = Visibility.Collapsed;
  67. RightCard.Content = other;
  68. UFG.Visibility = Visibility.Visible;
  69. break;
  70. default:
  71. UFG.Visibility = Visibility.Collapsed;
  72. RightCard.Content = about;
  73. UFG.Visibility = Visibility.Visible;
  74. break;
  75. }
  76. }
  77. /// <summary>
  78. /// 移动窗口
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  83. {
  84. if (e.LeftButton == MouseButtonState.Pressed)
  85. {
  86. this.DragMove();
  87. }
  88. }
  89. private static System.Windows.Window window = null;
  90. public static void Show(AppConfig appConfig, MainWindow mainWindow)
  91. {
  92. if (window == null || !window.Activate())
  93. {
  94. window = new ConfigWindow(appConfig, mainWindow);
  95. }
  96. window.Show();
  97. Keyboard.Focus(window);
  98. }
  99. public void OnKeyDown(object sender, KeyEventArgs e)
  100. {
  101. if (e.Key == Key.Escape)
  102. {
  103. this.DataContext = null;
  104. this.Close();
  105. }
  106. }
  107. }
  108. }