Refactor drill tape reading and reorder logic

This commit is contained in:
2026-05-16 10:23:55 +08:00
parent 0c14c16a21
commit 03d9b8baa2
7 changed files with 262 additions and 238 deletions

View File

@@ -1,6 +1,4 @@
using System;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@@ -70,22 +68,7 @@ namespace DrillTools
// 异步加载文件以避免阻塞UI
await System.Threading.Tasks.Task.Run(() =>
{
// 使用与现有代码相同的方式读取文件
var process = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c type \"{filePath}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
string drillTapeContent = process.StandardOutput.ReadToEnd();
process.WaitForExit();
string drillTapeContent = CommandTypeFileReader.ReadAllText(filePath);
// 在UI线程中更新界面
this.Dispatcher.Invoke(() =>
@@ -160,22 +143,7 @@ namespace DrillTools
// 保存原始文件路径
ViewModel.OriginalFilePath = openFileDialog.FileName;
// 使用 cmd 命令读取加密钻带文件
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c type \"{openFileDialog.FileName}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
string drillTapeContent = process.StandardOutput.ReadToEnd();
process.WaitForExit();
string drillTapeContent = CommandTypeFileReader.ReadAllText(openFileDialog.FileName);
ViewModel.LoadToolsFromDrillTape(drillTapeContent);
}
@@ -342,21 +310,7 @@ namespace DrillTools
// 保存原始文件路径
ViewModel.OriginalFilePath = files[0];
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c type \"{files[0]}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
string drillTapeContent = process.StandardOutput.ReadToEnd();
process.WaitForExit();
string drillTapeContent = CommandTypeFileReader.ReadAllText(files[0]);
ViewModel.LoadToolsFromDrillTape(drillTapeContent);
}
@@ -369,4 +323,4 @@ namespace DrillTools
base.OnDrop(e);
}
}
}
}