Skip to content

Commit 18e54c9

Browse files
authored
Merge pull request #90 from kmaki565/improve-filter-ux
Improve filter UX and add Help menu
2 parents d7a2e8f + cbfc35a commit 18e54c9

10 files changed

Lines changed: 60 additions & 28 deletions

File tree

‎EventLook/EventLook.csproj‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<AssemblyTitle>A fast &amp; handy Event Viewer</AssemblyTitle>
12-
<AssemblyVersion>1.6.3.0</AssemblyVersion>
12+
<AssemblyVersion>1.6.4.0</AssemblyVersion>
1313
<Description>$(AssemblyTitle)</Description>
1414
<Copyright>Copyright (C) K. Maki</Copyright>
1515
<Product>EventLook</Product>
@@ -49,8 +49,8 @@
4949
<Resource Include="Asset\StatusWarning_16x.png" />
5050
</ItemGroup>
5151
<ItemGroup>
52-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
53-
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
52+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
53+
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.7.25104.5739" />
5454
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
5555
</ItemGroup>
5656
<ItemGroup>

‎EventLook/Model/FilterBase.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ public void SetCvs(CollectionViewSource cvs)
2020
this.cvs.Filter += DoFilter;
2121
}
2222
/// <summary>
23-
/// Refreshes filter UI (e.g. populate filter items in a drop down) by loaded events,
23+
/// For filters with checkboxes, populates the list of checkboxes by the loaded events.
24+
/// This will do nothing for text-based filters.
2425
/// If reset is true, all filters will be cancelled (e.g. checkboxes all checked).
2526
/// Otherwise, it'll try to carry over filters user specified (except newly populated checkboxes).
2627
/// </summary>
2728
/// <param name="events">Loaded event items</param>
28-
public virtual void Refresh(IEnumerable<EventItem> events, bool reset) { }
29+
public virtual void Populate(IEnumerable<EventItem> events, bool reset) { }
2930

3031
/// <summary>
3132
/// Removes filter, but keeps the filter items in the dropdown (if available).

‎EventLook/Model/IdFilter.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ public void AddFilterId(int id, bool isExclude)
5151
+ (isExclude ? $"-{id}" : $"{id}");
5252
}
5353

54-
public override void Refresh(IEnumerable<EventItem> events, bool reset)
55-
{
56-
if (reset)
57-
Clear();
58-
}
5954
public override void Clear()
6055
{
6156
FilterText = "";

‎EventLook/Model/LevelFilter.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public ReadOnlyObservableCollection<LevelFilterItem> LevelFilters
2525
private set;
2626
}
2727

28-
public override void Refresh(IEnumerable<EventItem> events, bool reset)
28+
public override void Populate(IEnumerable<EventItem> events, bool reset)
2929
{
3030
// Remember filters and their selections before clearing (needs ToList)
3131
var prevFilters = reset ? null : levelFilters.Select(f => new { f.Level, f.Selected }).ToList();

‎EventLook/Model/MessageFilter.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ public string MessageFilterText
4040
}
4141
}
4242

43-
public override void Refresh(IEnumerable<EventItem> events, bool reset)
44-
{
45-
if (reset)
46-
Clear();
47-
}
4843
public override void Clear()
4944
{
5045
MessageFilterText = "";

‎EventLook/Model/ProcessHelper.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,18 @@ public static void LaunchEventViewer(LogSource logSource)
3636
Arguments = arg,
3737
});
3838
}
39+
40+
/// <summary>
41+
/// Launches the associated app with shell for the supplied URI .
42+
/// </summary>
43+
/// <param name="uri"></param>
44+
public static void OpenUri(string uri)
45+
{
46+
try
47+
{
48+
Process.Start(new ProcessStartInfo(uri) { UseShellExecute = true });
49+
}
50+
catch (Exception)
51+
{ }
52+
}
3953
}

‎EventLook/Model/SourceFilter.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ReadOnlyObservableCollection<SourceFilterItem> SourceFilters
2727
private set;
2828
}
2929

30-
public override void Refresh(IEnumerable<EventItem> events, bool reset)
30+
public override void Populate(IEnumerable<EventItem> events, bool reset)
3131
{
3232
// Remember filters and their selections before clearing (needs ToList)
3333
var prevFilters = reset ? null : sourceFilters.Select(f => new { f.Name, f.Selected }).ToList();

‎EventLook/View/MainWindow.xaml‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
<!-- This next line instantiates a CollectionViewSource with the collection of Events as its collection of objects-->
5252
<CollectionViewSource Source="{Binding Events}" x:Key="X_CVS"/>
5353
<DataGridTextColumn x:Key="RecordIdColumn" Header="Record ID" Binding="{Binding Record.RecordId}" Visibility="{Binding DataContext.ShowsRecordId, Source={x:Reference _window}, Converter={StaticResource BooleanToVisibilityConverter}}"/>
54+
<DataTemplate x:Key="SourceFilterWatermarkTemplate">
55+
<TextBlock Text="Select provider(s)" FontStyle="Italic" Margin="3,0,0,0"/>
56+
</DataTemplate>
57+
<DataTemplate x:Key="LevelFilterWatermarkTemplate">
58+
<TextBlock Text="Select level(s)" FontStyle="Italic" Margin="3,0,0,0"/>
59+
</DataTemplate>
5460
</Window.Resources>
5561
<Window.InputBindings>
5662
<KeyBinding Key="F5" Command="{Binding RefreshCommand}"/>
@@ -76,8 +82,13 @@
7682
<MenuItem Header="_Auto Refresh" IsCheckable="True" IsChecked="{Binding IsAutoRefreshEnabled}"/>
7783
<Separator />
7884
<MenuItem Header="_Settings..." Command="{Binding OpenSettingsCommand}" />
79-
</MenuItem>
80-
<MenuItem Header="_About" Click="MenuItem_About_Click"/>
85+
</MenuItem>
86+
<MenuItem Header="_Help">
87+
<MenuItem Header="View in _Microsoft Store" Command="{Binding OpenStoreCommand}"/>
88+
<MenuItem Header="Visit _GitHub repo" Command="{Binding OpenGitHubCommand}"/>
89+
<Separator />
90+
<MenuItem Header="_About EventLook" Click="MenuItem_About_Click"/>
91+
</MenuItem>
8192
</Menu>
8293
<StatusBar DockPanel.Dock="Bottom" Background="WhiteSmoke">
8394
<StatusBarItem>
@@ -172,13 +183,13 @@
172183
<TextBlock Text="Provider: " Margin="5,0,0,0" VerticalAlignment="Center"/>
173184
<xctk:CheckComboBox Width="250"
174185
IsSelectAllActive="True" IsAllItemsSelectedContentActive="True"
175-
Delimiter=", "
186+
Delimiter=", " WatermarkTemplate="{StaticResource SourceFilterWatermarkTemplate}"
176187
ItemsSource="{Binding SourceFilters}" DisplayMemberPath="Name" SelectedMemberPath="Selected"
177188
Command="{Binding ApplySourceFilterCommand}"/>
178189
<TextBlock Text="Level: " Margin="10,0,0,0" VerticalAlignment="Center"/>
179190
<xctk:CheckComboBox Width="120"
180191
IsSelectAllActive="True" IsAllItemsSelectedContentActive="True"
181-
Delimiter=", "
192+
Delimiter=", " WatermarkTemplate="{StaticResource LevelFilterWatermarkTemplate}"
182193
ItemsSource="{Binding LevelFilters}" SelectedMemberPath="Selected"
183194
Command="{Binding ApplyLevelFilterCommand}"/>
184195
<TextBlock Text="Event ID: " Margin="10,0,0,0" VerticalAlignment="Center"/>
@@ -202,14 +213,18 @@
202213
<ContextMenu x:Key="dataGridContextMenu">
203214
<ContextMenu.Items>
204215
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.ProviderName}" HeaderStringFormat="Filter to &quot;{0}&quot;"
205-
Command="{Binding DataContext.FilterToSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
216+
Command="{Binding DataContext.FilterToSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
217+
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
206218
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.ProviderName}" HeaderStringFormat="Exclude &quot;{0}&quot;"
207-
Command="{Binding DataContext.ExcludeSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
219+
Command="{Binding DataContext.ExcludeSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
220+
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
208221
<Separator/>
209222
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Level, Converter={StaticResource EventLevelToDisplayTextConverter}}" HeaderStringFormat="Filter to {0}"
210-
Command="{Binding DataContext.FilterToSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
223+
Command="{Binding DataContext.FilterToSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
224+
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
211225
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Level, Converter={StaticResource EventLevelToDisplayTextConverter}}" HeaderStringFormat="Exclude {0}"
212-
Command="{Binding DataContext.ExcludeSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
226+
Command="{Binding DataContext.ExcludeSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
227+
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
213228
<Separator/>
214229
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Id}" HeaderStringFormat="Filter to ID {0}"
215230
Command="{Binding DataContext.FilterToSelectedIdCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>

