|
|
|
@ -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<ButtonViewModel> _buttons; |
|
|
|
|
private List<ButtonViewModel> _buttons2; |
|
|
|
|
private ICommand ChangeDiamondTypeCommand; |
|
|
|
|
private ICommand StartGradingCommand; |
|
|
|
|
public List<ButtonViewModel> Buttons { |
|
|
|
|
get { return _buttons; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
_buttons = value; |
|
|
|
|
OnPropertyChanged(nameof(Buttons)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public List<ButtonViewModel> 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<ButtonViewModel> tempButtons = new List<ButtonViewModel>(); |
|
|
|
|
List<ButtonInfo> 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<ButtonInfo> GetButtonInfos() |
|
|
|
|
{ |
|
|
|
|
List<ButtonInfo> buttonInfos = new List<ButtonInfo>(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 获取钻石列表 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
public void InitDiamondList(object param) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -20,24 +79,143 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
/// <param name="type">钻石类型</param> |
|
|
|
|
public void ChangeDiamondType(object type) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (type!= null) |
|
|
|
|
{ |
|
|
|
|
foreach (var item in Buttons.Where(x => x.Type == type)) |
|
|
|
|
{ |
|
|
|
|
item.IsHighlighted = true; |
|
|
|
|
}; |
|
|
|
|
List<ButtonViewModel> tempButtons2 = new List<ButtonViewModel>(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 开始检测(对soc和算法开始通讯) |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 跳转至检测结果 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
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)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |