From 54f7e03130eb5a06e7e0ba5943065002bae9ee6c Mon Sep 17 00:00:00 2001
From: CHEN HONG GUAN <666ddxx@gmail.com>
Date: Tue, 25 Aug 2026 22:04:53 +0800
Subject: [PATCH] feat: show active filter state
Fixes #21
---
Localization.cs | 4 ++
MainWindow.xaml | 67 +++++++++++++++++++---------
MainWindow.xaml.cs | 75 +++++++++++++++++++++++++++++++-
tests/EventFast.Tests/Program.cs | 54 ++++++++++++++++++++++-
4 files changed, 176 insertions(+), 24 deletions(-)
diff --git a/Localization.cs b/Localization.cs
index bd6918f..00a290a 100644
--- a/Localization.cs
+++ b/Localization.cs
@@ -25,6 +25,8 @@ public sealed class Localization : INotifyPropertyChanged
["QuickDisk"] = "Disk / SSD / NVMe", ["QuickNtfs"] = "NTFS / file system", ["QuickUsb"] = "USB / USB-C / UCSI",
["QuickDevice"] = "Device / Kernel-PnP", ["QuickDriver"] = "Drivers", ["QuickWhea"] = "Hardware / WHEA",
["QuickNetwork"] = "Network", ["QuickUpdate"] = "Windows Update", ["QuickPower"] = "Power / unexpected shutdown",
+ ["ActiveFilters"] = "Active filters: {0}", ["FilterKeyword"] = "Keyword: {0}", ["FilterProvider"] = "Provider: {0}",
+ ["FilterChannels"] = "Channels: {0}", ["FilterSort"] = "Sort: {0}",
["SearchPossibleCauses"] = "Search possible causes", ["EventId"] = "Event ID", ["ColumnSeverity"] = "Severity", ["ColumnProblem"] = "Problem",
["ColumnCount"] = "Count", ["ColumnSource"] = "Source", ["ColumnLastSeen"] = "Last seen",
["ProblemDetails"] = "Problem details", ["GroupedEvents"] = "Group Events", ["ColumnTime"] = "Time",
@@ -93,6 +95,8 @@ public sealed class Localization : INotifyPropertyChanged
["QuickDisk"] = "磁碟 / SSD / NVMe", ["QuickNtfs"] = "NTFS / 檔案系統", ["QuickUsb"] = "USB / USB-C / UCSI",
["QuickDevice"] = "裝置 / Kernel-PnP", ["QuickDriver"] = "驅動程式", ["QuickWhea"] = "硬體 / WHEA",
["QuickNetwork"] = "網路", ["QuickUpdate"] = "Windows Update", ["QuickPower"] = "電源 / 異常關機",
+ ["ActiveFilters"] = "啟用篩選:{0}", ["FilterKeyword"] = "關鍵字:{0}", ["FilterProvider"] = "Provider:{0}",
+ ["FilterChannels"] = "Channel:{0}", ["FilterSort"] = "排序:{0}",
["SearchPossibleCauses"] = "使用搜尋引擎查詢可能原因", ["EventId"] = "Event ID", ["ColumnSeverity"] = "等級", ["ColumnProblem"] = "問題",
["ColumnCount"] = "次數", ["ColumnSource"] = "來源", ["ColumnLastSeen"] = "最後發生",
["ProblemDetails"] = "問題詳細資料", ["GroupedEvents"] = "群組事件", ["ColumnTime"] = "時間",
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 0e825a5..f8326de 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -4,6 +4,22 @@
xmlns:local="clr-namespace:EventFast"
Title="EventFast" Icon="Assets/EventFast.ico" Height="760" Width="1180" MinHeight="560" MinWidth="820"
Background="#F4F6F8" PreviewKeyDown="Window_PreviewKeyDown" AllowDrop="True" Drop="Window_Drop">
+
+
+
+
@@ -25,9 +41,10 @@
-
+
+ ToolTip="{local:Loc SearchTip}" TextChanged="ManualFilter_Changed" />
@@ -46,19 +63,21 @@
-
+
-
+
-
+
-
-
+
+
@@ -77,20 +96,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Dispatcher.BeginInvoke(() => _ = RunQueryAsync(_quickQuery is null ? null : EventQuery.QuickQueries[_quickQuery]));
}
@@ -87,12 +88,14 @@ internal MainWindow(StartupOptions? options = null)
private async void Search_Click(object sender, RoutedEventArgs e)
{
_quickQuery = null;
+ UpdateFilterVisuals();
await RunQueryAsync(null);
}
private async void Quick_Click(object sender, RoutedEventArgs e)
{
_quickQuery = (string)((Button)sender).Tag;
+ UpdateFilterVisuals();
await RunQueryAsync(EventQuery.QuickQueries[_quickQuery]);
}
@@ -228,6 +231,7 @@ private async void Window_Drop(object sender, DragEventArgs e)
Title = $"EventFast — {Path.GetFileName(_eventFile)}";
SystemBox.IsEnabled = ApplicationBox.IsEnabled = false;
TimeBox.SelectedIndex = TimeBox.Items.Count - 1;
+ UpdateFilterVisuals();
await RunQueryAsync(null);
}
@@ -350,6 +354,7 @@ private void Sort_Changed(object sender, SelectionChangedEventArgs e)
return;
ApplySort();
+ UpdateFilterVisuals();
}
private void ApplySort()
@@ -443,6 +448,73 @@ private void Time_Changed(object sender, SelectionChangedEventArgs e)
{
if (CustomTimePanel is not null && TimeBox.SelectedItem is ComboBoxItem item)
CustomTimePanel.Visibility = item.Tag.ToString() == "custom" ? Visibility.Visible : Visibility.Collapsed;
+ UpdateFilterVisuals();
+ }
+
+ private void Filter_Changed(object sender, RoutedEventArgs e) => UpdateFilterVisuals();
+
+ private void ManualFilter_Changed(object sender, RoutedEventArgs e)
+ {
+ UpdateFilterVisuals();
+ }
+
+ private void UpdateFilterVisuals()
+ {
+ if (ActiveFiltersText is null || SearchBox is null || TimeBox.SelectedItem is not ComboBoxItem timeItem ||
+ LevelBox.SelectedItem is not ComboBoxItem levelItem || SortBox.SelectedItem is not ComboBoxItem sortItem)
+ return;
+
+ var quick = _quickQuery is not null && EventQuery.QuickQueries.TryGetValue(_quickQuery, out var selectedQuick)
+ ? selectedQuick
+ : null;
+ var criteria = quick is null ? EventQuery.Parse(SearchBox.Text, 0, TimeSpan.Zero, _providerFilter) : null;
+ var channelsOverridden = quick?.Channels is { Length: > 0 };
+ var channelsEditable = _eventFile is null && !channelsOverridden;
+ SystemBox.IsEnabled = ApplicationBox.IsEnabled = channelsEditable;
+ SetFilterActive(SearchBox, criteria?.Keyword is not null || criteria?.EventId is not null);
+ SetFilterActive(TimeBox, timeItem.Tag.ToString() != "24");
+ var custom = timeItem.Tag.ToString() == "custom";
+ SetFilterActive(FromDate, custom);
+ SetFilterActive(ToDate, custom);
+ SetFilterActive(LevelBox, levelItem.Tag.ToString() != "3");
+ SetFilterActive(SystemBox, channelsEditable && SystemBox.IsChecked == true);
+ SetFilterActive(ApplicationBox, channelsEditable && ApplicationBox.IsChecked == true);
+ SetFilterActive(SortBox, sortItem.Tag.ToString() != "default");
+ SetFilterActive(IncludeXmlBox, IncludeXmlBox.IsChecked == true);
+ foreach (var button in QuickFilterPanel.Children.OfType