feat: ROU成型参数替换功能 — 支持 .rou/.rou1/.rou2/.roux 文件从参数 txt 自动补充 S/F/R/Z/H
This commit is contained in:
66
ParameterFileSelectionWindow.xaml.cs
Normal file
66
ParameterFileSelectionWindow.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DrillTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数文件选择窗口,列出指定目录下所有 .txt 文件供用户选择。
|
||||
/// </summary>
|
||||
public partial class ParameterFileSelectionWindow : Window
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户选中的文件完整路径;若取消则为 null。
|
||||
/// </summary>
|
||||
public string? SelectedFilePath { get; private set; }
|
||||
|
||||
public ParameterFileSelectionWindow(string paramDirectory)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Directory.Exists(paramDirectory))
|
||||
{
|
||||
var files = Directory.GetFiles(paramDirectory, "*.txt")
|
||||
.Select(f => new FileInfo(f))
|
||||
.OrderBy(f => f.Name)
|
||||
.ToList();
|
||||
|
||||
FileListBox.ItemsSource = files;
|
||||
}
|
||||
|
||||
OkButton.IsEnabled = false;
|
||||
FileListBox.SelectionChanged += (_, _) =>
|
||||
{
|
||||
OkButton.IsEnabled = FileListBox.SelectedItem != null;
|
||||
};
|
||||
|
||||
// 双击直接确认
|
||||
FileListBox.MouseDoubleClick += (_, _) =>
|
||||
{
|
||||
if (FileListBox.SelectedItem is FileInfo file)
|
||||
{
|
||||
SelectedFilePath = file.FullName;
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void OkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (FileListBox.SelectedItem is FileInfo file)
|
||||
{
|
||||
SelectedFilePath = file.FullName;
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user