diff --git a/App.xaml b/App.xaml index 186e68c..cf3a53b 100644 --- a/App.xaml +++ b/App.xaml @@ -8,7 +8,9 @@ xmlns:configView="clr-namespace:SparkClient.Views.Configuration" xmlns:gradingView="clr-namespace:SparkClient.Views.Grading" xmlns:gradingVM="clr-namespace:SparkClient.ViewModel.Grading" - xmlns:viewModel="clr-namespace:SparkClient.ViewModel" + xmlns:viewModel="clr-namespace:SparkClient.ViewModel" + xmlns:dialogVM="clr-namespace:SparkClient.ViewModel.Dialog" + xmlns:dialogView="clr-namespace:SparkClient.Views.Dialog" StartupUri="MainWindow.xaml"> @@ -52,6 +54,9 @@ + + + diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml index e608003..8d54950 100644 --- a/Language/zh_CN.xaml +++ b/Language/zh_CN.xaml @@ -40,6 +40,7 @@ 取消 确认 + 数据保存成功 数据保存失败 没有导入数据 @@ -48,6 +49,22 @@ STANDARD_NAME SHAPE_NAME INSTITUTE_NAME + + 请输入上传钻石编码 + 确定 + 跳过 + 没有输入钻石编码 + + 圆形 + 心形 + 枕形 + 梨形 + 公主方形 + 椭圆形 + 祖母绿形 + 异形钻 + + 正在检测,请等待... 平均 diff --git a/Resource/Images/Cushion-shaped.png b/Resource/Images/Cushion-shaped.png new file mode 100644 index 0000000..47079a4 Binary files /dev/null and b/Resource/Images/Cushion-shaped.png differ diff --git a/Resource/Images/Emerald-shape.png b/Resource/Images/Emerald-shape.png new file mode 100644 index 0000000..9eaf1fc Binary files /dev/null and b/Resource/Images/Emerald-shape.png differ diff --git a/Resource/Images/Heart-shaped.png b/Resource/Images/Heart-shaped.png new file mode 100644 index 0000000..9e8871e Binary files /dev/null and b/Resource/Images/Heart-shaped.png differ diff --git a/Resource/Images/Odd-shaped.png b/Resource/Images/Odd-shaped.png new file mode 100644 index 0000000..d8df207 Binary files /dev/null and b/Resource/Images/Odd-shaped.png differ diff --git a/Resource/Images/Pear-shaped.png b/Resource/Images/Pear-shaped.png new file mode 100644 index 0000000..4a06891 Binary files /dev/null and b/Resource/Images/Pear-shaped.png differ diff --git a/Resource/Images/Princess-shaped.png b/Resource/Images/Princess-shaped.png new file mode 100644 index 0000000..9b5125e Binary files /dev/null and b/Resource/Images/Princess-shaped.png differ diff --git a/Resource/Images/oval.png b/Resource/Images/oval.png new file mode 100644 index 0000000..6c7fa73 Binary files /dev/null and b/Resource/Images/oval.png differ diff --git a/Resource/Images/round_3x.png b/Resource/Images/round_3x.png new file mode 100644 index 0000000..ff43dd0 Binary files /dev/null and b/Resource/Images/round_3x.png differ diff --git a/Resource/Images/round_P8-P8.png b/Resource/Images/round_P8-P8.png new file mode 100644 index 0000000..93573b1 Binary files /dev/null and b/Resource/Images/round_P8-P8.png differ diff --git a/SparkClient.csproj b/SparkClient.csproj index fd168fe..9c1e876 100644 --- a/SparkClient.csproj +++ b/SparkClient.csproj @@ -23,13 +23,36 @@ + + + + + + + + + + + + + + + + + + + + Always + + PreserveNewest + diff --git a/ViewModel/BaseWindow/HomeWindowVM.cs b/ViewModel/BaseWindow/HomeWindowVM.cs index a29e27e..ce8ebae 100644 --- a/ViewModel/BaseWindow/HomeWindowVM.cs +++ b/ViewModel/BaseWindow/HomeWindowVM.cs @@ -4,42 +4,44 @@ using System.Windows.Input; using HandyControl.Controls; using SparkClient.Model.Helper; using SparkClient.ViewModel.Configuration; +using SparkClient.ViewModel.Dialog; using SparkClient.ViewModel.Grading; +using SparkClient.Views.Dialog; +using SparkClient.Views.Grading; namespace SparkClient.ViewModel.BaseWindow; public class HomeWindowVM : BaseViewModel { - public ICommand ShowHelperPageCommand { get; } - - public ICommand ShowConfigPageCommand { get; } - public ICommand ShowDiamondSelPageCommand { get; } + public ICommand ShowHelperPageCommand { get; } - public HomeWindowVM() - { - ShowHelperPageCommand = new RelayCommand(ShowHelperPage); - ShowConfigPageCommand = new RelayCommand(ShowConfigPage); - ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage); - } + public ICommand ShowConfigPageCommand { get; } + public ICommand ShowDiamondSelPageCommand { get; } - public void ShowHelperPage(object parameter) - { - BaseControlVM vm = new BaseControlVM(new HelperPageVM(), MultilingualHelper.getString("Help")); - WindowManager.mainViewModel.Content = vm; - WindowManager.openContent.Add(vm); - } + public HomeWindowVM() + { + ShowHelperPageCommand = new RelayCommand(ShowHelperPage); + ShowConfigPageCommand = new RelayCommand(ShowConfigPage); + ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage); + } - public void ShowConfigPage(object parameter) - { - ConfigMenuPageVM vm = new ConfigMenuPageVM(); - WindowManager.mainViewModel.Content = vm; - WindowManager.openContent.Add(vm); - } - - public void ShowDiamlondSelPage(object parameter) - { - BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult")); - WindowManager.mainViewModel.Content = vm; - WindowManager.openContent.Add(vm); - } + public void ShowHelperPage(object parameter) + { + BaseControlVM vm = new BaseControlVM(new HelperPageVM(), MultilingualHelper.getString("Help")); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + + public void ShowConfigPage(object parameter) + { + ConfigMenuPageVM vm = new ConfigMenuPageVM(); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + + public void ShowDiamlondSelPage(object parameter) + { + StartDialog dialog = new StartDialog(); + dialog.ShowDialog(); + } } \ No newline at end of file diff --git a/ViewModel/Dialog/StartDialogVM.cs b/ViewModel/Dialog/StartDialogVM.cs new file mode 100644 index 0000000..41d6b5b --- /dev/null +++ b/ViewModel/Dialog/StartDialogVM.cs @@ -0,0 +1,57 @@ +using HandyControl.Controls; +using SparkClient.Model.Helper; +using SparkClient.ViewModel.BaseWindow; +using SparkClient.ViewModel.Grading; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace SparkClient.ViewModel.Dialog +{ + internal class StartDialogVM : BaseViewModel + { + public ICommand SkipCommand { get; } + public ICommand OkCommand { get; } + private string _inputText; + public string InputText + { + get { return _inputText; } + set { _inputText = value; OnPropertyChanged("Institutes"); } + } + public StartDialogVM() + { + SkipCommand = new RelayCommand(Skip); + OkCommand = new RelayCommand(Ok); + } + + public void InitStartDialog(object param) + { + + } + + public void Skip(object parameter) + { + BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(""), MultilingualHelper.getString("DiamondSelect")); + vm.ShowFunctionButton = System.Windows.Visibility.Hidden; + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + + public void Ok(object parameter) + { + if (InputText != null && InputText.Trim().Length > 0) { + BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(InputText), MultilingualHelper.getString("DiamondSelect")); + vm.ShowFunctionButton = System.Windows.Visibility.Hidden; + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + else + { + Growl.Error(MultilingualHelper.getString("NoDiamondCode")); + } + } + } +} diff --git a/ViewModel/Grading/DiamondSelectVM.cs b/ViewModel/Grading/DiamondSelectVM.cs index 7572ecd..e7cd23b 100644 --- a/ViewModel/Grading/DiamondSelectVM.cs +++ b/ViewModel/Grading/DiamondSelectVM.cs @@ -1,17 +1,76 @@ +using SparkClient.Model.Helper; +using SparkClient.ViewModel.BaseWindow; +using SparkClient.Views.Dialog; +using System; +using System.DirectoryServices.ActiveDirectory; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + namespace SparkClient.ViewModel.Grading; public class DiamondSelectVM : BaseViewModel { - public DiamondSelectVM() + private string DiamondCode { get; set; } + private List _buttons; + private List _buttons2; + private ICommand ChangeDiamondTypeCommand; + private ICommand StartGradingCommand; + public List Buttons { + get { return _buttons; } + set + { + _buttons = value; + OnPropertyChanged(nameof(Buttons)); + } + } + public List Buttons2 { + get { return _buttons2; } + set + { + _buttons2 = value; + OnPropertyChanged(nameof(Buttons2)); + } } + + public DiamondSelectVM(string DiamondCode) + { + ChangeDiamondTypeCommand = new RelayCommand(ChangeDiamondType); + StartGradingCommand = new RelayCommand(StartGrading); + this.DiamondCode = DiamondCode; + List tempButtons = new List(); + List buttonInfos = GetButtonInfos(); + foreach (var buttonInfo in buttonInfos) + { + var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/" + buttonInfo.ImageName, UriKind.RelativeOrAbsolute)); + ButtonViewModel button = new ButtonViewModel() { Text = buttonInfo.ButtonName, ImageSource = bitmap, Type = buttonInfo.Type, Command = ChangeDiamondTypeCommand ,IsEnabled= buttonInfo.IsEnabled, IsHighlighted = false}; + tempButtons.Add(button); + } + Buttons = tempButtons; + } + private List GetButtonInfos() + { + List buttonInfos = new List(); + buttonInfos.Add(new ButtonInfo() { Type = "round", IsEnabled = true, ImageName = "round_3x.png", ButtonName = MultilingualHelper.getString("圆形") }); + buttonInfos.Add(new ButtonInfo() { Type = "Heart", IsEnabled = false, ImageName = "Heart-shaped.png", ButtonName = MultilingualHelper.getString("心形") }); + buttonInfos.Add(new ButtonInfo() { Type = "cushion", IsEnabled = false, ImageName = "Cushion-shaped.png", ButtonName = MultilingualHelper.getString("枕形") }); + buttonInfos.Add(new ButtonInfo() { Type = "Pear", IsEnabled = false, ImageName = "Pear-shaped.png", ButtonName = MultilingualHelper.getString("梨形") }); + buttonInfos.Add(new ButtonInfo() { Type = "Princess", IsEnabled = false, ImageName = "Princess-shaped.png", ButtonName = MultilingualHelper.getString("公主方形") }); + buttonInfos.Add(new ButtonInfo() { Type = "oval", IsEnabled = false, ImageName = "oval.png", ButtonName = MultilingualHelper.getString("椭圆形") }); + buttonInfos.Add(new ButtonInfo() { Type = "Emerald", IsEnabled = false, ImageName = "Emerald-shape.png", ButtonName = MultilingualHelper.getString("祖母绿形") }); + buttonInfos.Add(new ButtonInfo() { Type = "Odd", IsEnabled = false, ImageName = "Odd-shaped.png", ButtonName = MultilingualHelper.getString("异形钻") }); + return buttonInfos; + } /// /// 获取钻石列表 /// /// public void InitDiamondList(object param) { + } /// @@ -20,24 +79,143 @@ public class DiamondSelectVM : BaseViewModel /// 钻石类型 public void ChangeDiamondType(object type) { - + if (type!= null) + { + foreach (var item in Buttons.Where(x => x.Type == type)) + { + item.IsHighlighted = true; + }; + List tempButtons2 = new List(); + var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/round_P8-P8.png", UriKind.RelativeOrAbsolute)); + ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "round", Command = StartGradingCommand }; + tempButtons2.Add(button); + Buttons2 = tempButtons2; + } } /// /// 开始检测(对soc和算法开始通讯) /// /// - public void StartGrading(object param) + public async void StartGrading(object param) { - - } + if (param != null) + { + LoadingDialog loading = new LoadingDialog(); + var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => loading.ShowDialog())); + await Task.Run(async () => + { + for (int i = 0; i <= 100; i++) + { + // 模拟耗时操作 + //System.Threading.Thread.Sleep(50); // 休眠50毫秒 + await Task.Delay(1000); + // 更新进度条的值(需要在UI线程上执行) + loading.Dispatcher.Invoke(() => + { + loading.setValue(i); + }); + + } + }); + loading.Close(); + } + } + /// /// 跳转至检测结果 /// /// public void GradingResult(object param) { - + BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("GradingResult")); + vm.ShowFunctionButton = System.Windows.Visibility.Hidden; + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } +} +public class ButtonInfo +{ + public string Type { get; set; } + public string ImageName { get; set; } + public string ButtonName { get; set; } + public bool IsEnabled { get; set; } +} +public class ButtonViewModel : BaseViewModel +{ + private string _text; + private BitmapImage _imageSource; + private ICommand _command; + private string _type; + private int _col; + private bool _isEnabled; + private bool _isHighlighted; + + + public string Text + { + get { return _text; } + set + { + _text = value; + OnPropertyChanged(nameof(Text)); + } + } + + public BitmapImage ImageSource + { + get { return _imageSource; } + set + { + _imageSource = value; + OnPropertyChanged(nameof(ImageSource)); + } + } + + public ICommand Command + { + get { return _command; } + set + { + _command = value; + OnPropertyChanged(nameof(Command)); + } + } + public string Type + { + get { return _type; } + set + { + _type = value; + OnPropertyChanged(nameof(Type)); + } + } + public int Column + { + get { return _col; } + set + { + _col = value; + OnPropertyChanged(nameof(Column)); + } + } + public bool IsEnabled + { + get { return _isEnabled; } + set + { + _isEnabled = value; + OnPropertyChanged(nameof(IsEnabled)); + } + } + public bool IsHighlighted + { + get { return _isHighlighted; } + set + { + _isHighlighted = value; + OnPropertyChanged(nameof(IsHighlighted)); + } } } \ No newline at end of file diff --git a/Views/Dialog/LoadingDialog.xaml b/Views/Dialog/LoadingDialog.xaml new file mode 100644 index 0000000..3a84e9a --- /dev/null +++ b/Views/Dialog/LoadingDialog.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/Views/Dialog/StartDialog.xaml b/Views/Dialog/StartDialog.xaml new file mode 100644 index 0000000..a7ca79a --- /dev/null +++ b/Views/Dialog/StartDialog.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +