56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using _29WxOrderWpf.ViewModels;
|
|
using AllBase;
|
|
using AllBase.Model.Config;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using Work.BaseForms;
|
|
|
|
namespace _29WxOrderWpf.Ctrls.Settings;
|
|
|
|
/// <summary>
|
|
/// SettingsView.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class SettingsView : Window
|
|
{
|
|
private SettingViewModel vm;
|
|
public SettingsView()
|
|
{
|
|
InitializeComponent();
|
|
vm = new SettingViewModel();
|
|
this.DataContext = vm;
|
|
this.Loaded += SettingsView_Loaded;
|
|
this.Closed += SettingsView_Closed;
|
|
}
|
|
private void SettingsView_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
vm.Assign(BaseClass.Setting);
|
|
}
|
|
private void SettingsView_Closed(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var setting = vm.ToConfig();
|
|
BaseClass.Setting = setting;
|
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig(SettingViewModel.SettingFileName, JsonConvert.SerializeObject(setting));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseMsgForm.ShowError("配置保存错误");
|
|
}
|
|
}
|
|
|
|
|
|
}
|