fix: 20250310

master
Tongg 4 months ago
parent 1a199f8d85
commit 5abd0bb132
  1. 10
      App.config
  2. 4
      MainWindow.xaml.cs
  3. 4
      Model/Entity/ApiEntity/AlgorithmResultEntity.cs
  4. 6
      Model/Entity/ApiEntity/StatusCodes.cs
  5. 4
      Model/Services/SOCClientService.cs
  6. 5
      SparkClient.csproj
  7. 33
      ViewModel/Grading/DiamondSelectVM.cs
  8. 48
      ViewModel/Grading/GradingLoadingVM.cs
  9. 185
      ViewModel/Grading/GradingResultVM.cs
  10. 84
      Views/Dialog/ImageSelect.xaml
  11. 110
      Views/Dialog/ImageSelect.xaml.cs
  12. 3
      Views/Grading/GradingLoading.xaml
  13. 2
      Views/UserControl/ViewportData/Helper/CommonHelper.cs

@ -2,24 +2,20 @@
<configuration> <configuration>
<appSettings> <appSettings>
<!-- 切工仪URL --> <!-- 切工仪URL -->
<add key="BaseUrl" value="http://192.168.2.168:5000/api/SoC"/> <add key="BaseUrl" value="http://192.168.10.111:5000/api/SoC"/>
<!-- <add key="BaseUrl" value="http://192.168.3.100:8080"/> --> <!-- <add key="BaseUrl" value="http://192.168.3.100:8080"/> -->
<!-- SOC下载图片目录 --> <!-- SOC下载图片目录 -->
<add key="ImageFileBasePath" value="D:\diamond_images"/> <add key="ImageFileBasePath" value="D:\diamond_images"/>
<!-- 算法失败时,历史图片保存文件夹路径 --> <!-- 算法失败时,历史图片保存文件夹路径 -->
<add key="ImageHistoryPath" value="D:\ImageHistory"/> <add key="ImageHistoryPath" value="D:\ImageHistory"/>
<!-- 打印机名称 --> <!-- 打印机名称 -->
<add key="PrintName" value="Deli DL-770D"/> <add key="PrintName" value="Deli DL-720C"/>
<!-- 打印纸张内容宽比 -->
<add key="PrintWidth" value="400"/>
<!-- 打印纸张内容高比 -->
<add key="PrintHeight" value="300"/>
<!-- 检测结果默认DS --> <!-- 检测结果默认DS -->
<add key="DSSet" value="NA"/> <add key="DSSet" value="NA"/>
<!-- 检测预估耗时:毫秒 --> <!-- 检测预估耗时:毫秒 -->
<add key="ProgressTime" value="50000"/> <add key="ProgressTime" value="50000"/>
<add key="RunModel" value="999" /> <add key="RunModel" value="0" />
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<add name="" connectionString=""/> <add name="" connectionString=""/>

