fix:检测结果画面调整

master
sunhonglei 5 months ago
parent 1e7d1dc952
commit aaca54a311
  1. 3
      Language/zh_CN.xaml
  2. 2
      ViewModel/Grading/DiamondSelectVM.cs
  3. 124
      ViewModel/Grading/GradingResultVM.cs
  4. 4
      Views/Grading/GradingResult.xaml

@ -197,5 +197,6 @@
<sys:String x:Key="ApplicationError">应用程序出现错误:</sys:String>
<sys:String x:Key="CUDANoInstall">CUDA未安装,程序执行中可能会出错</sys:String>
<sys:String x:Key="MSVCRuntimeNoInstall">MSVC Runtime未安装,程序执行中可能会出错</sys:String>
<sys:String x:Key="FilePathNotExists">文件路径不存在</sys:String>
</ResourceDictionary>

@ -351,7 +351,7 @@ public class DiamondSelectVM : BaseViewModel
// parameter = DoAlgorithm();
//parameter = DoSoc();
parameter.Standard = "IGI 2024";
parameter.Standard = getStandardName();
string value = param.ToString() ?? "";
if (value != null && value.Split(" ").Length == 3)
{

@ -21,11 +21,14 @@ using SparkClient.Views.UserControl.ViewportData.Entity;
using SparkClient.ViewModel.Configuration.SettingsPages;
using SparkClient.Views.UserControl.ViewportData.Helper;
using System.Diagnostics.Metrics;
using log4net;
using SparkClient.ViewModel.Configuration;
namespace SparkClient.ViewModel.Grading;
public class GradingResultVM : BaseViewModel
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(GradingResultVM));
private string DiamondCode { get; set; }
private List<DataInfo> _dtResults;
// ViewportData
@ -42,6 +45,7 @@ public class GradingResultVM : BaseViewModel
private string _symLevelTotal;
private string _ds;
private RowDetail _selRowDataDetail;
private bool _isEnabled;
public ICommand SaveFileCommand { get; }
public ICommand SaveAsCommand { get; }
public List<DataInfo> DtResults { get { return _dtResults; } set { _dtResults = value; OnPropertyChanged(nameof(DtResults)); } }
@ -58,6 +62,7 @@ public class GradingResultVM : BaseViewModel
public DataTable DSList { get { return _dsList; } set { _dsList = value; OnPropertyChanged(nameof(DSList)); } }
public string DS { get { return _ds; } set { _ds = value; OnPropertyChanged(nameof(DS)); } }
public DataTable GradeList { get { return _gradeList; } set { _gradeList = value; OnPropertyChanged(nameof(GradeList)); } }
public bool IsEnabled { get{ return _isEnabled; } set { _isEnabled = value; OnPropertyChanged(nameof(IsEnabled)); } }
private readonly static string digitsFormat = "f1";
@ -83,6 +88,14 @@ public class GradingResultVM : BaseViewModel
InitView(algorithmResult);
machine = algorithmResult.DeviceId;
username = Settings.SelectValueByName("PERMISSIONS");
if (ruleId.StartsWith("IGI"))
{
IsEnabled = true;
}
else
{
IsEnabled = false;
}
}
DS = "NA";
AutoSave();
@ -637,6 +650,11 @@ public class GradingResultVM : BaseViewModel
return;
}
}
if (!File.Exists(getFilePath()))
{
new MessageBox().Show(MultilingualHelper.getString("FilePathNotExists"));
return;
}
string fullPath = Path.Combine(getFilePath(), this.DiamondCode);
ExportFile(fullPath);
SaveTestResult(SaveStatus.Save);
@ -694,6 +712,11 @@ public class GradingResultVM : BaseViewModel
{
// 获取用户选择的文件路径
string filePath = saveFileDialog.FileName;
if (!saveFileDialog.CheckPathExists)
{
new MessageBox().Show(MultilingualHelper.getString("FilePathNotExists"));
return;
}
//ExportFile(filePath);
TxtFile(filePath);
}
@ -702,61 +725,68 @@ public class GradingResultVM : BaseViewModel
}
private async void ExportFile(string filePath)
{
ExportDialog exportDialog = new ExportDialog();
var tcs = new TaskCompletionSource<bool>();
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => {
exportDialog.Closed += (s, e) => tcs.SetResult(true);
exportDialog.ShowDialog();
}
));
await Task.Run(async () =>
{
int count = saveFileCount();
int index = 1;
if (FileSaveEnabled("Txt")) {
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"Txt File({index++}/{count})");
});
TxtFile(filePath);
try {
ExportDialog exportDialog = new ExportDialog();
var tcs = new TaskCompletionSource<bool>();
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => {
exportDialog.Closed += (s, e) => tcs.SetResult(true);
exportDialog.ShowDialog();
}
if (FileSaveEnabled("Excel"))
));
await Task.Run(async () =>
{
exportDialog.Dispatcher.Invoke(() =>
int count = saveFileCount();
int index = 1;
if (FileSaveEnabled("Txt")) {
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"Txt File({index++}/{count})");
});
TxtFile(filePath);
}
if (FileSaveEnabled("Excel"))
{
exportDialog.setValue($"Excel File({index++}/{count})");
});
ExcelFile(filePath);
}
if (FileSaveEnabled("Stl"))
{
exportDialog.Dispatcher.Invoke(() =>
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"Excel File({index++}/{count})");
});
ExcelFile(filePath);
}
if (FileSaveEnabled("Stl"))
{
exportDialog.setValue($"STL File({index++}/{count})");
});
await Task.Delay(100);
STLFile(filePath);
}
if (FileSaveEnabled("Dat"))
{
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"STL File({index++}/{count})");
});
await Task.Delay(100);
STLFile(filePath);
}
if (FileSaveEnabled("Dat"))
{
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"DAT File({index++}/{count})");
});
await DatFile(filePath);
}
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue($"DAT File({index++}/{count})");
exportDialog.setValue("Success");
});
await DatFile(filePath);
}
exportDialog.Dispatcher.Invoke(() =>
{
exportDialog.setValue("Success");
//DataConver(filePath);
// exportDialog.Dispatcher.Invoke(() =>
// {
// exportDialog.setValue("Success");
// });
});
//DataConver(filePath);
// exportDialog.Dispatcher.Invoke(() =>
// {
// exportDialog.setValue("Success");
// });
});
await Task.Delay(500);
exportDialog.Close();
await Task.Delay(500);
exportDialog.Close();
}
catch(Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
Logger.Error($"全局异常捕获:{ex.Message}", ex);
}
}
private bool FileSaveEnabled(string Key)
{

@ -84,7 +84,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 保存按钮 -->
<Button Grid.Column="0" Padding="0" Margin="10 0 0 0" Height="50" BorderThickness="0"
<Button Grid.Column="0" Padding="0" Margin="10 0 0 0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveFileCommand}">
<Border
HorizontalAlignment="Center"
@ -104,7 +104,7 @@
</Border>
</Button>
<!-- 导出按钮 -->
<Button Grid.Column="1" Padding="0" Margin="10 0" Height="50" BorderThickness="0"
<Button Grid.Column="1" Padding="0" Margin="10 0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveAsCommand}">
<Border
HorizontalAlignment="Center"

Loading…
Cancel
Save