From 5dac03bb2085d8aa581cf1357c240b759ee79fd5 Mon Sep 17 00:00:00 2001 From: sunhonglei Date: Wed, 25 Dec 2024 17:42:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=A2=9C=E8=89=B2=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViewModel/Configuration/SettingBaseVM.cs | 3 + .../SettingsPages/ModelColorSetPageVM.cs | 105 +++++++++++++++++- .../Configuration/SettingsPages/SettingsVM.cs | 4 +- .../SettingPages/ModelColorSetPage.xaml | 44 ++++---- .../SettingPages/ModelColorSetPage.xaml.cs | 2 +- Views/Grading/DiamondSelect.xaml | 1 + 6 files changed, 130 insertions(+), 29 deletions(-) diff --git a/ViewModel/Configuration/SettingBaseVM.cs b/ViewModel/Configuration/SettingBaseVM.cs index 16d7162..be859a1 100644 --- a/ViewModel/Configuration/SettingBaseVM.cs +++ b/ViewModel/Configuration/SettingBaseVM.cs @@ -1,3 +1,4 @@ +using SparkClient.ViewModel.BaseWindow; using SparkClient.ViewModel.Configuration.SettingsPages; using System.Windows.Input; @@ -20,5 +21,7 @@ public class SettingBaseVM : BaseViewModel public void Save(object param) { CustomSetContent.SaveUpdate(param); + ModelColorSetContent.SaveUpdate(param); + WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); } } \ No newline at end of file diff --git a/ViewModel/Configuration/SettingsPages/ModelColorSetPageVM.cs b/ViewModel/Configuration/SettingsPages/ModelColorSetPageVM.cs index dd516de..d67b58f 100644 --- a/ViewModel/Configuration/SettingsPages/ModelColorSetPageVM.cs +++ b/ViewModel/Configuration/SettingsPages/ModelColorSetPageVM.cs @@ -1,7 +1,106 @@ +using SparkClient.Model.Helper; + namespace SparkClient.ViewModel.Configuration.SettingsPages; -public class ModelColorSetPageVM +public class ModelColorSetPageVM : BaseViewModel { - - + private string _FACET_COLOR; + private string _BORDER_COLOR; + private string _SELECTED_FACET_COLOR; + private string _SELECTED_BORDER_COLOR; + private string _SELECTED_TYPE_COLOR; + private string _SELECTED_FONT_COLOR; + private string _RULER_COLOR; + private string _ARROW_COLOR; + private string _BLEMISH_FACET_COLOR; + private string _TABLE_FACET_COLOR; + private string _UPPER_MAIN_FACET_COLOR; + private string _STAR_FACET_COLOR; + private string _UPPER_GIRDLE_FACET_COLOR; + private string _GIRDLE_FACET_COLOR; + private string _PAVILION_MAIN_FACET_COLOR; + private string _LOWER_GIRDLE_FACET_COLOR; + private string _CULET_COLOR; + public string FACET_COLOR { get { return _FACET_COLOR; } set { _FACET_COLOR = value; OnPropertyChanged(nameof(FACET_COLOR)); } } + public string BORDER_COLOR { get { return _BORDER_COLOR; } set { _BORDER_COLOR = value; OnPropertyChanged(nameof(BORDER_COLOR)); } } + public string SELECTED_FACET_COLOR { get { return _SELECTED_FACET_COLOR; } set { _SELECTED_FACET_COLOR = value; OnPropertyChanged(nameof(SELECTED_FACET_COLOR)); } } + public string SELECTED_BORDER_COLOR { get { return _SELECTED_BORDER_COLOR; } set { _SELECTED_BORDER_COLOR = value; OnPropertyChanged(nameof(SELECTED_BORDER_COLOR)); } } + public string SELECTED_TYPE_COLOR { get { return _SELECTED_TYPE_COLOR; } set { _SELECTED_TYPE_COLOR = value; OnPropertyChanged(nameof(SELECTED_TYPE_COLOR)); } } + public string SELECTED_FONT_COLOR { get { return _SELECTED_FONT_COLOR; } set { _SELECTED_FONT_COLOR = value; OnPropertyChanged(nameof(SELECTED_FONT_COLOR)); } } + public string RULER_COLOR { get { return _RULER_COLOR; } set { _RULER_COLOR = value; OnPropertyChanged(nameof(RULER_COLOR)); } } + public string ARROW_COLOR { get { return _ARROW_COLOR; } set { _ARROW_COLOR = value; OnPropertyChanged(nameof(ARROW_COLOR)); } } + public string BLEMISH_FACET_COLOR { get { return _BLEMISH_FACET_COLOR; } set { _BLEMISH_FACET_COLOR = value; OnPropertyChanged(nameof(BLEMISH_FACET_COLOR)); } } + public string TABLE_FACET_COLOR { get { return _TABLE_FACET_COLOR; } set { _TABLE_FACET_COLOR = value; OnPropertyChanged(nameof(TABLE_FACET_COLOR)); } } + public string UPPER_MAIN_FACET_COLOR { get { return _UPPER_MAIN_FACET_COLOR; } set { _UPPER_MAIN_FACET_COLOR = value; OnPropertyChanged(nameof(UPPER_MAIN_FACET_COLOR)); } } + public string STAR_FACET_COLOR { get { return _STAR_FACET_COLOR; } set { _STAR_FACET_COLOR = value; OnPropertyChanged(nameof(STAR_FACET_COLOR)); } } + public string UPPER_GIRDLE_FACET_COLOR { get { return _UPPER_GIRDLE_FACET_COLOR; } set { _UPPER_GIRDLE_FACET_COLOR = value; OnPropertyChanged(nameof(UPPER_GIRDLE_FACET_COLOR)); } } + public string GIRDLE_FACET_COLOR { get { return _GIRDLE_FACET_COLOR; } set { _GIRDLE_FACET_COLOR = value; OnPropertyChanged(nameof(GIRDLE_FACET_COLOR)); } } + public string PAVILION_MAIN_FACET_COLOR { get { return _PAVILION_MAIN_FACET_COLOR; } set { _PAVILION_MAIN_FACET_COLOR = value; OnPropertyChanged(nameof(PAVILION_MAIN_FACET_COLOR)); } } + public string LOWER_GIRDLE_FACET_COLOR { get { return _LOWER_GIRDLE_FACET_COLOR; } set { _LOWER_GIRDLE_FACET_COLOR = value; OnPropertyChanged(nameof(LOWER_GIRDLE_FACET_COLOR)); } } + public string CULET_COLOR { get { return _CULET_COLOR; } set { _CULET_COLOR = value; OnPropertyChanged(nameof(CULET_COLOR)); } } + + private Dictionary colors; + public ModelColorSetPageVM() + { + InitSetting(); + } + + private void InitSetting() + { + colors = new Dictionary(); + colors.Add("FACET_COLOR", "面部颜色"); + colors.Add("BORDER_COLOR", "边框颜色"); + colors.Add("SELECTED_FACET_COLOR", "选中面颜色"); + colors.Add("SELECTED_BORDER_COLOR", "选中面边框颜色"); + colors.Add("SELECTED_TYPE_COLOR", "选中面同类面颜色"); + colors.Add("SELECTED_FONT_COLOR", "选中面文字信息颜色"); + colors.Add("RULER_COLOR", "标识线条颜色"); + colors.Add("ARROW_COLOR", "正方向标记颜色"); + colors.Add("BLEMISH_FACET_COLOR", "瑕疵面颜色"); + colors.Add("TABLE_FACET_COLOR", "台面颜色"); + colors.Add("UPPER_MAIN_FACET_COLOR", "风筝面颜色"); + colors.Add("STAR_FACET_COLOR", "星刻面颜色"); + colors.Add("UPPER_GIRDLE_FACET_COLOR", "上腰面颜色"); + colors.Add("GIRDLE_FACET_COLOR", "腰面颜色"); + colors.Add("PAVILION_MAIN_FACET_COLOR", "亭部主刻面颜色"); + colors.Add("LOWER_GIRDLE_FACET_COLOR", "下腰面颜色"); + colors.Add("CULET_COLOR", "底面颜色"); + + foreach (var color in colors) + { + setColor(color.Key); + } + } + + public void SaveUpdate(object param) + { + DataBaseHelper.BeginTransaction(); + foreach(var color in colors) + { + updateDataBase(color.Key); + } + DataBaseHelper.commit(); + } + private void updateDataBase(string SETTING_ID) + { + Type type = this.GetType(); + Settings colorData = new Settings() + { + Key = SETTING_ID, + ItemName = colors[SETTING_ID], + Value = (string)type.GetProperty(SETTING_ID).GetValue(this), + }; + colorData.insert(); + } + private void setColor(string SETTING_ID) + { + var value = Settings.SelectValueByName("SETTING_ID"); + if (value == null || string.IsNullOrEmpty(value)) + { + value = "#FF000000"; + } + Type type = this.GetType(); + type.GetProperty(SETTING_ID).SetValue(this, value); + } + } \ No newline at end of file diff --git a/ViewModel/Configuration/SettingsPages/SettingsVM.cs b/ViewModel/Configuration/SettingsPages/SettingsVM.cs index d1795d9..59e7931 100644 --- a/ViewModel/Configuration/SettingsPages/SettingsVM.cs +++ b/ViewModel/Configuration/SettingsPages/SettingsVM.cs @@ -101,8 +101,6 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages MultilingualHelper.setLanguage(_languageId); updateDataBase(); - - WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); } private void updateDataBase() { @@ -184,7 +182,7 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages } } } - class Settings + public class Settings { private static string TABLE_NAME = "SETTING"; diff --git a/Views/Configuration/SettingPages/ModelColorSetPage.xaml b/Views/Configuration/SettingPages/ModelColorSetPage.xaml index 1939f6e..1a7f7ed 100644 --- a/Views/Configuration/SettingPages/ModelColorSetPage.xaml +++ b/Views/Configuration/SettingPages/ModelColorSetPage.xaml @@ -21,7 +21,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -60,7 +60,7 @@ @@ -68,7 +68,7 @@ @@ -99,7 +99,7 @@