diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/CommandPalette.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/CommandPalette.cs index f3258a8..77a7069 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/CommandPalette.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/CommandPalette.cs @@ -87,8 +87,8 @@ public class CommandPalette new TextBlock() .Setup(t => t.Bind( t, - d => d.Title, - t => t.Text)), + dc => dc!.Title, + tb => tb.Text)), new TextBlock { Extensions = @@ -98,20 +98,24 @@ public class CommandPalette } .Setup(t => t.Bind( t, - d => d.Shortcuts, - t => t.Text)) + dc => dc!.Shortcuts, + tb => tb.Text)) } }; item.Bind( item.Parent, - d => d.CommandPalette.SelectedItem.Identifier == item.DataContext.Identifier ? _theme.ListViewItemTheme.SelectedBackgroundColor : null, + dc => dc!.CommandPalette.SelectedItem!.Identifier == item.DataContext!.Identifier + ? _theme.ListViewItemTheme.SelectedBackgroundColor + : null, t => t.Background ); item.Bind( item.Parent, - d => d.CommandPalette.SelectedItem.Identifier == item.DataContext.Identifier ? _theme.ListViewItemTheme.SelectedForegroundColor : null, + dc => dc!.CommandPalette.SelectedItem!.Identifier == item.DataContext!.Identifier + ? _theme.ListViewItemTheme.SelectedForegroundColor + : null, t => t.Foreground ); @@ -119,13 +123,13 @@ public class CommandPalette } }.Setup(t => t.Bind( t, - d => d.CommandPalette.FilteredMatches, - t => t.ItemsSource + dc => dc!.CommandPalette.FilteredMatches, + tb => tb.ItemsSource )) .Setup(t => t.Bind( t, - d => d.CommandPalette.SelectedItem, - t => t.SelectedItem + dc => dc!.CommandPalette.SelectedItem, + tb => tb.SelectedItem )) } } @@ -146,9 +150,8 @@ public class CommandPalette root.Bind( root, - d => d.CommandPalette.ShowWindow.Value, - t => t.IsVisible, - r => r); + dc => dc!.CommandPalette.ShowWindow.Value, + t => t.IsVisible); return root; } diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Dialogs.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Dialogs.cs index ac3bbd2..29aa111 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Dialogs.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Dialogs.cs @@ -18,7 +18,6 @@ namespace FileTime.ConsoleUI.App.Controls; public class Dialogs { private readonly IRootViewModel _rootViewModel; - private readonly ITheme _theme; private ItemsControl _readInputs = null!; private IInputElement? _inputElementToFocus; @@ -30,7 +29,6 @@ public class Dialogs public Dialogs(IRootViewModel rootViewModel, ITheme theme) { _rootViewModel = rootViewModel; - _theme = theme; _specialItemNamePartFormat = new OrFormat { @@ -40,7 +38,7 @@ public class Dialogs }, Format2 = new SimpleFormat { - Foreground = _theme.DefaultForegroundAccentColor + Foreground = theme.DefaultForegroundAccentColor } }; @@ -74,8 +72,8 @@ public class Dialogs Content = new TextBlock() .Setup(t => t.Bind( t, - dc => dc.DialogService.LastMessageBox.Value.OkText, - t => t.Text)), + dc => dc!.DialogService.LastMessageBox.Value!.OkText, + tb => tb.Text)), }.WithClickHandler(b => b.DataContext?.DialogService.LastMessageBox.Value?.Ok()); var cancelButton = @@ -85,13 +83,13 @@ public class Dialogs Content = new TextBlock() .Setup(t => t.Bind( t, - dc => dc.DialogService.LastMessageBox.Value.CancelText, - t => t.Text)), + dc => dc!.DialogService.LastMessageBox.Value!.CancelText, + tb => tb.Text)), } .Setup(b => b.Bind( b, - dc => dc.DialogService.LastMessageBox.Value.ShowCancel, - b => b.IsVisible)) + dc => dc!.DialogService.LastMessageBox.Value!.ShowCancel, + bt => bt.IsVisible)) .WithClickHandler(b => b.DataContext?.DialogService.LastMessageBox.Value?.Cancel()); var root = new Border @@ -107,8 +105,8 @@ public class Dialogs new TextBlock() .Setup(t => t.Bind( t, - dc => dc.DialogService.LastMessageBox.Value.Text, - t => t.Text)), + dc => dc!.DialogService.LastMessageBox.Value!.Text, + tb => tb.Text)), new StackPanel { Orientation = Orientation.Horizontal, @@ -125,8 +123,8 @@ public class Dialogs root.Bind( root, - d => d.DialogService.LastMessageBox.Value != null, - v => v.IsVisible, + dc => dc!.DialogService.LastMessageBox.Value != null, + br => br.IsVisible, fallbackValue: false); ((INotifyPropertyChanged) root).PropertyChanged += (_, e) => @@ -159,8 +157,8 @@ public class Dialogs } .Setup(i => i.Bind( i, - dc => dc.DialogService.ReadInput.Value.Previews, - c => c.ItemsSource + dc => dc!.DialogService.ReadInput.Value!.Previews, + ic => ic.ItemsSource )) .WithExtension(new GridPositionExtension(0, 1)) } @@ -169,8 +167,8 @@ public class Dialogs root.Bind( root, - d => d.DialogService.ReadInput.Value != null, - v => v.IsVisible); + dc => dc!.DialogService.ReadInput.Value != null, + br => br.IsVisible); return root; } @@ -187,12 +185,12 @@ public class Dialogs } .Setup(i => i.Bind( i, - dc => (PreviewType) dc.PreviewType == PreviewType.PreviewList, - c => c.IsVisible)) + dc => (PreviewType) dc!.PreviewType == PreviewType.PreviewList, + ic => ic.IsVisible)) .Setup(i => i.Bind( i, - dc => ((PreviewList) dc).Items, - c => c.ItemsSource)), + dc => ((PreviewList) dc!).Items, + ic => ic.ItemsSource)), new Grid { ColumnDefinitionsObject = "* *", @@ -201,7 +199,7 @@ public class Dialogs new TextBlock() .Setup(t => t.Bind( t, - dc => ((DoubleTextPreview) dc).Text1, + dc => ((DoubleTextPreview) dc!).Text1, tb => tb.Text )), new TextBlock @@ -213,14 +211,14 @@ public class Dialogs } .Setup(t => t.Bind( t, - dc => ((DoubleTextPreview) dc).Text2, + dc => ((DoubleTextPreview) dc!).Text2, tb => tb.Text )) } }.Setup(g => g.Bind( g, - dc => (PreviewType) dc.PreviewType == PreviewType.DoubleText, - g => g.IsVisible)), + dc => (PreviewType) dc!.PreviewType == PreviewType.DoubleText, + gr => gr.IsVisible)), new Grid { ColumnDefinitionsObject = "* *", @@ -232,7 +230,7 @@ public class Dialogs ItemTemplate = ItemNamePartItemTemplate }.Setup(i => i.Bind( i, - dc => ((DoubleItemNamePartListPreview) dc).ItemNameParts1, + dc => ((DoubleItemNamePartListPreview) dc!).ItemNameParts1, c => c.ItemsSource)), new ItemsControl { @@ -244,13 +242,13 @@ public class Dialogs ItemTemplate = ItemNamePartItemTemplate }.Setup(i => i.Bind( i, - dc => ((DoubleItemNamePartListPreview) dc).ItemNameParts2, + dc => ((DoubleItemNamePartListPreview) dc!).ItemNameParts2, c => c.ItemsSource)) } }.Setup(g => g.Bind( g, - dc => (PreviewType) dc.PreviewType == PreviewType.DoubleItemNamePartList, - g => g.IsVisible)) + dc => (PreviewType) dc!.PreviewType == PreviewType.DoubleItemNamePartList, + gr => gr.IsVisible)) } }; @@ -261,12 +259,12 @@ public class Dialogs var textBlock = new TextBlock(); textBlock.Bind( textBlock, - dc => dc.Text, + dc => dc!.Text, tb => tb.Text ); textBlock.Bind( textBlock, - dc => dc.IsSpecial ? _specialItemNamePartFormat : null, + dc => dc!.IsSpecial ? _specialItemNamePartFormat : null, tb => tb.TextFormat ); @@ -289,7 +287,7 @@ public class Dialogs new TextBlock() .Setup(t => t.Bind( t, - c => c.Label, + dc => dc!.Label, tb => tb.Text )), new Grid @@ -306,14 +304,14 @@ public class Dialogs new TextBox() .Setup(t => t.Bind( t, - d => ((TextInputElement) d).Value, + dc => ((TextInputElement) dc!).Value, tb => tb.Text, v => v ?? string.Empty, fallbackValue: string.Empty )) .Setup(t => t.Bind( t, - d => ((TextInputElement) d).Label, + dc => ((TextInputElement) dc!).Label, tb => tb.Name)) .WithTextHandler((tb, t) => { @@ -323,7 +321,7 @@ public class Dialogs } .Setup(t => t.Bind( t, - d => d.Type == InputType.Text, + dc => dc!.Type == InputType.Text, tb => tb.IsVisible )), new Border @@ -335,14 +333,14 @@ public class Dialogs } .Setup(t => t.Bind( t, - d => ((PasswordInputElement) d).Value, + d => ((PasswordInputElement) d!).Value, tb => tb.Text, v => v ?? string.Empty, fallbackValue: string.Empty )) .Setup(t => t.Bind( t, - d => ((PasswordInputElement) d).Label, + d => ((PasswordInputElement) d!).Label, tb => tb.Name)) .WithTextHandler((tb, t) => { @@ -352,7 +350,7 @@ public class Dialogs } .Setup(t => t.Bind( t, - d => d.Type == InputType.Password, + dc => dc!.Type == InputType.Password, tb => tb.IsVisible )) //TODO: OptionInputElement @@ -366,8 +364,8 @@ public class Dialogs } .Setup(t => t.Bind( t, - d => d.DialogService.ReadInput.Value.Inputs, - c => c.ItemsSource + dc => dc!.DialogService.ReadInput.Value!.Inputs, + ic => ic.ItemsSource )); readInputs.WithKeyHandler((_, e) => @@ -413,7 +411,7 @@ public class Dialogs void NotifyCollectionChangedEventHandler( object? sender, - NotifyCollectionChangedEventArgs e) + NotifyCollectionChangedEventArgs _) { UpdateReadInputsFocus(); } diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/FrequencyNavigation.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/FrequencyNavigation.cs index 9485674..9d8c28b 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/FrequencyNavigation.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/FrequencyNavigation.cs @@ -52,7 +52,7 @@ public class FrequencyNavigation { sender.DataContext.FrequencyNavigation.SearchText = text; } - });; + }); var root = new Border { @@ -86,19 +86,19 @@ public class FrequencyNavigation .Setup(t => t.Bind( t, d => d, - t => t.Text)), + tb => tb.Text)), } }; item.Bind( item.Parent, - d => d.FrequencyNavigation.SelectedItem == item.DataContext ? _theme.ListViewItemTheme.SelectedBackgroundColor : null, + dc => dc!.FrequencyNavigation.SelectedItem == item.DataContext ? _theme.ListViewItemTheme.SelectedBackgroundColor : null, t => t.Background ); item.Bind( item.Parent, - d => d.FrequencyNavigation.SelectedItem == item.DataContext ? _theme.ListViewItemTheme.SelectedForegroundColor : null, + dc => dc!.FrequencyNavigation.SelectedItem == item.DataContext ? _theme.ListViewItemTheme.SelectedForegroundColor : null, t => t.Foreground ); @@ -106,13 +106,13 @@ public class FrequencyNavigation } }.Setup(t => t.Bind( t, - d => d.FrequencyNavigation.FilteredMatches, - t => t.ItemsSource + dc => dc!.FrequencyNavigation.FilteredMatches, + tb => tb.ItemsSource )) .Setup(t => t.Bind( t, - d => d.FrequencyNavigation.SelectedItem, - t => t.SelectedItem + dc => dc!.FrequencyNavigation.SelectedItem, + tb => tb.SelectedItem )) } } @@ -133,7 +133,7 @@ public class FrequencyNavigation root.Bind( root, - d => d.FrequencyNavigation.ShowWindow.Value, + dc => dc!.FrequencyNavigation.ShowWindow.Value, t => t.IsVisible, r => r); diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/ItemPreviews.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/ItemPreviews.cs index b46e4dc..f2997c3 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/ItemPreviews.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/ItemPreviews.cs @@ -19,7 +19,7 @@ public class ItemPreviews private readonly ITheme _theme; private readonly IConsoleAppState _appState; private readonly IColorProvider _colorProvider; - private ItemsControl _sizePreviews; + private ItemsControl _sizePreviews = null!; public ItemPreviews( ITheme theme, @@ -45,16 +45,16 @@ public class ItemPreviews Foreground = _theme.ErrorForegroundColor, }.Setup(t => t.Bind( t, - dc => dc.AppState.SelectedTab.Value.SelectedsChildren.Value.Count == 0, - t => t.IsVisible, + dc => dc!.AppState.SelectedTab.Value!.SelectedsChildren.Value!.Count == 0, + tb => tb.IsVisible, fallbackValue: false)), ElementPreviews() .WithDataContextBinding( - dc => (IElementPreviewViewModel) dc.ItemPreviewService.ItemPreview.Value + dc => (IElementPreviewViewModel) dc!.ItemPreviewService.ItemPreview.Value! ), SizeContainerPreview() .WithDataContextBinding( - dc => (ContainerPreview) dc.ItemPreviewService.ItemPreview.Value + dc => (ContainerPreview) dc!.ItemPreviewService.ItemPreview.Value! ) } }; @@ -71,8 +71,8 @@ public class ItemPreviews }; sizePreviews.Setup(c => c.Bind( c, - dc => dc.TopItems, - c => c.ItemsSource)); + dc => dc!.TopItems, + ic => ic.ItemsSource)); _sizePreviews = sizePreviews; @@ -101,8 +101,8 @@ public class ItemPreviews } .Setup(r => r.Bind( r, - dc => GenerateSizeBackground(_sizePreviews.DataContext.TopItems, dc), - r => r.Fill)), + dc => GenerateSizeBackground(_sizePreviews.DataContext!.TopItems, dc), + rt => rt.Fill)), new TextBlock { Extensions = {new GridPositionExtension(1, 0)}, @@ -111,8 +111,8 @@ public class ItemPreviews } .Setup(t => t.Bind( t, - dc => dc.Size.Value, - t => t.Text, + dc => dc!.Size.Value, + tb => tb.Text, v => ByteSize.FromBytes(v).ToString())), new TextBlock { @@ -120,8 +120,8 @@ public class ItemPreviews } .Setup(t => t.Bind( t, - dc => dc.Name, - t => t.Text)) + dc => dc!.Name, + tb => tb.Text)) } }; @@ -130,14 +130,14 @@ public class ItemPreviews } .Setup(c => c.Bind( c, - dc => dc.TopItems, - c => c.ItemsSource)) + dc => dc!.TopItems, + ic => ic.ItemsSource)) } }; root.Bind( root, - dc => dc.Name == ContainerPreview.PreviewName, + dc => dc!.Name == ContainerPreview.PreviewName, r => r.IsVisible); return root; @@ -155,14 +155,14 @@ public class ItemPreviews } .Setup(r => r.Bind( r, - dc => GenerateSizeBackground(_sizePreviews.DataContext.TopItems, dc), - r => r.Fill)) + dc => GenerateSizeBackground(_sizePreviews.DataContext!.TopItems, dc), + rt => rt.Fill)) } }; root.Bind( root, - dc => GetWidth(dc.Size.Value, _sizePreviews.DataContext.TopItems, _sizePreviews.ActualWidth), + dc => GetWidth(dc!.Size.Value, _sizePreviews.DataContext!.TopItems, _sizePreviews.ActualWidth), r => r.Width); return root; @@ -193,8 +193,8 @@ public class ItemPreviews Text = "Don't know how to preview this item.", }.Setup(t => t.Bind( t, - dc => dc.Mode == ItemPreviewMode.Unknown, - t => t.IsVisible, + dc => dc!.Mode == ItemPreviewMode.Unknown, + tb => tb.IsVisible, fallbackValue: false)), new TextBlock { @@ -202,8 +202,8 @@ public class ItemPreviews Text = "Empty", }.Setup(t => t.Bind( t, - dc => dc.Mode == ItemPreviewMode.Empty, - t => t.IsVisible, + dc => dc!.Mode == ItemPreviewMode.Empty, + tb => tb.IsVisible, fallbackValue: false)), new Grid { @@ -215,14 +215,14 @@ public class ItemPreviews { t.Bind( t, - dc => dc.TextContent, - t => t.Text, + dc => dc!.TextContent, + tb => tb.Text, fallbackValue: string.Empty); t.Bind( t, dc => _appState.PreviewType, - t => t.IsVisible, + tb => tb.IsVisible, v => v is null or ItemPreviewType.Text); }), new BinaryView() @@ -230,13 +230,13 @@ public class ItemPreviews { b.Bind( b, - dc => dc.BinaryContent, - b => b.Data); + dc => dc!.BinaryContent, + bv => bv.Data); b.Bind( b, dc => _appState.PreviewType, - t => t.IsVisible, + bv => bv.IsVisible, v => v == ItemPreviewType.Binary); }), new TextBlock @@ -245,22 +245,22 @@ public class ItemPreviews Extensions = {new GridPositionExtension(0, 1)} }.Setup(t => t.Bind( t, - dc => dc.TextEncoding, - t => t.Text, + dc => dc!.TextEncoding, + tb => tb.Text, v => $"Encoding: {v}")) } }.Setup(t => t.Bind( t, - dc => dc.Mode == ItemPreviewMode.Text, - t => t.IsVisible, + dc => dc!.Mode == ItemPreviewMode.Text, + tb => tb.IsVisible, fallbackValue: false)), } }; view.Bind( view, - dc => dc.Name == ElementPreviewViewModel.PreviewName, - v => v.IsVisible + dc => dc!.Name == ElementPreviewViewModel.PreviewName, + gr => gr.IsVisible ); return view; diff --git a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs index 60a7b4c..7a99e42 100644 --- a/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs +++ b/src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs @@ -42,8 +42,8 @@ public class Timeline { new TextBlock().Setup(t => t.Bind( t, - dc => dc.DisplayLabel.Value, - t => t.Text)), + dc => dc!.DisplayLabel.Value, + tb => tb.Text)), new TextBlock { Width = 5, @@ -51,8 +51,8 @@ public class Timeline Extensions = {new GridPositionExtension(1, 0)} }.Setup(t => t.Bind( t, - dc => dc.TotalProgress.Value, - t => t.Text, + dc => dc!.TotalProgress.Value, + tb => tb.Text, v => $"{v}%")), } }, @@ -80,8 +80,8 @@ public class Timeline } .Setup(p => p.Bind( p, - dc => dc.TotalProgress.Value, - p => p.Value)), + dc => dc!.TotalProgress.Value, + pb => pb.Value)), } }; @@ -90,8 +90,8 @@ public class Timeline } .Setup(i => i.Bind( i, - dc => dc.TimelineViewModel.ParallelCommandsGroups[0].Commands, - i => i.ItemsSource)) + dc => dc!.TimelineViewModel.ParallelCommandsGroups[0].Commands, + ic => ic.ItemsSource)) } };