using CommunityToolkit.Mvvm.Messaging; using DotNet4.Utilities; using LiveTools.Data; using Newtonsoft.Json.Linq; using ryCommon; using ryCommonDb; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; 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; namespace LiveTools { /// /// FrmLogin.xaml 的交互逻辑 /// public partial class FrmSetting : UserControl { public FrmSetting() { InitializeComponent(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder + "\\Setting.json")); ChkGiftTrigger.IsChecked = json.GetJsonValue("GiftTrigger", true); ChkPlaySound.IsChecked = json.GetJsonValue("PlaySound", true); ChkMultiPlaySound.IsChecked = json.GetJsonValue("MultiPlaySound", true); NumPicSize.Value = json.GetJsonValue("PicSize", 70); NumPicCount.Value = json.GetJsonValue("PicCount", 10); } private void BtnOK_Click(object sender, RoutedEventArgs e) { Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder + "\\Setting.json")); json.SetJsonValue("GiftTrigger", ChkGiftTrigger.IsChecked??true); json.SetJsonValue("PlaySound", ChkPlaySound.IsChecked ?? true); json.SetJsonValue("MultiPlaySound", ChkMultiPlaySound.IsChecked ?? true); json.SetJsonValue("PicSize", NumPicSize.Value.ToInt()); json.SetJsonValue("PicCount", NumPicCount.Value.ToInt()); RyFiles.WriteAllText(Config.UserDbFolder + "\\Setting.json",json.Text); Config.LoadSetting(); HandyControl.Controls.MessageBox.Show("保存成功。", "提示"); } } }