@ -11,6 +11,7 @@ using HandyControl.Tools;
using log4net; using log4net;
using log4net.Config; using log4net.Config;
using SparkClient.Model.Helper; using SparkClient.Model.Helper;
using SparkClient.Model.Services;
using SparkClient.ViewModel; using SparkClient.ViewModel;
using SparkClient.ViewModel.BaseWindow; using SparkClient.ViewModel.BaseWindow;
using SparkClient.Views.BaseWindow; using SparkClient.Views.BaseWindow;
@ -142,7 +143,7 @@ public partial class MainWindow
} }
private void MainWindow_OnClosing(object? sender, CancelEventArgs e) private async void MainWindow_OnClosing(object? sender, CancelEventArgs e)
{ {
var message = MultilingualHelper.getString("ExitAsk"); var message = MultilingualHelper.getString("ExitAsk");
var title = MultilingualHelper.getString("ExitAskTitle"); var title = MultilingualHelper.getString("ExitAskTitle");
@ -152,6 +153,7 @@ public partial class MainWindow
if (result == MessageBoxResult.OK) if (result == MessageBoxResult.OK)
{ {
await SOCClientService.Service.OpenPump(false);
DataBaseHelper.CloseConnection(); DataBaseHelper.CloseConnection();
// this.Close(); // this.Close();
Environment.Exit(0); Environment.Exit(0);

@ -39,7 +39,9 @@ namespace SparkClient.Model.Entity.ApiEntity
/// 面的类型。 /// 面的类型。
/// </summary> /// </summary>
public int facet_type { get; set; } public int facet_type { get; set; }
/// <summary>
/// 旋转角度
/// </summary>
public double theta { get; set; } public double theta { get; set; }
} }

@ -32,6 +32,12 @@ namespace SparkClient.Model.Common
// 切工仪舱门未关闭 // 切工仪舱门未关闭
public const string OpenOfTheHatch = "S007"; public const string OpenOfTheHatch = "S007";
/// <summary>
/// 输出参数错误或者未定义
/// </summary>
public const string OutputParameterNotProvidedOrIncorrect = "S008";
public const string PreviousTaskIncomplete = "S009";
// 未找到切工仪 // 未找到切工仪
public const string DeviceNotFound = "P001"; public const string DeviceNotFound = "P001";

@ -77,9 +77,9 @@ namespace SparkClient.Model.Services
// 记录日志 // 记录日志
Logger.Info($"Response: Status={statusCode}, Body={responseBody}"); Logger.Info($"Response: Status={statusCode}, Body={responseBody}");
var tempEntity = JsonConvert.DeserializeObject<ResponseStatus>(responseBody); var tempEntity = JsonConvert.DeserializeObject<ResponseStatus>(responseBody);
if ("S007".Equals(tempEntity.Status)) if (StatusCodes.PreviousTaskIncomplete.Equals(tempEntity.Status))
{ {
Logger.Info($"S007 请求重试"); Logger.Info($"S009 请求重试");
await Task.Delay(50); await Task.Delay(50);
return await SendGetRequestAsync(url); return await SendGetRequestAsync(url);
} }

@ -258,6 +258,11 @@
<XamlRuntime>Wpf</XamlRuntime> <XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Views\Dialog\ImageSelect.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -165,15 +165,12 @@ public class DiamondSelectVM : BaseViewModel
WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
return; return;
} }
else if ( res <= -100) if ( res <= -100)
{ {
return; return;
} }
else GradingResult(loadingView.Parameter);
{ loadingView.Dispose();
GradingResult(loadingView.Parameter);
loadingView.Dispose();
}
} }
else if ("1".Equals(runModel)) else if ("1".Equals(runModel))
{ {
@ -191,18 +188,15 @@ public class DiamondSelectVM : BaseViewModel
//返回 //返回
loadingView.Dispose(); loadingView.Dispose();
WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
; await SOCClientService.Service.OpenPump(false);
return; return;
} }
else if ( res <= -100) if ( res <= -100)
{ {
return; return;
} }
else GradingResult(loadingView.Parameter);
{ loadingView.Dispose();
GradingResult(loadingView.Parameter);
loadingView.Dispose();
}
} }
else else
{ {
@ -221,18 +215,17 @@ public class DiamondSelectVM : BaseViewModel
//返回 //返回
loadingView.Dispose(); loadingView.Dispose();
WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
; await SOCClientService.Service.OpenPump(false);
return; return;
} }
else if ( res <= -100) if ( res <= -100)
{ {
return; return;
} }
else
{ GradingResult(loadingView.Parameter);
GradingResult(loadingView.Parameter); loadingView.Dispose();
loadingView.Dispose();
}
} }

