Refactor drill tape reading and reorder logic
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user