|
|
|
|
@ -39,7 +39,8 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
private List<ButtonViewModel> _buttons2; |
|
|
|
|
private ICommand ChangeDiamondTypeCommand; |
|
|
|
|
private ICommand StartGradingCommand; |
|
|
|
|
public List<ButtonViewModel> Buttons { |
|
|
|
|
public List<ButtonViewModel> Buttons |
|
|
|
|
{ |
|
|
|
|
get { return _buttons; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
@ -66,7 +67,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
foreach (var buttonInfo in buttonInfos) |
|
|
|
|
{ |
|
|
|
|
var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/UIResource/" + buttonInfo.ImageName, UriKind.RelativeOrAbsolute)); |
|
|
|
|
ButtonViewModel button = new ButtonViewModel() { Text = buttonInfo.ButtonName, ImageSource = bitmap, Type = buttonInfo.Type, Command = ChangeDiamondTypeCommand ,IsEnabled= buttonInfo.IsEnabled, IsHighlighted = false}; |
|
|
|
|
ButtonViewModel button = new ButtonViewModel() { Text = buttonInfo.ButtonName, ImageSource = bitmap, Type = buttonInfo.Type, Command = ChangeDiamondTypeCommand, IsEnabled = buttonInfo.IsEnabled, IsHighlighted = false }; |
|
|
|
|
tempButtons.Add(button); |
|
|
|
|
} |
|
|
|
|
Buttons = tempButtons; |
|
|
|
|
@ -83,9 +84,9 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "round", IsEnabled = true, ImageName = "round.png", ButtonName = MultilingualHelper.getString("圆形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Hexagon", IsEnabled = false, ImageName = "Hexagon.png", ButtonName = MultilingualHelper.getString("六边形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "cushion", IsEnabled = false, ImageName = "Cushion.png", ButtonName = MultilingualHelper.getString("枕形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Pear", IsEnabled = false, ImageName = "Pear.png", ButtonName = MultilingualHelper.getString("梨形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Pear", IsEnabled = true, ImageName = "Pear.png", ButtonName = MultilingualHelper.getString("梨形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Princess", IsEnabled = false, ImageName = "Princess.png", ButtonName = MultilingualHelper.getString("公主方形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "oval", IsEnabled = false, ImageName = "oval.png", ButtonName = MultilingualHelper.getString("椭圆形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "oval", IsEnabled = true, ImageName = "oval.png", ButtonName = MultilingualHelper.getString("椭圆形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Emerald", IsEnabled = false, ImageName = "Emerald.png", ButtonName = MultilingualHelper.getString("祖母绿形") }); |
|
|
|
|
buttonInfos.Add(new ButtonInfo() { Type = "Odd", IsEnabled = false, ImageName = "Odd.png", ButtonName = MultilingualHelper.getString("异形钻") }); |
|
|
|
|
return buttonInfos; |
|
|
|
|
@ -107,19 +108,63 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
[Log] |
|
|
|
|
public void ChangeDiamondType(object type) |
|
|
|
|
{ |
|
|
|
|
if (type!= null) |
|
|
|
|
{ |
|
|
|
|
foreach (var item in Buttons.Where(x => x.Type == type)) |
|
|
|
|
// 非空处理 |
|
|
|
|
if (type == null) return; |
|
|
|
|
|
|
|
|
|
// 获取当前点选钻石形状 |
|
|
|
|
string selectedType = type.ToString(); |
|
|
|
|
|
|
|
|
|
// 恢复所有按钮状态,并高亮当前选中的按钮 |
|
|
|
|
foreach (var item in Buttons) |
|
|
|
|
{ |
|
|
|
|
item.IsHighlighted = true; |
|
|
|
|
}; |
|
|
|
|
item.IsHighlighted = item.Type == selectedType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//初始化按键集 |
|
|
|
|
List<ButtonViewModel> tempButtons2 = new List<ButtonViewModel>(); |
|
|
|
|
|
|
|
|
|
// 设置二级图片按钮路径 |
|
|
|
|
string basePath = "pack://application:,,,/Resource/Images/UIResource/Diamond/"; |
|
|
|
|
Func<string, BitmapImage> getBitmap = (fileName) => new BitmapImage(new Uri(basePath + fileName, UriKind.RelativeOrAbsolute)); |
|
|
|
|
|
|
|
|
|
// 根据选中类型生成右侧按钮 |
|
|
|
|
switch (selectedType.ToLower()) |
|
|
|
|
{ |
|
|
|
|
case "round": |
|
|
|
|
// 圆形钻石 |
|
|
|
|
AddRoundButtons(tempButtons2, getBitmap); |
|
|
|
|
break; |
|
|
|
|
case "pear": |
|
|
|
|
// 梨形钻石 |
|
|
|
|
AddPearButtons(tempButtons2, getBitmap); |
|
|
|
|
break; |
|
|
|
|
case "oval": |
|
|
|
|
// 椭圆形钻石 |
|
|
|
|
AddOvalButtons(tempButtons2, getBitmap); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
// 默认圆形 |
|
|
|
|
AddRoundButtons(tempButtons2, getBitmap); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
Buttons2 = tempButtons2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 圆形二级界面按键加载处理 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="buttons">当前页面按键</param> |
|
|
|
|
/// <param name="getBitmap">图片路径</param> |
|
|
|
|
private void AddRoundButtons(List<ButtonViewModel> buttons, Func<string, BitmapImage> getBitmap) |
|
|
|
|
{ |
|
|
|
|
// 运行模式为实验室模式 |
|
|
|
|
if (Common.RunMode == 0) |
|
|
|
|
{ |
|
|
|
|
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, IsFocused = true}; |
|
|
|
|
tempButtons2.Add(button); |
|
|
|
|
}else if (Common.RunMode == 1) |
|
|
|
|
var bitmap_p8p8 = getBitmap("round_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap_p8p8, Type = "ROUND P8 P8", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
} |
|
|
|
|
// 运行模式为工厂模式 |
|
|
|
|
else if (Common.RunMode == 1) |
|
|
|
|
{ |
|
|
|
|
var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/UIResource/Diamond/round_P8-P8.png", UriKind.RelativeOrAbsolute)); |
|
|
|
|
var bitmap_p8p8s1 = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/UIResource/Diamond/round_P8-P8-S1.png", UriKind.RelativeOrAbsolute)); |
|
|
|
|
@ -138,15 +183,66 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
new ButtonViewModel() { Text = "P8-P8 Stage 8", ImageSource = bitmap_p8p8s8, Type = "ROUND P8 P8 S8", Command = StartGradingCommand, IsFocused = true}, |
|
|
|
|
new ButtonViewModel() { Text = "P8-P8 Stage 9", ImageSource = bitmap, Type = "ROUND P8 P8 S9", Command = StartGradingCommand, IsFocused = true}, |
|
|
|
|
new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "ROUND P8 P8", Command = StartGradingCommand, IsFocused = true}, |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
listBtn.ForEach(e => buttons.Add(e)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
listBtn.ForEach(e => tempButtons2.Add(e)); |
|
|
|
|
/// <summary> |
|
|
|
|
/// 梨形二级界面按键加载处理 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="buttons">当前页面按键</param> |
|
|
|
|
/// <param name="getBitmap">图片路径</param> |
|
|
|
|
private void AddPearButtons(List<ButtonViewModel> buttons, Func<string, BitmapImage> getBitmap) |
|
|
|
|
{ |
|
|
|
|
// 运行模式为实验室模式 |
|
|
|
|
if (Common.RunMode == 0) |
|
|
|
|
{ |
|
|
|
|
// TODO 待二级图片作成后替换,以及后续检测处理追加 |
|
|
|
|
var bitmap_p8p8 = getBitmap("pear_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Pear Stage 1", ImageSource = bitmap_p8p8, Type = "PEAR S1", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
|
|
|
|
|
// 追加按钮2 |
|
|
|
|
//var bitmap_p8p8s2 = getBitmap("pear_P8-P8-S2.png"); |
|
|
|
|
//buttons.Add(new ButtonViewModel { Text = "Pear Stage 2", ImageSource = bitmap_p8p8s2, Type = "PEAR S2", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
} |
|
|
|
|
// 运行模式为工厂模式 |
|
|
|
|
else if (Common.RunMode == 1) |
|
|
|
|
{ |
|
|
|
|
// TODO 待二级图片作成后替换,以及后续检测处理追加 |
|
|
|
|
var bitmap_p8p8 = getBitmap("pear_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Pear Stage 1", ImageSource = bitmap_p8p8, Type = "PEAR S1", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
|
|
|
|
|
// TODO 虚拟追加按钮2 |
|
|
|
|
var bitmap_p8p8s2 = getBitmap("pear_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Pear Stage 2", ImageSource = bitmap_p8p8, Type = "PEAR S2", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Buttons2 = tempButtons2; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 椭圆形二级界面按键加载处理 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="buttons">当前页面按键</param> |
|
|
|
|
/// <param name="getBitmap">图片路径</param> |
|
|
|
|
private void AddOvalButtons(List<ButtonViewModel> buttons, Func<string, BitmapImage> getBitmap) |
|
|
|
|
{ |
|
|
|
|
// 运行模式为实验室模式 |
|
|
|
|
if (Common.RunMode == 0) |
|
|
|
|
{ |
|
|
|
|
// TODO 待二级图片作成后替换,以及后续检测处理追加 |
|
|
|
|
var bitmap_p8p8 = getBitmap("oval_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Oval Stage 1", ImageSource = bitmap_p8p8, Type = "OVAL S1", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
} |
|
|
|
|
// 运行模式为工厂模式 |
|
|
|
|
else if (Common.RunMode == 1) |
|
|
|
|
{ |
|
|
|
|
// TODO 待二级图片作成后替换,以及后续检测处理追加 |
|
|
|
|
var bitmap_p8p8 = getBitmap("oval_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Oval Stage 1", ImageSource = bitmap_p8p8, Type = "OVAL S1", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
|
|
|
|
|
// TODO 虚拟追加按钮2 |
|
|
|
|
var bitmap_p8p8s2 = getBitmap("oval_P8-P8.png"); |
|
|
|
|
buttons.Add(new ButtonViewModel { Text = "Oval Stage 2", ImageSource = bitmap_p8p8, Type = "OVAL S2", Command = StartGradingCommand, IsFocused = true }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -186,7 +282,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
DiamondCode = ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string runModel = ConfigurationHelper.ReadConfigValue("RunModel")??"1"; |
|
|
|
|
string runModel = ConfigurationHelper.ReadConfigValue("RunModel") ?? "1"; |
|
|
|
|
|
|
|
|
|
if ("0".Equals(runModel)) |
|
|
|
|
//json模式 |
|
|
|
|
@ -207,7 +303,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if ( res <= -100) |
|
|
|
|
if (res <= -100) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -234,7 +330,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
await SOCClientService.Service.OpenPump(false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if ( res <= -100) |
|
|
|
|
if (res <= -100) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -261,7 +357,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
await SOCClientService.Service.OpenPump(false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if ( res <= -100) |
|
|
|
|
if (res <= -100) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -274,7 +370,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
LoadingDialog loading = new LoadingDialog(DiamondCode); |
|
|
|
|
try |
|
|
|
|
@ -450,7 +546,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
finally { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
**/ |
|
|
|
|
**/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Log] |
|
|
|
|
@ -464,7 +560,7 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
return dataTable.Rows[0][MultilingualHelper.getString("NameType")].ToString()??""; |
|
|
|
|
return dataTable.Rows[0][MultilingualHelper.getString("NameType")].ToString() ?? ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 将 UI 操作调度到主线程并显示错误信息 |
|
|
|
|
@ -489,7 +585,8 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
public async void DoStartGrading(object param) |
|
|
|
|
{ |
|
|
|
|
LoadingDialog loading = new LoadingDialog(DiamondCode); |
|
|
|
|
try { |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (param != null) |
|
|
|
|
{ |
|
|
|
|
AlgorithmResultEntity parameter = new AlgorithmResultEntity(); |
|
|
|
|
@ -514,7 +611,8 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tcs = new TaskCompletionSource<bool>(); |
|
|
|
|
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => { |
|
|
|
|
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => |
|
|
|
|
{ |
|
|
|
|
loading.Closed += (s, e) => tcs.SetResult(true); |
|
|
|
|
loading.ShowDialog(); |
|
|
|
|
} |
|
|
|
|
@ -594,13 +692,13 @@ public class DiamondSelectVM : BaseViewModel |
|
|
|
|
// 生成时间戳,格式为 yyyyMMddHHmmss |
|
|
|
|
string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); |
|
|
|
|
// 组合新的文件夹路径 |
|
|
|
|
string newFolderPath = Path.Combine(imageHistoryPath, string.IsNullOrWhiteSpace(dCode) ? $"image-{timestamp}-{dType}" : $"image-{dCode}-{timestamp}-{dType}" ); |
|
|
|
|
string newFolderPath = Path.Combine(imageHistoryPath, string.IsNullOrWhiteSpace(dCode) ? $"image-{timestamp}-{dType}" : $"image-{dCode}-{timestamp}-{dType}"); |
|
|
|
|
|
|
|
|
|
// 检查 D 盘内存空间 |
|
|
|
|
string strSafeSpace = ConfigurationHelper.ReadConfigValue("SafeSpaceReservation"); |
|
|
|
|
long safeSpace = 10L; |
|
|
|
|
long.TryParse(strSafeSpace, out safeSpace); |
|
|
|
|
DriveInfo dDrive = new DriveInfo(imageHistoryPath.Substring(0,1)); |
|
|
|
|
DriveInfo dDrive = new DriveInfo(imageHistoryPath.Substring(0, 1)); |
|
|
|
|
long requiredSpace = safeSpace * 1024 * 1024 * 1024; |
|
|
|
|
if (dDrive.TotalFreeSpace < requiredSpace) |
|
|
|
|
{ |
|
|
|
|
@ -790,7 +888,8 @@ public class ButtonViewModel : BaseViewModel |
|
|
|
|
|
|
|
|
|
public Brush BackgroundColor |
|
|
|
|
{ |
|
|
|
|
get { |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return _background; |
|
|
|
|
} |
|
|
|
|
set |
|
|
|
|
|