From 25a7458db3551ef535e9c458d301a3e2b2182b19 Mon Sep 17 00:00:00 2001
From: "Mr.Xia" <1424473282@qq.com>
Date: Thu, 21 May 2026 13:16:39 +0800
Subject: [PATCH] Add startup PP drill tape generation
---
App.xaml.cs | 54 ++++++++++++++++-
MainWindow.xaml | 6 ++
MainWindow.xaml.cs | 20 ++++++
MainWindowViewModel.cs | 108 +++++++++++++++++++++++++++++++++
StartupSelectionWindow.xaml | 5 +-
StartupSelectionWindow.xaml.cs | 12 +++-
6 files changed, 200 insertions(+), 5 deletions(-)
diff --git a/App.xaml.cs b/App.xaml.cs
index bf033df..03c5db7 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -35,7 +35,8 @@ namespace DrillTools
ShutdownMode = ShutdownMode.OnExplicitShutdown;
bool canClearParameters = CanClearDrillTapeParameters(filePath);
- var selectionWindow = new StartupSelectionWindow(filePath, canClearParameters);
+ bool canGeneratePpDrillTape = CanGeneratePpDrillTape(filePath);
+ var selectionWindow = new StartupSelectionWindow(filePath, canClearParameters, canGeneratePpDrillTape);
selectionWindow.ShowDialog();
switch (selectionWindow.SelectedAction)
@@ -52,6 +53,10 @@ namespace DrillTools
PerformParameterCleanup(filePath);
Shutdown();
break;
+ case StartupAction.GeneratePpDrillTape:
+ PerformPpDrillTapeGeneration(filePath);
+ Shutdown();
+ break;
default:
Shutdown();
break;
@@ -115,6 +120,53 @@ namespace DrillTools
}
}
+ private static bool CanGeneratePpDrillTape(string filePath)
+ {
+ try
+ {
+ var viewModel = new MainWindowViewModel
+ {
+ IsStartupDrillTapeFile = true,
+ OriginalFilePath = filePath
+ };
+
+ string content = CommandTypeFileReader.ReadAllText(filePath);
+ viewModel.LoadToolsFromDrillTape(content);
+ return viewModel.CanGeneratePpDrillTape;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ private static void PerformPpDrillTapeGeneration(string filePath)
+ {
+ try
+ {
+ var viewModel = new MainWindowViewModel
+ {
+ IsStartupDrillTapeFile = true,
+ OriginalFilePath = filePath
+ };
+
+ string content = CommandTypeFileReader.ReadAllText(filePath);
+ viewModel.LoadToolsFromDrillTape(content);
+ string outputFilePath = viewModel.GeneratePpDrillTape();
+
+ System.Windows.MessageBox.Show(
+ $"PP钻带已生成:\n{outputFilePath}",
+ "生成PP钻带完成",
+ MessageBoxButton.OK,
+ MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ System.Windows.MessageBox.Show($"生成PP钻带失败:\n{ex.Message}",
+ "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
private static void PerformParameterCleanup(string filePath)
{
try
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 48ec38a..5ab5017 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -64,6 +64,12 @@
Click="ApplyOrderButton_Click"
Content="应用并保存"
IsEnabled="{Binding HasOriginalFile}" />
+