ConfigWindow.xaml.cs 3.0 KB

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