SettingControl.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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
  19. {
  20. /// <summary>
  21. /// SettingControl.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class SettingControl : UserControl
  24. {
  25. public SettingControl()
  26. {
  27. InitializeComponent();
  28. }
  29. private void SimplePanel_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
  30. {
  31. CommonCode.SaveAppData(MainWindow.appData);
  32. }
  33. private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
  34. {
  35. }
  36. /// <summary>
  37. /// 修改背景图片
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. private void BGButton_Click(object sender, RoutedEventArgs e)
  42. {
  43. AppConfig appConfig = MainWindow.appData.AppConfig;
  44. try
  45. {
  46. OpenFileDialog ofd = new OpenFileDialog
  47. {
  48. Multiselect = false, //只允许选中单个文件
  49. Filter = "图像文件(*.png, *.jpg)|*.png;*.jpg;*.gif"
  50. };
  51. if (ofd.ShowDialog() == true)
  52. {
  53. appConfig.BitmapImage = ImageUtil.GetBitmapImageByFile(ofd.FileName);
  54. }
  55. } catch (Exception)
  56. {
  57. HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
  58. }
  59. }
  60. }
  61. }