Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EventLook/EventLook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<PropertyGroup>
<AssemblyTitle>A fast &amp; handy Event Viewer</AssemblyTitle>
<AssemblyVersion>1.6.3.0</AssemblyVersion>
<AssemblyVersion>1.6.4.0</AssemblyVersion>
<Description>$(AssemblyTitle)</Description>
<Copyright>Copyright (C) K. Maki</Copyright>
<Product>EventLook</Product>
Expand Down Expand Up @@ -49,8 +49,8 @@
<Resource Include="Asset\StatusWarning_16x.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.7.25104.5739" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions EventLook/Model/FilterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public void SetCvs(CollectionViewSource cvs)
this.cvs.Filter += DoFilter;
}
/// <summary>
/// Refreshes filter UI (e.g. populate filter items in a drop down) by loaded events,
/// For filters with checkboxes, populates the list of checkboxes by the loaded events.
/// This will do nothing for text-based filters.
/// If reset is true, all filters will be cancelled (e.g. checkboxes all checked).
/// Otherwise, it'll try to carry over filters user specified (except newly populated checkboxes).
/// </summary>
/// <param name="events">Loaded event items</param>
public virtual void Refresh(IEnumerable<EventItem> events, bool reset) { }
public virtual void Populate(IEnumerable<EventItem> events, bool reset) { }

/// <summary>
/// Removes filter, but keeps the filter items in the dropdown (if available).
Expand Down
5 changes: 0 additions & 5 deletions EventLook/Model/IdFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ public void AddFilterId(int id, bool isExclude)
+ (isExclude ? $"-{id}" : $"{id}");
}

public override void Refresh(IEnumerable<EventItem> events, bool reset)
{
if (reset)
Clear();
}
public override void Clear()
{
FilterText = "";
Expand Down
2 changes: 1 addition & 1 deletion EventLook/Model/LevelFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ReadOnlyObservableCollection<LevelFilterItem> LevelFilters
private set;
}

public override void Refresh(IEnumerable<EventItem> events, bool reset)
public override void Populate(IEnumerable<EventItem> events, bool reset)
{
// Remember filters and their selections before clearing (needs ToList)
var prevFilters = reset ? null : levelFilters.Select(f => new { f.Level, f.Selected }).ToList();
Expand Down
5 changes: 0 additions & 5 deletions EventLook/Model/MessageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public string MessageFilterText
}
}

public override void Refresh(IEnumerable<EventItem> events, bool reset)
{
if (reset)
Clear();
}
public override void Clear()
{
MessageFilterText = "";
Expand Down
14 changes: 14 additions & 0 deletions EventLook/Model/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,18 @@ public static void LaunchEventViewer(LogSource logSource)
Arguments = arg,
});
}

/// <summary>
/// Launches the associated app with shell for the supplied URI .
/// </summary>
/// <param name="uri"></param>
public static void OpenUri(string uri)
{
try
{
Process.Start(new ProcessStartInfo(uri) { UseShellExecute = true });
}
catch (Exception)
{ }
}
}
2 changes: 1 addition & 1 deletion EventLook/Model/SourceFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ReadOnlyObservableCollection<SourceFilterItem> SourceFilters
private set;
}

