diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml index c41e720..4702bef 100644 --- a/Language/zh_CN.xaml +++ b/Language/zh_CN.xaml @@ -23,6 +23,8 @@ 删除配置 导入配置 + 美化Json + 压缩Json 是否退出程序? diff --git a/MainWindow.xaml b/MainWindow.xaml index 7835d91..dc02990 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -100,12 +100,12 @@ diff --git a/Resource/Other/Json-Mode-Default.xshd b/Resource/Other/Json-Mode-Default.xshd new file mode 100644 index 0000000..3f3837a --- /dev/null +++ b/Resource/Other/Json-Mode-Default.xshd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + " + " + + + ' + ' + + + : + + + , + + + + + + + , + + + + + + true + false + + + null + + + " + " + + + ' + ' + + + \{ + \} + + + \[ + \] + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + + + + \ No newline at end of file diff --git a/SparkClient.csproj b/SparkClient.csproj index 8b02262..be710d8 100644 --- a/SparkClient.csproj +++ b/SparkClient.csproj @@ -9,6 +9,7 @@ + @@ -54,6 +55,8 @@ Always + + diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs index badb4ec..92d1837 100644 --- a/ViewModel/Configuration/AlgorithmConfigVM.cs +++ b/ViewModel/Configuration/AlgorithmConfigVM.cs @@ -1,13 +1,25 @@ -namespace SparkClient.ViewModel.Configuration; +using System.Windows.Input; +using HandyControl.Controls; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace SparkClient.ViewModel.Configuration; public class AlgorithmConfigVM : BaseViewModel { - + public ICommand SaveAlgorithmDataCommand { get; } + public ICommand BeautifyJsonCommand { get; } + public ICommand UglifyJsonCommand { get; } + + + private string _AlgorithmConfigJson; + public string AlgorithmConfigJson { get { return _AlgorithmConfigJson; } set { _AlgorithmConfigJson = value; OnPropertyChanged("AlgorithmConfigJson"); } } public AlgorithmConfigVM() { - // 初始化VIEW层参数 - // 初始化VIEW层Command - this.InitAlgorithmData(null); + SaveAlgorithmDataCommand = new RelayCommand(SaveAlgorithmData); + BeautifyJsonCommand = new RelayCommand(BeautifyJson); + UglifyJsonCommand = new RelayCommand(UglifyJson); + InitAlgorithmData(null); } /// @@ -16,33 +28,45 @@ public class AlgorithmConfigVM : BaseViewModel /// public void InitAlgorithmData(object param) { + AlgorithmConfigJson = "{}"; } + /// - /// 添加行 + /// 保存数据 /// - /// 行数 - public void AddRows(object row) + /// + public void SaveAlgorithmData(object param) { - + Growl.Info("Saving Algorithm Data"); } /// - /// 保存数据 + /// 梅花JSON /// /// - public void SaveAlgorithmData(object param) + public void BeautifyJson(object param) { - + try + { + AlgorithmConfigJson = JToken.Parse(AlgorithmConfigJson).ToString(); + } + catch (Exception ex) + { + Growl.Error(ex.Message); + } + + } /// - /// 删除一行数据 + /// 压缩JSON /// - /// 行 - public void DelAlgorRow(object row) + /// + public void UglifyJson(object param) { - + AlgorithmConfigJson = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(AlgorithmConfigJson)); } + } \ No newline at end of file diff --git a/Views/Configuration/AlgorithmConfigPage.xaml b/Views/Configuration/AlgorithmConfigPage.xaml index dc78983..7832b60 100644 --- a/Views/Configuration/AlgorithmConfigPage.xaml +++ b/Views/Configuration/AlgorithmConfigPage.xaml @@ -3,10 +3,45 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:local="clr-namespace:SparkClient.Views" + xmlns:configuration="clr-namespace:SparkClient.Views.Configuration" mc:Ignorable="d" > - - 算法配置 + + + + + + + + + + + + + + +