@ -191,14 +191,28 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
LoadImages(processImage.Result.Images); LoadImages(processImage.Result.Images);
} }
string strImageModeImagePath = string.Empty;
if (type == 1) if (type == 1)
{ {
List<string> mnFiles = new List<string>(); ImageSelect jsonImport = new ImageSelect();
for (int i = 0; i < 100; i++) bool? a = jsonImport.ShowDialog();
if (a ?? false)
{ {
mnFiles.Add($"{i}.bmp"); strImageModeImagePath = jsonImport.FilePath.Text;
string name = jsonImport.FileName.Text;
List<string> mnFiles = new List<string>();
for (int i = 0; i < 100; i++)
{
mnFiles.Add(name.Replace("%d", i.ToString()));
}
LoadImages(mnFiles);
} }
LoadImages(mnFiles); else
{
return -1;
}
} }
ImageIsEnable = true; ImageIsEnable = true;
@ -216,11 +230,18 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
var _algorithmConfigVM = new AlgorithmConfigVM(); var _algorithmConfigVM = new AlgorithmConfigVM();
_algorithmConfigVM.InitAlgorithmData(null); _algorithmConfigVM.InitAlgorithmData(null);
string algo_config = _algorithmConfigVM.AlgorithmConfigJson; string algo_config = _algorithmConfigVM.AlgorithmConfigJson;
string imageFileBasePath = string.Empty;
//图片根目录 //图片根目录
string? image_file_base_path = ConfigurationManager.AppSettings["ImageFileBasePath"]; if (type == 1)
if (string.IsNullOrEmpty(image_file_base_path)) {
imageFileBasePath = strImageModeImagePath;
}
else
{
imageFileBasePath = ConfigurationManager.AppSettings["ImageFileBasePath"];
}
if (string.IsNullOrEmpty(imageFileBasePath))
{ {
throw new InvalidOperationException("ImageFileBasePath is not configured in AppSettings."); throw new InvalidOperationException("ImageFileBasePath is not configured in AppSettings.");
} }
@ -235,7 +256,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
JObject jsonData = new JObject( JObject jsonData = new JObject(
new JProperty("shape", _diamnondType.Split(" ")[0]), new JProperty("shape", _diamnondType.Split(" ")[0]),
new JProperty("shape_mode", _diamnondType.Split(" ")[1]), new JProperty("shape_mode", _diamnondType.Split(" ")[1]),
new JProperty("image_file_base_path", image_file_base_path), new JProperty("image_file_base_path", imageFileBasePath),
new JProperty("image_files", ImagePaths), new JProperty("image_files", ImagePaths),
new JProperty("half_circle", half_circle), new JProperty("half_circle", half_circle),
new JProperty("algorithm_log_path", algorithm_log_path), new JProperty("algorithm_log_path", algorithm_log_path),
@ -294,6 +315,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
Progress = (100.00); Progress = (100.00);
string strParam = JsonConvert.SerializeObject(detectTask.Result); string strParam = JsonConvert.SerializeObject(detectTask.Result);
//Logger.Info("序列化字符串:" + strParam);
AlgorithmResultEntity parameter = JsonConvert.DeserializeObject<AlgorithmResultEntity>(strParam); AlgorithmResultEntity parameter = JsonConvert.DeserializeObject<AlgorithmResultEntity>(strParam);
if (parameter == null && _isCancel == false) if (parameter == null && _isCancel == false)
{ {
@ -328,6 +350,12 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
Parameter = parameter; Parameter = parameter;
if (_isCancel == true) return -100; if (_isCancel == true) return -100;
if (parameter.status == StatusCodes.Recheck)
{
new MessageBox().Show(MultilingualHelper.getString("Recheck"));
}
return 0; return 0;
} }
@ -366,7 +394,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
{ {
current = Math.Min(current + 1, 100); current = Math.Min(current + 1, 100);
UpdateProgress(current); UpdateProgress(current);
await Task.Delay(stepTime); await Task.Delay(stepTime/2);
} }
} }
private void UpdateProgress(int value) private void UpdateProgress(int value)

