ThemeControl.xaml.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using GeekDesk.Util;
  2. using GeekDesk.ViewModel;
  3. using Microsoft.Win32;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace GeekDesk.Control.UserControls.Config
  19. {
  20. /// <summary>
  21. /// MotionControl.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class ThemeControl : System.Windows.Controls.UserControl
  24. {
  25. private static AppConfig appConfig = MainWindow.appData.AppConfig;
  26. public ThemeControl()
  27. {
  28. InitializeComponent();
  29. }
  30. /// <summary>
  31. /// 修改背景图片
  32. /// </summary>
  33. /// <param name="sender"></param>
  34. /// <param name="e"></param>
  35. private void BGButton_Click(object sender, RoutedEventArgs e)
  36. {
  37. try
  38. {
  39. OpenFileDialog ofd = new OpenFileDialog
  40. {
  41. Multiselect = false, //只允许选中单个文件
  42. Filter = "图像文件(*.png, *.jpg)|*.png;*.jpg;*.gif"
  43. };
  44. if (ofd.ShowDialog() == true)
  45. {
  46. appConfig.BitmapImage = ImageUtil.GetBitmapImageByFile(ofd.FileName);
  47. appConfig.BacImgName = ofd.FileName;
  48. }
  49. }
  50. catch (Exception)
  51. {
  52. HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
  53. }
  54. }
  55. private void ColorButton_Click(object sender, RoutedEventArgs e)
  56. {
  57. ColorPanel.Visibility = Visibility.Visible;
  58. }
  59. private void ColorPicker_Canceled(object sender, EventArgs e)
  60. {
  61. ColorPanel.Visibility = Visibility.Collapsed;
  62. }
  63. private void ColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
  64. {
  65. SolidColorBrush scb = ColorPicker.SelectedBrush;
  66. appConfig.TextColor = scb.ToString();
  67. ColorPanel.Visibility = Visibility.Collapsed;
  68. }
  69. /// <summary>
  70. /// 移动窗口
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  75. {
  76. if (e.LeftButton == MouseButtonState.Pressed)
  77. {
  78. Window.GetWindow(this).DragMove();
  79. }
  80. }
  81. }
  82. }