Add startup PP drill tape generation

This commit is contained in:
2026-05-21 13:16:39 +08:00
parent 951486202e
commit 25a7458db3
6 changed files with 200 additions and 5 deletions

View File

@@ -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