ThemeControl.xaml.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. public ThemeControl()
  26. {
  27. InitializeComponent();
  28. }
  29. /// <summary>
  30. /// 修改背景图片
  31. /// </summary>
  32. /// <param name="sender"></param>
  33. /// <param name="e"></param>
  34. private void BGButton_Click(object sender, RoutedEventArgs e)
  35. {
  36. AppConfig appConfig = MainWindow.appData.AppConfig;
  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. }
  56. }