Add startup PP drill tape generation
This commit is contained in:
54
App.xaml.cs
54
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
|
||||
|
||||
Reference in New Issue
Block a user