@ -1977,17 +1977,17 @@ public class GradingResultVM : BaseViewModel
[Log] [Log]
private void ExecuteThermalPrint(object parameter) private void ExecuteThermalPrint(object parameter)
{ {
MessageBox messageBox = new MessageBox();
MessageBoxResult boxResult = messageBox.ShowAsk(MultilingualHelper.getString("YesOrNo"));
if (boxResult != MessageBoxResult.OK)
{
return;
}
string tempFilePath = string.Empty;
Microsoft.Office.Interop.Excel.Application excelApp = null; Microsoft.Office.Interop.Excel.Application excelApp = null;
string tempFilePath = string.Empty;
try try
{ {
MessageBox messageBox = new MessageBox();
MessageBoxResult boxResult = messageBox.ShowAsk(MultilingualHelper.getString("YesOrNo"));
if (boxResult != MessageBoxResult.OK)
{
return;
}
// 步骤2:加载模板并填充数据 // 步骤2:加载模板并填充数据
tempFilePath = GenerateTempExcelFile(); tempFilePath = GenerateTempExcelFile();
@ -1997,13 +1997,14 @@ public class GradingResultVM : BaseViewModel
excelApp.DisplayAlerts = false; // 禁用警告提示 excelApp.DisplayAlerts = false; // 禁用警告提示
Microsoft.Office.Interop.Excel.Workbook workbook = excelApp.Workbooks.Open(tempFilePath); Microsoft.Office.Interop.Excel.Workbook workbook = excelApp.Workbooks.Open(tempFilePath);
string printName = ConfigurationHelper.ReadConfigValue("PrintName");
string? targetPrinter = System.Drawing.Printing.PrinterSettings.InstalledPrinters string? targetPrinter = System.Drawing.Printing.PrinterSettings.InstalledPrinters
.Cast<string>() .Cast<string>()
.FirstOrDefault(p => p.Contains(ConfigurationHelper.ReadConfigValue("PrintName"))); .FirstOrDefault(p => p.Contains(printName));
if (targetPrinter == null) if (targetPrinter == null)
{ {
throw new Exception($"未找到打印机{targetPrinter}"); throw new Exception($"未找到打印机{printName}");
} }
// 打印配置 // 打印配置
@ -2335,86 +2336,94 @@ public class GradingResultVM : BaseViewModel
private string GenerateTempExcelFile() private string GenerateTempExcelFile()
{ {
string TemplatePath = @"Resource\ResultReport.xlsx"; try
using (FileStream templateStream = new FileStream(TemplatePath, FileMode.Open, FileAccess.Read))
{ {
IWorkbook workbook = new XSSFWorkbook(templateStream); string TemplatePath = @"Resource\ResultReport.xlsx";
ISheet sheet = workbook.GetSheetAt(0); using (FileStream templateStream = new FileStream(TemplatePath, FileMode.Open, FileAccess.Read))
//Row 1
SetCellValue(sheet, "A1", $"{MultilingualHelper.getString("Organization")}:{Standard}");
SetCellValue(sheet, "B1", $"{MultilingualHelper.getString("DiamondResultShape")}:{Shape}");
SetCellValue(sheet, "C1", $"{MultilingualHelper.getString("Code")}:{DiamondCode}");
SetCellValue(sheet, "E1", $"{MultilingualHelper.getString("Wight")}:{Wight}ct.");
//Row 2
SetCellValue(sheet, "A2", $"{MultilingualHelper.getString("Parameters")}");
SetCellValue(sheet, "B2", $"{MultilingualHelper.getString("DiamondResultGridAvgValue")}");
SetCellValue(sheet, "C2", $"{MultilingualHelper.getString("Interval")}(Min~Max)");
SetCellValue(sheet, "D2", $"{MultilingualHelper.getString("DiamondResultGridCutLevel")}");
SetCellValue(sheet, "E2", $"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}");
//Row 3
var row3 = getSelectData("DIAMETER");
SetCellValue(sheet, "A3", $"{GetName("DIAMETER")}(mm)");
SetCellValue(sheet, "B3", $"{row3.Avg}");
SetCellValue(sheet, "C3", $"({row3.Min}~{row3.Max})");
SetCellValue(sheet, "D3", "--");
SetCellValue(sheet, "E3", $"{row3.SymLevel}");
//Row 4
var row4 = getSelectData("TOTAL_DEPTH");
SetCellValue(sheet, "A4", $"{GetName("TOTAL_DEPTH")}(%)");
SetCellValue(sheet, "B4", $"{row4.Avg}");
SetCellValue(sheet, "C4", "--");
SetCellValue(sheet, "D4", $"{row4.CutLevel}");
SetCellValue(sheet, "E4", "--");
// Row 5
var row5 = getSelectData("TABLE");
SetCellValue(sheet, "A5", $"{GetName("TABLE")}(%)");
SetCellValue(sheet, "B5", $"{row5.Avg}");
SetCellValue(sheet, "C5", $"({row5.Min}~{row5.Max})");
SetCellValue(sheet, "D5", $"{row5.CutLevel}");
SetCellValue(sheet, "E5", "--");
var row6 = getSelectData("CROWN_ANGLE");
SetCellValue(sheet, "A6", $"{GetName("CROWN_ANGLE")}(°)");
SetCellValue(sheet, "B6", $"{row6.Avg}");
SetCellValue(sheet, "C6", $"({row6.Min}~{row6.Max})");
SetCellValue(sheet, "D6", $"{row6.CutLevel}");
SetCellValue(sheet, "E6", $"{row6.SymLevel}");
var row7 = getSelectData("CROWN_HEIGHT");
SetCellValue(sheet, "A7", $"{GetName("CROWN_HEIGHT")}(%)");
SetCellValue(sheet, "B7", $"{row7.Avg}");
SetCellValue(sheet, "C7", $"({row7.Min}~{row7.Max})");
SetCellValue(sheet, "D7", $"{row7.CutLevel}");
SetCellValue(sheet, "E7", $"{row7.SymLevel}");
var row8 = getSelectData("GIRDLE");
SetCellValue(sheet, "A8", $"{GetName("GIRDLE")}(%)");
SetCellValue(sheet, "B8", $"{row8.Avg}");
SetCellValue(sheet, "C8", $"({row8.Min}~{row8.Max})");
SetCellValue(sheet, "D8", $"{row8.CutLevel}");
SetCellValue(sheet, "E8", $"{row8.SymLevel}");
var row9 = getSelectData("PAV_DEPTH");
SetCellValue(sheet, "A9", $"{GetName("PAV_DEPTH")}(%)");
SetCellValue(sheet, "B9", $"{row9.Avg}");
SetCellValue(sheet, "C9", $"({row9.Min}~{row9.Max})");
SetCellValue(sheet, "D9", $"{row9.CutLevel}");
SetCellValue(sheet, "E9", $"{row9.SymLevel}");
//row 10
//Row 11
SetCellValue(sheet, "A11", $"{MultilingualHelper.getString("CuttingGrade")}");
SetCellValue(sheet, "B11", $"{CutLevelTotal}");
//Row 12
SetCellValue(sheet, "A12", $"{MultilingualHelper.getString("SymmetryLevel")}");
SetCellValue(sheet, "B12", $"{SymLevelTotal}");
SetCellValue(sheet, "C12", $"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}");
// 生成临时文件路径
string tempFile = Path.Combine(
Path.GetTempPath(),
$"DiamondReport_{DateTime.Now:yyyyMMddHHmmss}.xlsx");
using (FileStream fs = new FileStream(tempFile, FileMode.Create))
{ {
workbook.Write(fs); IWorkbook workbook = new XSSFWorkbook(templateStream);
ISheet sheet = workbook.GetSheetAt(0);
//Row 1
SetCellValue(sheet, "A1", $"{MultilingualHelper.getString("Organization")}:{Standard}");
SetCellValue(sheet, "B1", $"{MultilingualHelper.getString("DiamondResultShape")}:{Shape}");
SetCellValue(sheet, "C1", $"{MultilingualHelper.getString("Code")}:{DiamondCode}");
SetCellValue(sheet, "E1", $"{MultilingualHelper.getString("Wight")}:{Wight}ct.");
//Row 2
SetCellValue(sheet, "A2", $"{MultilingualHelper.getString("Parameters")}");
SetCellValue(sheet, "B2", $"{MultilingualHelper.getString("DiamondResultGridAvgValue")}");
SetCellValue(sheet, "C2", $"{MultilingualHelper.getString("Interval")}(Min~Max)");
SetCellValue(sheet, "D2", $"{MultilingualHelper.getString("DiamondResultGridCutLevel")}");
SetCellValue(sheet, "E2", $"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}");
//Row 3
var row3 = getSelectData("DIAMETER");
SetCellValue(sheet, "A3", $"{GetName("DIAMETER")}(mm)");
SetCellValue(sheet, "B3", $"{row3.Avg}");
SetCellValue(sheet, "C3", $"({row3.Min}~{row3.Max})");
SetCellValue(sheet, "D3", "--");
SetCellValue(sheet, "E3", $"{row3.SymLevel}");
//Row 4
var row4 = getSelectData("TOTAL_DEPTH");
SetCellValue(sheet, "A4", $"{GetName("TOTAL_DEPTH")}(%)");
SetCellValue(sheet, "B4", $"{row4.Avg}");
SetCellValue(sheet, "C4", "--");
SetCellValue(sheet, "D4", $"{row4.CutLevel}");
SetCellValue(sheet, "E4", "--");
// Row 5
var row5 = getSelectData("TABLE");
SetCellValue(sheet, "A5", $"{GetName("TABLE")}(%)");
SetCellValue(sheet, "B5", $"{row5.Avg}");
SetCellValue(sheet, "C5", $"({row5.Min}~{row5.Max})");
SetCellValue(sheet, "D5", $"{row5.CutLevel}");
SetCellValue(sheet, "E5", "--");
var row6 = getSelectData("CROWN_ANGLE");
SetCellValue(sheet, "A6", $"{GetName("CROWN_ANGLE")}(°)");
SetCellValue(sheet, "B6", $"{row6.Avg}");
SetCellValue(sheet, "C6", $"({row6.Min}~{row6.Max})");
SetCellValue(sheet, "D6", $"{row6.CutLevel}");
SetCellValue(sheet, "E6", $"{row6.SymLevel}");
var row7 = getSelectData("CROWN_HEIGHT");
SetCellValue(sheet, "A7", $"{GetName("CROWN_HEIGHT")}(%)");
SetCellValue(sheet, "B7", $"{row7.Avg}");
SetCellValue(sheet, "C7", $"({row7.Min}~{row7.Max})");
SetCellValue(sheet, "D7", $"{row7.CutLevel}");
SetCellValue(sheet, "E7", $"{row7.SymLevel}");
var row8 = getSelectData("GIRDLE");
SetCellValue(sheet, "A8", $"{GetName("GIRDLE")}(%)");
SetCellValue(sheet, "B8", $"{row8.Avg}");
SetCellValue(sheet, "C8", $"({row8.Min}~{row8.Max})");
SetCellValue(sheet, "D8", $"{row8.CutLevel}");
SetCellValue(sheet, "E8", $"{row8.SymLevel}");
var row9 = getSelectData("PAV_DEPTH");
SetCellValue(sheet, "A9", $"{GetName("PAV_DEPTH")}(%)");
SetCellValue(sheet, "B9", $"{row9.Avg}");
SetCellValue(sheet, "C9", $"({row9.Min}~{row9.Max})");
SetCellValue(sheet, "D9", $"{row9.CutLevel}");
SetCellValue(sheet, "E9", $"{row9.SymLevel}");
//row 10
//Row 11
SetCellValue(sheet, "A11", $"{MultilingualHelper.getString("CuttingGrade")}");
SetCellValue(sheet, "B11", $"{CutLevelTotal}");
//Row 12
SetCellValue(sheet, "A12", $"{MultilingualHelper.getString("SymmetryLevel")}");
SetCellValue(sheet, "B12", $"{SymLevelTotal}");
SetCellValue(sheet, "C12", $"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}");
// 生成临时文件路径
string tempFile = Path.Combine(
Path.GetTempPath(),
$"DiamondReport_{DateTime.Now:yyyyMMddHHmmss}.xlsx");
using (FileStream fs = new FileStream(tempFile, FileMode.Create))
{
workbook.Write(fs);
}
return tempFile;
} }
return tempFile; }
catch (Exception e)
{
throw e;
} }
} }

@ -0,0 +1,84 @@
<Window x:Class="SparkClient.Views.Dialog.ImageSelect"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SparkClient.Views.Dialog"
mc:Ignorable="d"
Title="JsonImport" Height="450" Width="800"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Border CornerRadius="10" Background="White" x:Name="Border" BorderBrush="Blue" BorderThickness="2">
<Grid ClipToBounds="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 模拟顶部标题栏 -->
<Grid Grid.Row="0" Background="#795C2A" Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 关闭按钮 -->
<Border Grid.Column="2"
Width="40" Height="30"
Margin=" 0 0 10 0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Background="Transparent"
MouseEnter="Border_Close_MouseEnter"
MouseLeave="Border_MouseLeave">
<Button Background="Transparent" BorderBrush="Transparent" Click="Close_Click">
<Viewbox Stretch="Uniform">
<Path Data="{StaticResource CloseGeometry}"
Fill="Azure"
Stroke="Azure"
StrokeThickness="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="20 0 0 0"
Width="30" />
</Viewbox>
</Button>
</Border>
</Grid>
<StackPanel Grid.Row="1" VerticalAlignment="Center" >
<Grid Height="80" Margin="0 10 0 10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="9*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" HorizontalAlignment="right" Content="图片路径" Background="Transparent"
BorderBrush="Transparent"
FontSize="16" FontFamily="AlibabaPuHui-regular" />
<TextBox Grid.Row="0" TextWrapping="Wrap" x:Name ="FilePath" Grid.Column="2" IsReadOnly="True"/>
<Button Grid.Row="0" Grid.Column="3" Content="浏览" HorizontalAlignment="Left" Click="open_Click"/>
<Label Grid.Row="2" Grid.Column="1" HorizontalAlignment="right" Content="文件名格式" Background="Transparent"
BorderBrush="Transparent"
FontSize="16" FontFamily="AlibabaPuHui-regular" />
<TextBox Grid.Row="2" Grid.ColumnSpan="1" TextWrapping="Wrap" x:Name ="FileName" Grid.Column="2" Text="%d.bmp"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="2" Content="{DynamicResource ok}" HorizontalAlignment="Center" Click="Ok_Click" />
<Button Grid.Column="3" Content="{DynamicResource Cancel}" HorizontalAlignment="Center" Click="Close_Click" />
</Grid>
</StackPanel>
</Grid>
</Border>
</Window>

@ -0,0 +1,110 @@
using HandyControl.Controls;
using log4net;
using SparkClient.ViewModel;
using SparkClient.ViewModel.Dialog;
using SparkClient.Views.Grading;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Win32;
namespace SparkClient.Views.Dialog
{
/// <summary>
/// JsonImport.xaml 的交互逻辑
/// </summary>
public partial class ImageSelect
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(ImageSelect));
public BaseViewModel ViewModel = null;
public ImageSelect()
{
InitializeComponent();
WindowStartupLocation = WindowStartupLocation.CenterScreen;
// 动态设置圆角裁剪
this.Loaded += (s, e) => ApplyCornerRadiusClip();
this.SizeChanged += (s, e) => ApplyCornerRadiusClip(); // 保证在大小改变时也裁剪
this.Width = 562;
this.Height = 222;
this.ViewModel = new StartDialogVM();
this.DataContext = this.ViewModel;
}
#region 重写窗体操作按钮
private void Border_Close_MouseEnter(object sender, MouseEventArgs e)
{
// 鼠标进入时更改背景色
if (sender is Border border)
{
border.Background = new SolidColorBrush(Color.FromArgb(50, 255, 0, 0));
}
}
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
// 鼠标离开时恢复背景色
if (sender is Border border)
{
border.Background = new SolidColorBrush(Colors.Transparent);
}
}
private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
try
{
this.DragMove();
}
catch (InvalidOperationException ex)
{
}
}
}
#endregion
private void Close_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
this.Close();
}
private void open_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFolderDialog
{
Title = "请选择部署位置"
};
bool? result = dialog.ShowDialog();
if (result == true)
{
FilePath.Text = dialog.FolderName;
}
}
private void Ok_Click(object sender, RoutedEventArgs e)
{
if (FilePath.Text.Trim().Length > 0) {
DialogResult = true;
this.Close();
}
else
{
Growl.Error("请选择图片路径");
}
}
private void ApplyCornerRadiusClip()
{
// 使用矩形几何生成圆角裁剪
this.Border.Clip = new RectangleGeometry
{
Rect = new Rect(0, 0, this.Border.ActualWidth, this.Border.ActualHeight),
RadiusX = this.Border.CornerRadius.TopLeft, // 使用 Border 的 CornerRadius
RadiusY = this.Border.CornerRadius.TopLeft
};
}
}
}

