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}" />
+