diff --git a/App.config b/App.config index f974c5c..fcec6ad 100644 --- a/App.config +++ b/App.config @@ -11,6 +11,10 @@ + + + + diff --git a/Model/Helper/ConfigurationHelper.cs b/Model/Helper/ConfigurationHelper.cs new file mode 100644 index 0000000..d6579bd --- /dev/null +++ b/Model/Helper/ConfigurationHelper.cs @@ -0,0 +1,23 @@ +using System.Configuration; + +namespace SparkClient.Model.Helper; + +public class ConfigurationHelper +{ + static System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + + public static string ReadConfigValue(string key) + { + + string name = config.AppSettings.Settings[key].Value; + + return name; + } + + public static void SetConfigValue(string key, string value) + { + config.AppSettings.Settings[key].Value = value; + config.Save(ConfigurationSaveMode.Modified); + System.Configuration.ConfigurationManager.RefreshSection("appSettings"); + } +} \ No newline at end of file diff --git a/ViewModel/BaseWindow/BaseControlVM.cs b/ViewModel/BaseWindow/BaseControlVM.cs index bc874a5..a7ce3a3 100644 --- a/ViewModel/BaseWindow/BaseControlVM.cs +++ b/ViewModel/BaseWindow/BaseControlVM.cs @@ -69,12 +69,14 @@ public class BaseControlVM : BaseViewModel WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); } else { - MessageBox message = new MessageBox(); - MessageBoxResult result = message.ShowAsk(MultilingualHelper.getString("DiamodResultCloseConfirm")); - if (MessageBoxResult.OK.Equals(result)) - { - WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); - } + // 部署改造:2 + WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); + // MessageBox message = new MessageBox(); + // MessageBoxResult result = message.ShowAsk(MultilingualHelper.getString("DiamodResultCloseConfirm")); + // if (MessageBoxResult.OK.Equals(result)) + // { + // WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); + // } } } else diff --git a/ViewModel/Grading/DiamondSelectVM.cs b/ViewModel/Grading/DiamondSelectVM.cs index fec0193..89f750d 100644 --- a/ViewModel/Grading/DiamondSelectVM.cs +++ b/ViewModel/Grading/DiamondSelectVM.cs @@ -117,7 +117,7 @@ public class DiamondSelectVM : BaseViewModel }; List tempButtons2 = new List(); var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/UIResource/round_P8-P8.png", UriKind.RelativeOrAbsolute)); - ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "ROUND P8 P8", Command = StartGradingCommand }; + ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "ROUND P8 P8", Command = StartGradingCommand, IsFocused = true}; tempButtons2.Add(button); Buttons2 = tempButtons2; } @@ -256,7 +256,7 @@ public class DiamondSelectVM : BaseViewModel try { string parameterJson = JsonConvert.SerializeObject(parameter); - ; + parameterJson = JToken.Parse(parameterJson).ToString(); string outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", "result"); if (!Directory.Exists(outputPath)) Directory.CreateDirectory(outputPath); @@ -458,7 +458,7 @@ public class DiamondSelectVM : BaseViewModel } // 生成时间戳,格式为 yyyyMMddHHmmss - string timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); + string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); // 组合新的文件夹路径 string newFolderPath = Path.Combine(imageHistoryPath, string.IsNullOrWhiteSpace(dCode) ? $"image-{timestamp}" : $"image-{dCode}-{timestamp}" ); @@ -537,6 +537,7 @@ public class DiamondSelectVM : BaseViewModel { //WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); BaseControlVM vm = new BaseControlVM(new GradingResultVM(param), MultilingualHelper.getString("DetectionResult")); + vm.WindowTitle = string.IsNullOrWhiteSpace(param.DiamondCode) ? vm.WindowTitle : $"{vm.WindowTitle} - {param.DiamondCode}"; vm.ShowFunctionButton = System.Windows.Visibility.Hidden; WindowManager.mainViewModel.Content = vm; WindowManager.openContent.Add(vm); @@ -566,7 +567,7 @@ public class ButtonViewModel : BaseViewModel private bool _isHighlighted; private Brush _foreground; private Brush _background; - + private bool _isFocused; public string Text { get { return _text; } @@ -659,6 +660,19 @@ public class ButtonViewModel : BaseViewModel } } + public bool IsFocused + { + get + { + return _isFocused; + } + set + { + _isFocused = value; + OnPropertyChanged(nameof(IsFocused)); + } + } + [Log] private void UpdateStyles() { diff --git a/ViewModel/Grading/GradingResultVM.cs b/ViewModel/Grading/GradingResultVM.cs index 66dfc02..3da5bf0 100644 --- a/ViewModel/Grading/GradingResultVM.cs +++ b/ViewModel/Grading/GradingResultVM.cs @@ -119,7 +119,9 @@ public class GradingResultVM : BaseViewModel /// /// 下拉列表DS 选择的值 /// - public string DS { get { return _ds; } set { _ds = value; OnPropertyChanged(nameof(DS)); } } + public string DS { get { return _ds; } set { _ds = value; OnPropertyChanged(nameof(DS)); + saveTempDS(value); + } } /// /// 定级下拉列表 /// @@ -192,7 +194,7 @@ public class GradingResultVM : BaseViewModel IsEnabled = false; } } - DS = "NA"; + DS = ConfigurationManager.AppSettings["DSSet"]; if (IsEnabled) { AutoSave(); @@ -295,6 +297,13 @@ public class GradingResultVM : BaseViewModel } } } + + private void saveTempDS(string selValue) + { + ConfigurationHelper.SetConfigValue("DSSet",selValue); + + } + [Log] private void InitView(AlgorithmResultEntity result) { @@ -1074,35 +1083,36 @@ public class GradingResultVM : BaseViewModel Measurements info = algorithmResult.measurements; StreamWriter stream = new StreamWriter(file); stream.WriteLine($"IGI REPORT NUMBER={DiamondCode}"); - stream.WriteLine($"SARIN WEIGHT={Wight}"); - stream.WriteLine($"M1={info.M1}"); - stream.WriteLine($"M2={info.M2}"); - stream.WriteLine($"M3={info.M3}"); - stream.WriteLine($"TABLE={info.TABLE*100}"); - stream.WriteLine($"TABLE MIN={info.TABLE_MIN * 100}"); - stream.WriteLine($"TABLE MAX={info.TABLE_MAX * 100}"); - stream.WriteLine($"CROWN HEIGHT={info.CROWN_HEIGHT * 100}"); - stream.WriteLine($"CROWN H MIN={info.CROWN_H_MIN * 100}"); - stream.WriteLine($"CROWN H MAX={info.CROWN_H_MAX * 100}"); - stream.WriteLine($"CROWN ANGLE={info.CROWN_ANGLE}"); - stream.WriteLine($"CROWN ANGLE MIN={info.CROWN_ANGLE_MIN}"); - stream.WriteLine($"CROWN ANGLE MAX={info.CROWN_ANGLE_MAX}"); - stream.WriteLine($"PAV DEPTH={info.PAV_DEPTH * 100}"); - stream.WriteLine($"PAV DEPTH MIN={info.PAV_DEPTH_MIN * 100}"); - stream.WriteLine($"PAV DEPTH MAX={info.PAV_DEPTH_MAX * 100}"); - stream.WriteLine($"PAV ANGLE={info.PAV_ANGLE}"); - stream.WriteLine($"PAV ANGLE MIN={info.PAV_ANGLE_MIN}"); - stream.WriteLine($"PAV ANGLE MAX={info.PAV_ANGLE_MAX}"); - stream.WriteLine($"GIRDLE={info.GIRDLE * 100}"); - stream.WriteLine($"GIRDLE MIN={info.GIRDLE_MIN * 100}"); - stream.WriteLine($"GIRDLE MAX={info.GIRDLE_MAX * 100}"); - stream.WriteLine($"TOTAL DEPTH={info.TOTAL_DEPTH * 100}"); - stream.WriteLine($"CULET={info.CULET*100}"); + stream.WriteLine($"SARIN WEIGHT={Double.Parse(Wight).ToString("f3")}"); + stream.WriteLine($"M1={info.M1.ToString("f2")}"); + stream.WriteLine($"M2={info.M2.ToString("f2")}"); + stream.WriteLine($"M3={info.M3.ToString("f2")}"); + stream.WriteLine($"TABLE={(info.TABLE * 100).ToString("F1")}"); + stream.WriteLine($"TABLE MIN={(info.TABLE_MIN * 100).ToString("F1")}"); + stream.WriteLine($"TABLE MAX={(info.TABLE_MAX * 100).ToString("F1")}"); + stream.WriteLine($"CROWN HEIGHT={(info.CROWN_HEIGHT * 100).ToString("F1")}"); + stream.WriteLine($"CROWN H MIN={(info.CROWN_H_MIN * 100).ToString("F1")}"); + stream.WriteLine($"CROWN H MAX={(info.CROWN_H_MAX * 100).ToString("F1")}"); + stream.WriteLine($"CROWN ANGLE={(info.CROWN_ANGLE).ToString("F1")}"); + stream.WriteLine($"CROWN ANGLE MIN={(info.CROWN_ANGLE_MIN).ToString("F1")}"); + stream.WriteLine($"CROWN ANGLE MAX={(info.CROWN_ANGLE_MAX).ToString("F1")}"); + stream.WriteLine($"PAV DEPTH={(info.PAV_DEPTH * 100).ToString("F1")}"); + stream.WriteLine($"PAV DEPTH MIN={(info.PAV_DEPTH_MIN * 100).ToString("F1")}"); + stream.WriteLine($"PAV DEPTH MAX={(info.PAV_DEPTH_MAX * 100).ToString("F1")}"); + stream.WriteLine($"PAV ANGLE={(info.PAV_ANGLE).ToString("F1")}"); + stream.WriteLine($"PAV ANGLE MIN={(info.PAV_ANGLE_MIN).ToString("F1")}"); + stream.WriteLine($"PAV ANGLE MAX={(info.PAV_ANGLE_MAX).ToString("F1")}"); + //部署值修改 + stream.WriteLine($"GIRDLE={(info.GIRDLE_BEZEL * 100).ToString("F1")}"); + stream.WriteLine($"GIRDLE MIN={(info.GIRDLE_BEZEL_MIN * 100).ToString("F1")}"); + stream.WriteLine($"GIRDLE MAX={(info.GIRDLE_BEZEL_MAX * 100).ToString("F1")}"); + stream.WriteLine($"TOTAL DEPTH={(info.TOTAL_DEPTH * 100).ToString("F1")}"); + stream.WriteLine($"CULET={(info.CULET*100).ToString("F1")}"); stream.WriteLine($"MACHINE={machine}"); stream.WriteLine($"CUTGRADE={GetGradeEnName(totalCutGrade.ToString())}"); stream.WriteLine($"LW RATIO={info.LW_RATIO}"); stream.WriteLine($"DS={DS}"); - stream.WriteLine($"COC={info.COC * 100}"); + stream.WriteLine($"COC={(info.COC * 100).ToString("F1")}"); stream.WriteLine($"USER={username}"); string TABLE_GRADE = DtResults.Where(x => "TABLE".Equals(x.TestItemId)).Select(x=>x.CutLevel).First()??""; stream.WriteLine($"TABLE GRADE={GetGradeEnName(GetGradeOrder(TABLE_GRADE))}"); @@ -1116,9 +1126,9 @@ public class GradingResultVM : BaseViewModel stream.WriteLine($"PAV ANGLE GRADE={GetGradeEnName(GetGradeOrder(PAV_ANGLE_GRADE))}"); string TD_GRADE = DtResults.Where(x => "TOTAL_DEPTH".Equals(x.TestItemId)).Select(x => x.CutLevel).First() ?? ""; stream.WriteLine($"TD GRADE={GetGradeEnName(GetGradeOrder(TD_GRADE))}"); - stream.WriteLine($"TA={info.TA}"); - stream.WriteLine($"LGF={info.LGF * 100}"); - stream.WriteLine($"STAR={info.STAR * 100}"); + stream.WriteLine($"TA={info.TA.ToString("F1")}"); + stream.WriteLine($"LGF={(info.LGF * 100).ToString("F1")}"); + stream.WriteLine($"STAR={(info.STAR * 100).ToString("F1")}"); stream.Close(); } } diff --git a/Views/Configuration/SettingPages/CustomSettingPage.xaml b/Views/Configuration/SettingPages/CustomSettingPage.xaml index b45e8e8..7d0a214 100644 --- a/Views/Configuration/SettingPages/CustomSettingPage.xaml +++ b/Views/Configuration/SettingPages/CustomSettingPage.xaml @@ -86,7 +86,7 @@ - + diff --git a/Views/Grading/DiamondSelect.xaml b/Views/Grading/DiamondSelect.xaml index a6ed48a..7087e9d 100644 --- a/Views/Grading/DiamondSelect.xaml +++ b/Views/Grading/DiamondSelect.xaml @@ -56,12 +56,13 @@ -