@ -337,7 +337,8 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="{StaticResource GradingLoading}" BorderBrush="Transparent" BorderThickness="0" <TextBox Grid.Row="0" Text="{StaticResource GradingLoading}" BorderBrush="Transparent" BorderThickness="0"
TextAlignment="Center" FontSize="30" IsEnabled="False"/> TextAlignment="Center" FontSize="30" IsEnabled="False"/>
<ProgressBar Grid.Row="1" Margin="50 0" Height="30" Value="{Binding Progress}" FontSize="24"/> <ProgressBar Grid.Row="1" Margin="50 0" Height="30" Value="{Binding Progress}" FontSize="24" Visibility="Hidden"/>
<hc:LoadingLine Grid.Row="1" Margin="50 0" Foreground="#40B1FF" Style="{StaticResource LoadingLineLarge}"/>
</Grid> </Grid>

@ -46,7 +46,7 @@ public class CommonHelper
// 提取 PlaneCode 和 PlaneType // 提取 PlaneCode 和 PlaneType
string planeCode = jsonObject.facet_id ?? (string)jsonObject.facet_id; string planeCode = jsonObject.facet_id ?? (string)jsonObject.facet_id;
PlaneType planeType = (PlaneType)(int)jsonObject.facet_type; PlaneType planeType = (PlaneType)(int)jsonObject.facet_type;
Double theta = jsonObject.theta ?? (Double)jsonObject.theta; double theta = jsonObject.theta ?? (double)jsonObject.theta;
// 生成 TriangleCode // 生成 TriangleCode
var triangleCode = GenerateTriangleCode(point1, point2, point3); var triangleCode = GenerateTriangleCode(point1, point2, point3);

Loading…
Cancel
Save