public override void Refresh(IEnumerable<EventItem> events, bool reset)
public override void Populate(IEnumerable<EventItem> events, bool reset)
{
// Remember filters and their selections before clearing (needs ToList)
var prevFilters = reset ? null : sourceFilters.Select(f => new { f.Name, f.Selected }).ToList();
Expand Down
31 changes: 23 additions & 8 deletions EventLook/View/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<!-- This next line instantiates a CollectionViewSource with the collection of Events as its collection of objects-->
<CollectionViewSource Source="{Binding Events}" x:Key="X_CVS"/>
<DataGridTextColumn x:Key="RecordIdColumn" Header="Record ID" Binding="{Binding Record.RecordId}" Visibility="{Binding DataContext.ShowsRecordId, Source={x:Reference _window}, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<DataTemplate x:Key="SourceFilterWatermarkTemplate">
<TextBlock Text="Select provider(s)" FontStyle="Italic" Margin="3,0,0,0"/>
</DataTemplate>
<DataTemplate x:Key="LevelFilterWatermarkTemplate">
<TextBlock Text="Select level(s)" FontStyle="Italic" Margin="3,0,0,0"/>
</DataTemplate>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Key="F5" Command="{Binding RefreshCommand}"/>
Expand All @@ -76,8 +82,13 @@
<MenuItem Header="_Auto Refresh" IsCheckable="True" IsChecked="{Binding IsAutoRefreshEnabled}"/>
<Separator />
<MenuItem Header="_Settings..." Command="{Binding OpenSettingsCommand}" />
</MenuItem>
<MenuItem Header="_About" Click="MenuItem_About_Click"/>
</MenuItem>
<MenuItem Header="_Help">
<MenuItem Header="View in _Microsoft Store" Command="{Binding OpenStoreCommand}"/>
<MenuItem Header="Visit _GitHub repo" Command="{Binding OpenGitHubCommand}"/>
<Separator />
<MenuItem Header="_About EventLook" Click="MenuItem_About_Click"/>
</MenuItem>
</Menu>
<StatusBar DockPanel.Dock="Bottom" Background="WhiteSmoke">
<StatusBarItem>
Expand Down Expand Up @@ -172,13 +183,13 @@
<TextBlock Text="Provider: " Margin="5,0,0,0" VerticalAlignment="Center"/>
<xctk:CheckComboBox Width="250"
IsSelectAllActive="True" IsAllItemsSelectedContentActive="True"
Delimiter=", "
Delimiter=", " WatermarkTemplate="{StaticResource SourceFilterWatermarkTemplate}"
ItemsSource="{Binding SourceFilters}" DisplayMemberPath="Name" SelectedMemberPath="Selected"
Command="{Binding ApplySourceFilterCommand}"/>
<TextBlock Text="Level: " Margin="10,0,0,0" VerticalAlignment="Center"/>
<xctk:CheckComboBox Width="120"
IsSelectAllActive="True" IsAllItemsSelectedContentActive="True"
Delimiter=", "
Delimiter=", " WatermarkTemplate="{StaticResource LevelFilterWatermarkTemplate}"
ItemsSource="{Binding LevelFilters}" SelectedMemberPath="Selected"
Command="{Binding ApplyLevelFilterCommand}"/>
<TextBlock Text="Event ID: " Margin="10,0,0,0" VerticalAlignment="Center"/>
Expand All @@ -202,14 +213,18 @@
<ContextMenu x:Key="dataGridContextMenu">
<ContextMenu.Items>
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.ProviderName}" HeaderStringFormat="Filter to &quot;{0}&quot;"
Command="{Binding DataContext.FilterToSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
Command="{Binding DataContext.FilterToSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.ProviderName}" HeaderStringFormat="Exclude &quot;{0}&quot;"
Command="{Binding DataContext.ExcludeSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
Command="{Binding DataContext.ExcludeSelectedSourceCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
<Separator/>
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Level, Converter={StaticResource EventLevelToDisplayTextConverter}}" HeaderStringFormat="Filter to {0}"
Command="{Binding DataContext.FilterToSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
Command="{Binding DataContext.FilterToSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Level, Converter={StaticResource EventLevelToDisplayTextConverter}}" HeaderStringFormat="Exclude {0}"
Command="{Binding DataContext.ExcludeSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
Command="{Binding DataContext.ExcludeSelectedLevelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
IsEnabled="{Binding DataContext.IsUpdating, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Converter={StaticResource InverseBooleanConverter}}"/>
<Separator/>
<MenuItem Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.Record.Id}" HeaderStringFormat="Filter to ID {0}"
Command="{Binding DataContext.FilterToSelectedIdCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
Expand Down
16 changes: 14 additions & 2 deletions EventLook/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private async void Refresh(bool reset, bool append = false)
// If the log source selection is changed before completing loading events, we don't want to enumerate
// the source filter items with the previous log source.
if (!IsUpdating)
filters.ForEach(f => f.Refresh(Events, reset));
filters.ForEach(f => f.Populate(Events, reset));

Refreshed?.Invoke();
}
Expand Down Expand Up @@ -359,6 +359,8 @@ private void OnFilterUpdated(object sender, EventArgs e)
public ICommand CopyMessageTextCommand { get; private set; }
public ICommand ExportToCsvCommand { get; private set; }
public ICommand RunAsAdminCommand { get; private set; }
public ICommand OpenStoreCommand { get; private set; }
public ICommand OpenGitHubCommand { get; private set; }

private void InitializeCommands()
{
Expand All @@ -382,6 +384,8 @@ private void InitializeCommands()
CopyMessageTextCommand = new RelayCommand(CopyMessageText);
ExportToCsvCommand = new RelayCommand(ExportToCsv);
RunAsAdminCommand = new RelayCommand(RunAsAdmin);
OpenStoreCommand = new RelayCommand(OpenStore);
OpenGitHubCommand = new RelayCommand(OpenGitHub);
}
#endregion

Expand Down Expand Up @@ -483,7 +487,7 @@ private void AutoRefreshCallback(ProgressInfo progressInfo)
{
InsertEvents(progressInfo.LoadedEvents); // Single event should be loaded at a time.
LoadedEventCount = Events.Count;
filters.ForEach(f => f.Refresh(Events, reset: false));
filters.ForEach(f => f.Populate(Events, reset: false));
// If the range is like "Last x days", just adjust appearance of the date time picker.
if (!SelectedRange.IsCustom && SelectedRange.DaysFromNow != 0)
ToDateTime = DateTime.Now;
Expand Down Expand Up @@ -752,4 +756,12 @@ private void RunAsAdmin()
MessageBox.Show("Failed to restart as administrator.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void OpenStore()
{
ProcessHelper.OpenUri("ms-windows-store://pdp/?productid=9NJV5FQ089Z0");
}
private void OpenGitHub()
{
ProcessHelper.OpenUri("https://github.com/kmaki565/EventLook");
}
}
2 changes: 1 addition & 1 deletion EventLookPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="64247kmaki565.323654BB1C7D"
Publisher="CN=B5234934-E68F-4911-8E10-60FECC338A02"
Version="1.6.3.0" />
Version="1.6.4.0" />

<Properties>
<DisplayName>EventLook</DisplayName>
Expand Down