‎EventLook/ViewModel/MainViewModel.cs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private async void Refresh(bool reset, bool append = false)
257257
// If the log source selection is changed before completing loading events, we don't want to enumerate
258258
// the source filter items with the previous log source.
259259
if (!IsUpdating)
260-
filters.ForEach(f => f.Refresh(Events, reset));
260+
filters.ForEach(f => f.Populate(Events, reset));
261261

262262
Refreshed?.Invoke();
263263
}
@@ -359,6 +359,8 @@ private void OnFilterUpdated(object sender, EventArgs e)
359359
public ICommand CopyMessageTextCommand { get; private set; }
360360
public ICommand ExportToCsvCommand { get; private set; }
361361
public ICommand RunAsAdminCommand { get; private set; }
362+
public ICommand OpenStoreCommand { get; private set; }
363+
public ICommand OpenGitHubCommand { get; private set; }
362364

363365
private void InitializeCommands()
364366
{
@@ -382,6 +384,8 @@ private void InitializeCommands()
382384
CopyMessageTextCommand = new RelayCommand(CopyMessageText);
383385
ExportToCsvCommand = new RelayCommand(ExportToCsv);
384386
RunAsAdminCommand = new RelayCommand(RunAsAdmin);
387+
OpenStoreCommand = new RelayCommand(OpenStore);
388+
OpenGitHubCommand = new RelayCommand(OpenGitHub);
385389
}
386390
#endregion
387391

@@ -483,7 +487,7 @@ private void AutoRefreshCallback(ProgressInfo progressInfo)
483487
{
484488
InsertEvents(progressInfo.LoadedEvents); // Single event should be loaded at a time.
485489
LoadedEventCount = Events.Count;
486-
filters.ForEach(f => f.Refresh(Events, reset: false));
490+
filters.ForEach(f => f.Populate(Events, reset: false));
487491
// If the range is like "Last x days", just adjust appearance of the date time picker.
488492
if (!SelectedRange.IsCustom && SelectedRange.DaysFromNow != 0)
489493
ToDateTime = DateTime.Now;
@@ -752,4 +756,12 @@ private void RunAsAdmin()
752756
MessageBox.Show("Failed to restart as administrator.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
753757
}
754758
}
759+
private void OpenStore()
760+
{
761+
ProcessHelper.OpenUri("ms-windows-store://pdp/?productid=9NJV5FQ089Z0");
762+
}
763+
private void OpenGitHub()
764+
{
765+
ProcessHelper.OpenUri("https://github.com/kmaki565/EventLook");
766+
}
755767
}

‎EventLookPackage/Package.appxmanifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Identity
1010
Name="64247kmaki565.323654BB1C7D"
1111
Publisher="CN=B5234934-E68F-4911-8E10-60FECC338A02"
12-
Version="1.6.3.0" />
12+
Version="1.6.4.0" />
1313

1414
<Properties>
1515
<DisplayName>EventLook</DisplayName>

0 commit comments

Comments
 (0)