Skip to content

Commit 440afac

Browse files
committed
fix: 修复清除文件按钮无效
1 parent a7e5b1a commit 440afac

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

MainWindow.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
<Button Grid.Column="4"
266266
Style="{StaticResource MaterialDesignIconButton}"
267267
ToolTip="清除文件"
268+
Command="{Binding ClearPrimaryFileCommand}"
268269
Visibility="{Binding PrimaryFile.IsLoaded,
269270
Converter={StaticResource BooleanToVisibilityConverter}}">
270271
<materialDesign:PackIcon Kind="Close"
@@ -369,6 +370,7 @@
369370
<!-- Clear Button -->
370371
<Button Grid.Column="4"
371372
Style="{StaticResource MaterialDesignIconButton}"
373+
Command="{Binding ClearSecondaryFileCommand}"
372374
ToolTip="清除文件"
373375
Visibility="{Binding SecondaryFile.IsLoaded,
374376
Converter={StaticResource BooleanToVisibilityConverter}}">

ViewModels/MainViewModel.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class MainViewModel : BaseViewModel
3232
private readonly AsyncRelayCommand _browseSecondaryFileCommand;
3333
private readonly ConfigurationManager _configurationManager;
3434
private readonly AsyncRelayCommand<Configuration> _deleteConfigurationCommand;
35+
private readonly RelayCommand _clearPrimaryFileCommand;
36+
private readonly RelayCommand _clearSecondaryFileCommand;
37+
public ICommand ClearPrimaryFileCommand => _clearPrimaryFileCommand;
38+
public ICommand ClearSecondaryFileCommand => _clearSecondaryFileCommand;
3539

3640
/// <summary>
3741
/// 诊断匹配问题命令
@@ -159,6 +163,8 @@ public MainViewModel(ExcelFileManager excelFileManager, ConfigurationManager con
159163
_saveConfigurationCommand = new AsyncRelayCommand(SaveConfigurationAsync);
160164
_loadConfigurationCommand = new AsyncRelayCommand(LoadConfigurationAsync);
161165
_resetConfigurationCommand = new RelayCommand(ResetConfiguration);
166+
_clearPrimaryFileCommand = new RelayCommand(ClearPrimaryFile);
167+
_clearSecondaryFileCommand = new RelayCommand(ClearSecondaryFile);
162168

163169
_updateSelectedPrimaryMatchFieldsCommand = new RelayCommand<IList>(UpdateSelectedPrimaryMatchFields);
164170
_updateSelectedSecondaryMatchFieldsCommand = new RelayCommand<IList>(UpdateSelectedSecondaryMatchFields);
@@ -2946,6 +2952,35 @@ private void ResetConfiguration()
29462952
});
29472953
}
29482954

2955+
private void ClearPrimaryFile()
2956+
{
2957+
PrimaryFilePath = string.Empty;
2958+
PrimaryFilePassword = string.Empty;
2959+
PrimaryFile = new ExcelFile();
2960+
PrimaryWorksheets.Clear();
2961+
PrimaryColumns.Clear();
2962+
SelectedPrimaryWorksheets.Clear();
2963+
SelectedPrimaryMatchFields.Clear();
2964+
PrimaryPreviewData = null;
2965+
PrimaryFilters.Clear();
2966+
StatusMessage = "已清除主表文件";
2967+
}
2968+
2969+
private void ClearSecondaryFile()
2970+
{
2971+
SecondaryFilePath = string.Empty;
2972+
SecondaryFilePassword = string.Empty;
2973+
SecondaryFile = new ExcelFile();
2974+
SecondaryWorksheets.Clear();
2975+
SecondaryColumns.Clear();
2976+
SelectedSecondaryWorksheets.Clear();
2977+
SelectedSecondaryMatchFields.Clear();
2978+
SecondaryPreviewData = null;
2979+
SecondaryFilters.Clear();
2980+
FieldMappings.Clear(); // 清除字段映射
2981+
StatusMessage = "已清除辅助表文件";
2982+
}
2983+
29492984
/// <summary>
29502985
/// 从当前状态创建配置对象
29512986
/// </summary>

0 commit comments

Comments
 (0)