From edbcb956974cdcf7c3bc331118b57802e1d051a7 Mon Sep 17 00:00:00 2001 From: koal44 Date: Thu, 28 Mar 2024 19:02:29 -0700 Subject: [PATCH 01/33] Fix null analyzer complaints: CS8602, CS8618, CS8603, CS8622, IDE0031 --- src/Wpf.Ui.Demo.Mvvm/App.xaml.cs | 6 +- src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs | 6 +- .../Services/ApplicationHostService.cs | 4 +- .../ViewModels/DataViewModel.cs | 12 +-- src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj | 2 +- src/Wpf.Ui.FontMapper/FontSource.cs | 4 +- src/Wpf.Ui.FontMapper/Program.cs | 21 +++--- .../Models/Monaco/MonacoTheme.cs | 6 +- src/Wpf.Ui.Gallery/Models/NavigationCard.cs | 6 +- src/Wpf.Ui.Gallery/Models/Product.cs | 4 +- .../Services/WindowsProviderService.cs | 7 +- src/Wpf.Ui.Tray/INotifyIcon.cs | 2 +- src/Wpf.Ui.Tray/INotifyIconService.cs | 4 +- src/Wpf.Ui.Tray/Interop/Shell32.cs | 6 +- src/Wpf.Ui.Tray/NotifyIconService.cs | 6 +- src/Wpf.Ui.Tray/TrayManager.cs | 9 ++- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 75 ++++++------------- src/Wpf.Ui/Controls/DateTimeHelper.cs | 42 ++++------- .../NavigationView.Properties.cs | 11 +-- .../NavigationView/NavigationViewActivator.cs | 40 +++------- .../Controls/PasswordBox/PasswordBox.cs | 2 +- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 30 +++++--- .../Controls/TitleBar/TitleBarButton.cs | 2 +- .../LeftSplitCornerRadiusConverter.cs | 2 +- .../Converters/LeftSplitThicknessConverter.cs | 2 +- .../RightSplitCornerRadiusConverter.cs | 2 +- .../RightSplitThicknessConverter.cs | 2 +- src/Wpf.Ui/Interop/Shell32.cs | 6 +- src/Wpf.Ui/UiApplication.cs | 32 ++++---- 29 files changed, 152 insertions(+), 201 deletions(-) diff --git a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs b/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs index bf821f1b3..f48e0b1f8 100644 --- a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs +++ b/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -26,7 +26,9 @@ public partial class App private static readonly IHost _host = Host.CreateDefaultBuilder() .ConfigureAppConfiguration(c => { - c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); + var basePath = Path.GetDirectoryName(AppContext.BaseDirectory) + ?? throw new DirectoryNotFoundException("Unable to find the base directory of the application."); + c.SetBasePath(basePath); }) .ConfigureServices( (context, services) => diff --git a/src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs b/src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs index 7e437257d..0779b7a6c 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -7,7 +7,7 @@ namespace Wpf.Ui.Demo.Mvvm.Models; public class AppConfig { - public string ConfigurationsFolder { get; set; } + public string? ConfigurationsFolder { get; set; } - public string AppPropertiesFileName { get; set; } + public string? AppPropertiesFileName { get; set; } } diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs b/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs index c627bab09..bf50d2eeb 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -14,7 +14,7 @@ namespace Wpf.Ui.Demo.Mvvm.Services; public class ApplicationHostService : IHostedService { private readonly IServiceProvider _serviceProvider; - private INavigationWindow _navigationWindow; + private INavigationWindow? _navigationWindow; public ApplicationHostService(IServiceProvider serviceProvider) { diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs index c69801289..fe6e4d45f 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -14,7 +14,7 @@ public partial class DataViewModel : ObservableObject, INavigationAware private bool _isInitialized = false; [ObservableProperty] - private IEnumerable _colors; + private List _colors = new(); public void OnNavigatedTo() { @@ -27,10 +27,11 @@ public void OnNavigatedFrom() { } private void InitializeViewModel() { var random = new Random(); - var colorCollection = new List(); + Colors.Clear(); for (int i = 0; i < 8192; i++) - colorCollection.Add( + { + Colors.Add( new DataColor { Color = new SolidColorBrush( @@ -43,8 +44,7 @@ private void InitializeViewModel() ) } ); - - Colors = colorCollection; + } _isInitialized = true; } diff --git a/src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj b/src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj index 16be6fe74..32b894779 100644 --- a/src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj +++ b/src/Wpf.Ui.Extension/Wpf.Ui.Extension.csproj @@ -114,4 +114,4 @@ - + \ No newline at end of file diff --git a/src/Wpf.Ui.FontMapper/FontSource.cs b/src/Wpf.Ui.FontMapper/FontSource.cs index d3e768da2..07f91a684 100644 --- a/src/Wpf.Ui.FontMapper/FontSource.cs +++ b/src/Wpf.Ui.FontMapper/FontSource.cs @@ -1,4 +1,4 @@ -namespace Wpf.Ui.FontMapper; +namespace Wpf.Ui.FontMapper; class FontSource { @@ -6,7 +6,7 @@ class FontSource public string Description { get; private set; } public string SourcePath { get; } public string DestinationPath { get; } - public IDictionary Contents { get; private set; } + public IDictionary Contents { get; set; } = new Dictionary(); public FontSource(string name, string description, string sourcePath, string destinationPath) { diff --git a/src/Wpf.Ui.FontMapper/Program.cs b/src/Wpf.Ui.FontMapper/Program.cs index 6ffd72f41..b4c5b34f1 100644 --- a/src/Wpf.Ui.FontMapper/Program.cs +++ b/src/Wpf.Ui.FontMapper/Program.cs @@ -10,12 +10,8 @@ Console.WriteLine("Fluent System Icons Mapper"); System.Diagnostics.Debug.WriteLine("INFO | Fluent System Icons Mapper", "Wpf.Ui.FontMapper"); -var workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - -if (workingDirectory is null) -{ - throw new ArgumentNullException(nameof(workingDirectory)); -} +var workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + ?? throw new InvalidOperationException("Could not determine the working directory."); var regularIcons = new FontSource( "SymbolRegular", @@ -114,9 +110,9 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory) ) .AppendLine("// Copyright (C) Leszek Pomianowski and WPF UI Contributors.") .AppendLine("// All Rights Reserved.") - .AppendLine(String.Empty) + .AppendLine() .AppendLine("namespace Wpf.Ui.Controls;") - .AppendLine(String.Empty) + .AppendLine() .AppendLine("/// ") .AppendLine($"/// {singleFont.Description.Replace("\n", "\n/// ")}") .AppendLine("/// ") @@ -127,9 +123,9 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory) .AppendLine(" /// Actually, this icon is not empty, but makes it easier to navigate.") .AppendLine(" /// ") .AppendLine(" Empty = 0x0,") - .AppendLine(String.Empty) + .AppendLine() .AppendLine(" // Automatically generated, may contain bugs.") - .AppendLine(String.Empty); + .AppendLine(); foreach (KeyValuePair singleIcon in singleFont.Contents) { @@ -137,7 +133,7 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory) if (singleIcon.Value < 32) { _ = enumMapStringBuilder - .AppendLine(String.Empty) + .AppendLine() .AppendLine(" /// ") .AppendLine(" /// Blank icon.") .AppendLine(" /// "); @@ -148,7 +144,7 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory) _ = enumMapStringBuilder .AppendLine("}") - .AppendLine(String.Empty) + .AppendLine() .AppendLine("#pragma warning restore CS1591") .Append("\r\n"); @@ -160,6 +156,7 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory) } await File.WriteAllTextAsync(destinationPath, enumMapStringBuilder.ToString()); + Console.WriteLine($"Wrote to file \"{destinationPath}\""); } await WriteToFile(regularIcons, workingDirectory); diff --git a/src/Wpf.Ui.Gallery/Models/Monaco/MonacoTheme.cs b/src/Wpf.Ui.Gallery/Models/Monaco/MonacoTheme.cs index 7a947e9ec..d0972bab8 100644 --- a/src/Wpf.Ui.Gallery/Models/Monaco/MonacoTheme.cs +++ b/src/Wpf.Ui.Gallery/Models/Monaco/MonacoTheme.cs @@ -8,11 +8,11 @@ namespace Wpf.Ui.Gallery.Models.Monaco; [Serializable] public record MonacoTheme { - public string Base { get; init; } + public string? Base { get; init; } public bool Inherit { get; init; } - public IDictionary Rules { get; init; } + public IDictionary? Rules { get; init; } - public IDictionary Colors { get; init; } + public IDictionary? Colors { get; init; } } diff --git a/src/Wpf.Ui.Gallery/Models/NavigationCard.cs b/src/Wpf.Ui.Gallery/Models/NavigationCard.cs index 55c9ca28b..5eaa79941 100644 --- a/src/Wpf.Ui.Gallery/Models/NavigationCard.cs +++ b/src/Wpf.Ui.Gallery/Models/NavigationCard.cs @@ -9,11 +9,11 @@ namespace Wpf.Ui.Gallery.Models; public record NavigationCard { - public string Name { get; init; } + public string? Name { get; init; } public SymbolRegular Icon { get; init; } - public string Description { get; init; } + public string? Description { get; init; } - public Type PageType { get; init; } + public Type? PageType { get; init; } } diff --git a/src/Wpf.Ui.Gallery/Models/Product.cs b/src/Wpf.Ui.Gallery/Models/Product.cs index 4fed12368..2f76bc433 100644 --- a/src/Wpf.Ui.Gallery/Models/Product.cs +++ b/src/Wpf.Ui.Gallery/Models/Product.cs @@ -11,9 +11,9 @@ public class Product public int ProductCode { get; set; } - public string ProductName { get; set; } + public string? ProductName { get; set; } - public string QuantityPerUnit { get; set; } + public string? QuantityPerUnit { get; set; } public double UnitPrice { get; set; } diff --git a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs index 6195d9340..249f0af11 100644 --- a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs +++ b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs @@ -20,11 +20,8 @@ public void Show() if (!typeof(Window).IsAssignableFrom(typeof(T))) throw new InvalidOperationException($"The window class should be derived from {typeof(Window)}."); - var windowInstance = _serviceProvider.GetService() as Window; - - if (windowInstance == null) - throw new InvalidOperationException("Window is not registered as service."); - + var windowInstance = _serviceProvider.GetService() as Window + ?? throw new InvalidOperationException("Window is not registered as service."); windowInstance.Owner = Application.Current.MainWindow; windowInstance.Show(); } diff --git a/src/Wpf.Ui.Tray/INotifyIcon.cs b/src/Wpf.Ui.Tray/INotifyIcon.cs index d822713b6..1852a4bb7 100644 --- a/src/Wpf.Ui.Tray/INotifyIcon.cs +++ b/src/Wpf.Ui.Tray/INotifyIcon.cs @@ -49,7 +49,7 @@ internal interface INotifyIcon /// /// Gets or sets the menu displayed when the icon is right-clicked. /// - ContextMenu ContextMenu { get; set; } + ContextMenu? ContextMenu { get; set; } /// /// Gets or sets the value indicating whether to focus the on single left click. diff --git a/src/Wpf.Ui.Tray/INotifyIconService.cs b/src/Wpf.Ui.Tray/INotifyIconService.cs index 66a13e964..6fc0f3d51 100644 --- a/src/Wpf.Ui.Tray/INotifyIconService.cs +++ b/src/Wpf.Ui.Tray/INotifyIconService.cs @@ -32,12 +32,12 @@ public interface INotifyIconService /// /// Context menu displayed after clicking the icon. /// - ContextMenu ContextMenu { get; set; } + ContextMenu? ContextMenu { get; set; } /// /// Gets or sets the of the tray icon. /// - public ImageSource Icon { get; set; } + public ImageSource? Icon { get; set; } /// /// Tries to register the Notify Icon in the shell. diff --git a/src/Wpf.Ui.Tray/Interop/Shell32.cs b/src/Wpf.Ui.Tray/Interop/Shell32.cs index ebcd71a7a..12377b2f8 100644 --- a/src/Wpf.Ui.Tray/Interop/Shell32.cs +++ b/src/Wpf.Ui.Tray/Interop/Shell32.cs @@ -105,7 +105,7 @@ public class NOTIFYICONDATA /// 0x00000004. The szTip member is valid. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x80)] // 128 - public string szTip; + public string? szTip; /// /// The state of the icon. There are two flags that can be set independently. @@ -117,7 +117,7 @@ public class NOTIFYICONDATA public uint dwStateMask; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)] // 256 - public string szInfo; + public string? szInfo; /// /// Prior to Vista this was a union of uTimeout and uVersion. As of Vista, uTimeout has been deprecated. @@ -125,7 +125,7 @@ public class NOTIFYICONDATA public uint uVersion; // Used with Shell_NotifyIcon flag NIM_SETVERSION. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x40)] // 64 - public string szInfoTitle; + public string? szInfoTitle; public uint dwInfoFlags; diff --git a/src/Wpf.Ui.Tray/NotifyIconService.cs b/src/Wpf.Ui.Tray/NotifyIconService.cs index c4efcf659..a6d29cac8 100644 --- a/src/Wpf.Ui.Tray/NotifyIconService.cs +++ b/src/Wpf.Ui.Tray/NotifyIconService.cs @@ -29,13 +29,13 @@ public string TooltipText set => this.internalNotifyIconManager.TooltipText = value; } - public ContextMenu ContextMenu + public ContextMenu? ContextMenu { get => this.internalNotifyIconManager.ContextMenu; set => this.internalNotifyIconManager.ContextMenu = value; } - public ImageSource Icon + public ImageSource? Icon { get => this.internalNotifyIconManager.Icon; set => this.internalNotifyIconManager.Icon = value; @@ -105,7 +105,7 @@ protected virtual void OnMiddleClick() { } /// protected virtual void OnMiddleDoubleClick() { } - private void OnParentWindowClosing(object sender, CancelEventArgs e) + private void OnParentWindowClosing(object? sender, CancelEventArgs e) { this.internalNotifyIconManager.Dispose(); } diff --git a/src/Wpf.Ui.Tray/TrayManager.cs b/src/Wpf.Ui.Tray/TrayManager.cs index fea87fe21..f4dfdaa5c 100644 --- a/src/Wpf.Ui.Tray/TrayManager.cs +++ b/src/Wpf.Ui.Tray/TrayManager.cs @@ -32,6 +32,11 @@ internal static class TrayManager { public static bool Register(INotifyIcon notifyIcon) { + if (notifyIcon is null) + { + return false; + } + return Register(notifyIcon, GetParentSource()); } @@ -45,7 +50,7 @@ public static bool Register(INotifyIcon notifyIcon, Window parentWindow) return Register(notifyIcon, (HwndSource)PresentationSource.FromVisual(parentWindow)); } - public static bool Register(INotifyIcon notifyIcon, HwndSource parentSource) + public static bool Register(INotifyIcon notifyIcon, HwndSource? parentSource) { if (parentSource is null) { @@ -139,7 +144,7 @@ public static bool Unregister(INotifyIcon notifyIcon) /// /// Gets application source. /// - private static HwndSource GetParentSource() + private static HwndSource? GetParentSource() { Window mainWindow = Application.Current.MainWindow; diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 5c8ae6acb..e46b0cb42 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -35,9 +35,7 @@ namespace Wpf.Ui.Controls; public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl { protected const string ElementTextBox = "PART_TextBox"; - protected const string ElementSuggestionsPopup = "PART_SuggestionsPopup"; - protected const string ElementSuggestionsList = "PART_SuggestionsList"; /// @@ -252,17 +250,11 @@ public event TypedEventHandler - public new void Focus() + public new bool Focus() { - TextBox.Focus(); + return TextBox!.Focus(); } protected T GetTemplateChild(string name) @@ -433,16 +425,13 @@ private void TextBoxOnPreviewKeyDown(object sender, KeyEventArgs e) if (e.Key is Key.Escape) { SetCurrentValue(IsSuggestionListOpenProperty, false); - return; } if (e.Key is Key.Enter) { SetCurrentValue(IsSuggestionListOpenProperty, false); - - OnQuerySubmitted(TextBox.Text); - + OnQuerySubmitted(TextBox!.Text); return; } @@ -478,9 +467,9 @@ private void TextBoxOnTextChanged(object sender, TextChangedEventArgs e) changeReason = AutoSuggestionBoxTextChangeReason.ProgrammaticChange; } - OnTextChanged(changeReason, TextBox.Text); + OnTextChanged(changeReason, TextBox!.Text); - SuggestionsList.SetCurrentValue(Selector.SelectedItemProperty, null); + SuggestionsList!.SetCurrentValue(Selector.SelectedItemProperty, null); if (changeReason is not AutoSuggestionBoxTextChangeReason.UserInput) { @@ -509,12 +498,12 @@ private void SuggestionsListOnPreviewKeyDown(object sender, KeyEventArgs e) SetCurrentValue(IsSuggestionListOpenProperty, false); - OnSelectedChanged(SuggestionsList.SelectedItem); + OnSelectedChanged(SuggestionsList!.SelectedItem); } private void SuggestionsListOnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { - if (SuggestionsList.SelectedItem is not null) + if (SuggestionsList!.SelectedItem is not null) { return; } @@ -529,7 +518,7 @@ private void SuggestionsListOnPreviewMouseLeftButtonUp(object sender, MouseButto private void SuggestionsListOnSelectionChanged(object sender, SelectionChangedEventArgs e) { - if (SuggestionsList.SelectedItem is null) + if (SuggestionsList!.SelectedItem is null) { return; } @@ -565,58 +554,40 @@ private void UpdateTexBoxTextAfterSelection(object selectedObj) { _changingTextAfterSuggestionChosen = true; - TextBox.SetCurrentValue(System.Windows.Controls.TextBox.TextProperty, GetStringFromObj(selectedObj)); + TextBox!.SetCurrentValue(System.Windows.Controls.TextBox.TextProperty, GetStringFromObj(selectedObj)); _changingTextAfterSuggestionChosen = false; } private void DefaultFiltering(string text) { - if (String.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(text)) { SetCurrentValue(ItemsSourceProperty, OriginalItemsSource); - return; } - var suitableItems = new List(); - var splitText = text.ToLower().Split(' '); - - for (var i = 0; i < OriginalItemsSource.Count; i++) - { - var item = OriginalItemsSource[i]; - var itemText = GetStringFromObj(item); - - var found = splitText.All(key => itemText.ToLower().Contains(key)); - - if (found) + var splitText = text.ToLowerInvariant().Split(' '); + var suitableItems = OriginalItemsSource + .Cast() + .Where(item => { - suitableItems.Add(item); - } - } + var itemText = GetStringFromObj(item)?.ToLowerInvariant(); + return splitText.All(key => itemText?.Contains(key) ?? false); + }) + .ToList(); SetCurrentValue(ItemsSourceProperty, suitableItems); } private string? GetStringFromObj(object obj) { - var text = String.Empty; - - if (!String.IsNullOrEmpty(DisplayMemberPath)) - { - //Maybe it needs some optimization? - if (obj.GetType().GetProperty(DisplayMemberPath)?.GetValue(obj) is string value) - { - text = value; - } - } - - if (String.IsNullOrEmpty(text)) - { - text = obj as String ?? obj.ToString(); - } + // uses reflection. maybe it needs some optimization? + var displayMemberPathText = !string.IsNullOrEmpty(DisplayMemberPath) && obj.GetType().GetProperty(DisplayMemberPath)?.GetValue(obj) is string value + ? value + : null; - return text; + return displayMemberPathText ?? obj as string ?? obj.ToString(); } private static void TextPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Wpf.Ui/Controls/DateTimeHelper.cs b/src/Wpf.Ui/Controls/DateTimeHelper.cs index 7dfb2737d..9e49a13f8 100644 --- a/src/Wpf.Ui/Controls/DateTimeHelper.cs +++ b/src/Wpf.Ui/Controls/DateTimeHelper.cs @@ -72,7 +72,7 @@ internal static class DateTimeHelper public static int CompareDays(DateTime dt1, DateTime dt2) { - return DateTime.Compare(DiscardTime(dt1).Value, DiscardTime(dt2).Value); + return DateTime.Compare(DiscardTime(dt1), DiscardTime(dt2)); } public static int CompareYearMonth(DateTime dt1, DateTime dt2) @@ -90,14 +90,9 @@ public static DateTime DiscardDayTime(DateTime d) return new DateTime(d.Year, d.Month, 1, 0, 0, 0); } - public static DateTime? DiscardTime(DateTime? d) + public static DateTime DiscardTime(DateTime d) { - if (d is null) - { - return null; - } - - return d.Value.Date; + return d.Date; } public static int EndOfDecade(DateTime date) @@ -117,31 +112,24 @@ internal static DateTimeFormatInfo GetDateFormat(CultureInfo culture) return culture.DateTimeFormat; } - GregorianCalendar foundCal = default!; - DateTimeFormatInfo dtfi = default!; - + GregorianCalendar? foundCal = null; foreach (System.Globalization.Calendar cal in culture.OptionalCalendars) { - if (cal is not GregorianCalendar) - { - continue; - } - - // Return the first Gregorian calendar with CalendarType == Localized - // Otherwise return the first Gregorian calendar - if (foundCal is null) - { - foundCal = cal as GregorianCalendar; - } - - if (((GregorianCalendar)cal).CalendarType == GregorianCalendarTypes.Localized) + if (cal is GregorianCalendar gregorianCalendar) { - foundCal = cal as GregorianCalendar; - - break; + // Return the first Gregorian calendar with CalendarType == Localized + // Otherwise return the first Gregorian calendar + foundCal ??= gregorianCalendar; + + if (gregorianCalendar.CalendarType == GregorianCalendarTypes.Localized) + { + foundCal = gregorianCalendar; + break; + } } } + DateTimeFormatInfo dtfi; if (foundCal == null) { // if there are no GregorianCalendars in the OptionalCalendars list, use the invariant dtfi diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index b3fbc27da..8a9b9872b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -615,13 +615,10 @@ private static void IsPaneOpenChangedCallback(DependencyObject d, DependencyProp navigationView.CloseNavigationViewItemMenus(); - if (navigationView.TitleBar is not null) - { - navigationView.TitleBar.SetCurrentValue( - MarginProperty, - navigationView.IsPaneOpen ? s_titleBarPaneOpenMargin : s_titleBarPaneCompactMargin - ); - } + navigationView.TitleBar?.SetCurrentValue( + MarginProperty, + navigationView.IsPaneOpen ? s_titleBarPaneOpenMargin : s_titleBarPaneCompactMargin + ); UpdateVisualState(navigationView); } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs index 3ca08e37d..b588de91f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs @@ -52,15 +52,10 @@ internal static class NavigationViewActivator } else if (parameterlessCount == 0 && parameterfullCount > 0) { - ConstructorInfo? selectedCtor = FitBestConstructor(pageConstructors, dataContext); - - if (selectedCtor == null) - { - throw new InvalidOperationException( + ConstructorInfo? selectedCtor = FitBestConstructor(pageConstructors, dataContext) + ?? throw new InvalidOperationException( $"The {pageType} page does not have a parameterless constructor or the required services have not been configured for dependency injection. Use the static {nameof(ControlsServices)} class to initialize the GUI library with your service provider. If you are using {typeof(IPageService)} do not navigate initially and don't use Cache or Precache." ); - } - instance = InvokeElementConstructor(selectedCtor, dataContext); SetDataContext(instance, dataContext); @@ -80,15 +75,10 @@ internal static class NavigationViewActivator } } - ConstructorInfo? emptyConstructor = FindParameterlessConstructor(pageType); - - if (emptyConstructor == null) - { - throw new InvalidOperationException( + var emptyConstructor = FindParameterlessConstructor(pageType) + ?? throw new InvalidOperationException( $"The {pageType} page does not have a parameterless constructor. If you are using {typeof(IPageService)} do not navigate initially and don't use Cache or Precache." ); - } - instance = emptyConstructor.Invoke(null) as FrameworkElement; SetDataContext(instance, dataContext); @@ -112,27 +102,19 @@ internal static class NavigationViewActivator /// /// /// - private static ConstructorInfo? FitBestConstructor( - ConstructorInfo[] parameterfullCtors, - object? dataContext - ) + private static ConstructorInfo? FitBestConstructor(ConstructorInfo[] parameterfullCtors, object? dataContext) { return parameterfullCtors .Select(ctor => { var parameters = ctor.GetParameters(); - var argumentResolution = parameters.Select(prm => - { - var resolved = ResolveConstructorParameter(prm.ParameterType, dataContext); - return resolved != null; - }); - var fullyResolved = argumentResolution.All(resolved => resolved == true); - var score = fullyResolved ? parameters.Length : 0; - - return score == 0 ? null : new { Constructor = ctor, Score = score }; + int score = parameters.Aggregate(0, (acc, prm) => + acc + (ResolveConstructorParameter(prm.ParameterType, dataContext) != null ? 1 : 0)); + score = score != parameters.Length ? 0 : score; + return new { Constructor = ctor, Score = score }; }) - .Where(cs => cs != null) - .OrderBy(cs => cs.Score) + .Where(cs => cs.Score != 0) + .OrderByDescending(cs => cs.Score) .FirstOrDefault() ?.Constructor; } diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index e2bbbab26..bb5c182f0 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -186,7 +186,7 @@ protected virtual void OnPasswordRevealModeChanged() /// /// Sender of the click event. /// Additional parameters. - protected override void OnTemplateButtonClick(string parameter) + protected override void OnTemplateButtonClick(string? parameter) { #if DEBUG System.Diagnostics.Debug.WriteLine( diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index a2b4e9010..1846948ec 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -563,7 +563,7 @@ private void MaximizeWindow() } } - private void OnParentWindowStateChanged(object sender, EventArgs e) + private void OnParentWindowStateChanged(object? sender, EventArgs e) { if (IsMaximized != (_currentWindow.WindowState == WindowState.Maximized)) IsMaximized = _currentWindow.WindowState == WindowState.Maximized; @@ -598,14 +598,18 @@ private void OnTemplateButtonClick(TitleBarButtonType buttonType) /// /// Listening window hooks after rendering window content to SizeToContent support /// - private void OnWindowContentRendered(object sender, EventArgs e) + private void OnWindowContentRendered(object? sender, EventArgs e) { - var window = (Window)sender; + if (sender is not Window window) + { + return; + } + window.ContentRendered -= OnWindowContentRendered; var handle = new WindowInteropHelper(window).Handle; - var windowSource = - HwndSource.FromHwnd(handle) ?? throw new ArgumentNullException("Window source is null"); + var windowSource = HwndSource.FromHwnd(handle) + ?? throw new ArgumentNullException("Window source is null"); windowSource.AddHook(HwndSourceHook); } @@ -674,6 +678,12 @@ or User32.WM.NCLBUTTONUP private void TitleBar_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { var point = PointToScreen(e.GetPosition(this)); + + if (dpiScale is null) + { + throw new InvalidOperationException("dpiScale is not initialized."); + } + SystemCommands.ShowSystemMenu( parentWindow as Window, new Point(point.X / dpiScale.Value.DpiScaleX, point.Y / dpiScale.Value.DpiScaleY) @@ -683,11 +693,13 @@ private void TitleBar_MouseRightButtonUp(object sender, MouseButtonEventArgs e) private T GetTemplateChild(string name) where T : DependencyObject { - var element = base.GetTemplateChild(name); + var element = GetTemplateChild(name); - if (element is null) - throw new ArgumentNullException($"{name} is null"); + if (element is not T tElement) + { + throw new InvalidOperationException($"Template part '{name}' is not found or is not of type {typeof(T)}"); + } - return (T)element; + return tElement; } } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index 1b2d37020..abd02bd0e 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -121,7 +121,7 @@ private void TitleBarButton_Loaded(object sender, RoutedEventArgs e) .AddValueChanged(this, OnButtonsForegroundChanged); } - private void OnButtonsForegroundChanged(object sender, EventArgs e) + private void OnButtonsForegroundChanged(object? sender, EventArgs e) { SetCurrentValue( RenderButtonsForegroundProperty, diff --git a/src/Wpf.Ui/Converters/LeftSplitCornerRadiusConverter.cs b/src/Wpf.Ui/Converters/LeftSplitCornerRadiusConverter.cs index 0ab47f47e..75bc1b553 100644 --- a/src/Wpf.Ui/Converters/LeftSplitCornerRadiusConverter.cs +++ b/src/Wpf.Ui/Converters/LeftSplitCornerRadiusConverter.cs @@ -13,7 +13,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture { if (value is not CornerRadius cornerRadius) { - return value; + return default(CornerRadius); } return new CornerRadius(cornerRadius.TopLeft, 0, 0, cornerRadius.BottomLeft); diff --git a/src/Wpf.Ui/Converters/LeftSplitThicknessConverter.cs b/src/Wpf.Ui/Converters/LeftSplitThicknessConverter.cs index 374c20445..d6aad38cd 100644 --- a/src/Wpf.Ui/Converters/LeftSplitThicknessConverter.cs +++ b/src/Wpf.Ui/Converters/LeftSplitThicknessConverter.cs @@ -13,7 +13,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture { if (value is not Thickness thickness) { - return value; + return default(Thickness); } return new Thickness(thickness.Left, thickness.Top, 0, thickness.Bottom); diff --git a/src/Wpf.Ui/Converters/RightSplitCornerRadiusConverter.cs b/src/Wpf.Ui/Converters/RightSplitCornerRadiusConverter.cs index 60ab75434..032cb3456 100644 --- a/src/Wpf.Ui/Converters/RightSplitCornerRadiusConverter.cs +++ b/src/Wpf.Ui/Converters/RightSplitCornerRadiusConverter.cs @@ -13,7 +13,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture { if (value is not CornerRadius cornerRadius) { - return value; + return default(CornerRadius); } return new CornerRadius(0, cornerRadius.TopRight, cornerRadius.BottomRight, 0); diff --git a/src/Wpf.Ui/Converters/RightSplitThicknessConverter.cs b/src/Wpf.Ui/Converters/RightSplitThicknessConverter.cs index a99998df4..c6ce9ebf3 100644 --- a/src/Wpf.Ui/Converters/RightSplitThicknessConverter.cs +++ b/src/Wpf.Ui/Converters/RightSplitThicknessConverter.cs @@ -13,7 +13,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture { if (value is not Thickness thickness) { - return value; + return default(Thickness); } return new Thickness(thickness.Left, thickness.Top, thickness.Right, thickness.Bottom); diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index 3f6db99b1..c777c2421 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -113,7 +113,7 @@ public class NOTIFYICONDATA /// 0x00000004. The szTip member is valid. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x80)] // 128 - public string szTip; + public string? szTip; /// /// The state of the icon. There are two flags that can be set independently. @@ -125,7 +125,7 @@ public class NOTIFYICONDATA public uint dwStateMask; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)] // 256 - public string szInfo; + public string? szInfo; /// /// Prior to Vista this was a union of uTimeout and uVersion. As of Vista, uTimeout has been deprecated. @@ -133,7 +133,7 @@ public class NOTIFYICONDATA public uint uVersion; // Used with Shell_NotifyIcon flag NIM_SETVERSION. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x40)] // 64 - public string szInfoTitle; + public string? szInfoTitle; public uint dwInfoFlags; diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index fb223e6f7..8b6ff9326 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -10,13 +10,13 @@ namespace Wpf.Ui; /// public class UiApplication { - private static UiApplication _uiApplication; + private static UiApplication? _uiApplication; - private readonly Application _application; + private readonly Application? _application; - private ResourceDictionary _resources; + private ResourceDictionary? _resources; - private Window _mainWindow; + private Window? _mainWindow; /// /// Initializes a new instance of the class. @@ -34,17 +34,25 @@ public UiApplication(Application application) /// /// Gets the current application. /// - public static UiApplication Current => GetUiApplication(); + public static UiApplication Current + { + get + { + _uiApplication ??= new UiApplication(Application.Current); + + return _uiApplication; + } + } /// /// Gets or sets the application's main window. /// - public Window MainWindow + public Window? MainWindow { get => _application?.MainWindow ?? _mainWindow; set { - if (_application is not null) + if (_application != null) { _application.MainWindow = value; } @@ -77,6 +85,7 @@ public ResourceDictionary Resources return _application?.Resources ?? _resources; } + set { if (_application is not null) @@ -104,13 +113,4 @@ public void Shutdown() _application?.Shutdown(); } - private static UiApplication GetUiApplication() - { - if (_uiApplication is null) - { - _uiApplication = new UiApplication(Application.Current); - } - - return _uiApplication; - } } From ca565617a505d303412429a2f39c61cbb5cc1b32 Mon Sep 17 00:00:00 2001 From: koal44 Date: Thu, 28 Mar 2024 19:03:25 -0700 Subject: [PATCH 02/33] Hide warnings related to IDE0008 related to using `var` keyword --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 38c62724d..2bbf5d745 100644 --- a/.editorconfig +++ b/.editorconfig @@ -95,7 +95,7 @@ dotnet_style_readonly_field = true:warning # var preferences csharp_style_var_elsewhere = false:warning -csharp_style_var_for_built_in_types = false:warning +csharp_style_var_for_built_in_types = false:none csharp_style_var_when_type_is_apparent = false:warning # Expression-bodied members From 750a6e892e48f446b3925fb377fefebaef9117fb Mon Sep 17 00:00:00 2001 From: koal44 Date: Thu, 28 Mar 2024 23:22:58 -0700 Subject: [PATCH 03/33] Removed Coersion logic from IconSourceElementConverter, and placed in IconElement and IcounSourceElement classes instead --- .../BreadcrumbBar/BreadcrumbBarItem.cs | 2 +- src/Wpf.Ui/Controls/Button/Button.cs | 12 +++--- src/Wpf.Ui/Controls/CardAction/CardAction.cs | 2 +- .../Controls/CardExpander/CardExpander.cs | 2 +- .../Controls/IconElement/IconElement.cs | 18 ++++++++- .../IconElement/IconElementConverter.cs | 2 +- .../Controls/IconElement/IconSourceElement.cs | 7 +++- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs | 2 +- .../NavigationView/NavigationViewItem.cs | 2 +- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 2 +- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 2 +- .../Converters/IconSourceElementConverter.cs | 37 ++++--------------- 12 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index d81c8059a..25d80539f 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -23,7 +23,7 @@ public class BreadcrumbBarItem : System.Windows.Controls.ContentControl nameof(Icon), typeof(IconElement), typeof(BreadcrumbBarItem), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index 8da7aab40..1cfdcb9fa 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -38,7 +38,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC nameof(Icon), typeof(IconElement), typeof(Button), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// @@ -111,12 +111,10 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC nameof(CornerRadius), typeof(CornerRadius), typeof(Button), - (PropertyMetadata) - new FrameworkPropertyMetadata( - (object)new CornerRadius(), - FrameworkPropertyMetadataOptions.AffectsMeasure - | FrameworkPropertyMetadataOptions.AffectsRender - ) + new FrameworkPropertyMetadata( + default(CornerRadius), + FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender + ) ); /// diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index 18fcdecf3..9eabc789c 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -35,7 +35,7 @@ public class CardAction : System.Windows.Controls.Primitives.ButtonBase nameof(Icon), typeof(IconElement), typeof(CardAction), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 6a620655b..5846ffd57 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -22,7 +22,7 @@ public class CardExpander : System.Windows.Controls.Expander nameof(Icon), typeof(IconElement), typeof(CardExpander), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/IconElement/IconElement.cs b/src/Wpf.Ui/Controls/IconElement/IconElement.cs index 978d703f5..d1d0f3def 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElement.cs @@ -90,7 +90,23 @@ protected override Size ArrangeOverride(Size finalSize) { EnsureLayoutRoot(); - _layoutRoot!.Arrange(new Rect(new Point(), finalSize)); + _layoutRoot!.Arrange(new Rect(default, finalSize)); return finalSize; } + + /// + /// Coerces the value of an Icon dependency property, allowing the use of either IconElement or IconSourceElement. + /// + /// The dependency object (unused). + /// The value to be coerced. + /// An IconElement, either directly or derived from an IconSourceElement. + public static object? Coerce(DependencyObject _, object baseValue) + { + return baseValue switch + { + IconSourceElement iconSourceElement => iconSourceElement.CreateIconElement(), + IconElement or null => baseValue, + _ => throw new ArgumentException(nameof(baseValue), $"Expected either '{typeof(IconSourceElement)}' or '{typeof(IconElement)}' but got '{baseValue.GetType()}'"), + }; + } } diff --git a/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs b/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs index 30b962965..6404494d6 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs @@ -9,7 +9,7 @@ namespace Wpf.Ui.Controls; /// -/// Tries to convert and to . +/// Tries to convert and to . /// public class IconElementConverter : TypeConverter { diff --git a/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs b/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs index 906ef1f19..d45ec388f 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs @@ -37,6 +37,11 @@ public IconSource? IconSource protected override UIElement InitializeChildren() { // TODO: Come up with an elegant solution - throw new InvalidOperationException($"Use {nameof(IconSourceElementConverter)} class."); + throw new InvalidOperationException($"Use {nameof(CreateIconElement)}"); + } + + public IconElement? CreateIconElement() + { + return IconSource?.CreateIconElement(); } } diff --git a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs index 83b970788..c79293f75 100644 --- a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs +++ b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs @@ -16,7 +16,7 @@ public class InfoBadge : System.Windows.Controls.Control nameof(Icon), typeof(IconElement), typeof(InfoBadge), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index fcaae6999..6f95b82f1 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -98,7 +98,7 @@ public class NavigationViewItem nameof(Icon), typeof(IconElement), typeof(NavigationViewItem), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index 376b213b5..8e4d96b56 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -86,7 +86,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl nameof(Icon), typeof(IconElement), typeof(Snackbar), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index c528942f4..513511573 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -25,7 +25,7 @@ public class TextBox : System.Windows.Controls.TextBox nameof(Icon), typeof(IconElement), typeof(TextBox), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + new PropertyMetadata(null, null, IconElement.Coerce) ); /// diff --git a/src/Wpf.Ui/Converters/IconSourceElementConverter.cs b/src/Wpf.Ui/Converters/IconSourceElementConverter.cs index 58e30de06..bd7877a66 100644 --- a/src/Wpf.Ui/Converters/IconSourceElementConverter.cs +++ b/src/Wpf.Ui/Converters/IconSourceElementConverter.cs @@ -21,9 +21,14 @@ public class IconSourceElementConverter : IValueConverter /// The converter parameter. /// The culture to use in the converter. /// The converted . - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - return ConvertToIconElement(value); + if (value is IconSourceElement iconSourceElement) + { + return iconSourceElement.CreateIconElement(); + } + + return value; } /// @@ -38,30 +43,4 @@ public object ConvertBack(object? value, Type targetType, object? parameter, Cul { throw new NotImplementedException(); } - - /// - /// Converts a value to an . - /// - /// The dependency object (not used). - /// The base value to convert. - /// The converted IconElement. - public static object ConvertToIconElement(DependencyObject _, object baseValue) - { - return ConvertToIconElement(baseValue); - } - - private static object ConvertToIconElement(object value) - { - if (value is not IconSourceElement iconSourceElement) - { - return value; - } - - if (iconSourceElement.IconSource is null) - { - throw new ArgumentException(nameof(iconSourceElement.IconSource)); - } - - return iconSourceElement.IconSource.CreateIconElement(); - } -} +} \ No newline at end of file From c17bc3995f38254191edcf53f91634ce99cef0a7 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 09:43:21 -0700 Subject: [PATCH 04/33] Cleaning single-line warnings: SA1005 - Removed commented-out Toolbox attributes - Replaced single-line commented-out code with multi-line --- .../Utilities/ThemeUtilities.cs | 1 + src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 2 - src/Wpf.Ui.Tray/Interop/User32.cs | 4 +- src/Wpf.Ui/Controls/Anchor/Anchor.cs | 5 +- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 2 - src/Wpf.Ui/Controls/Badge/Badge.cs | 2 - .../BreadcrumbBar/BreadcrumbBarItem.cs | 2 - src/Wpf.Ui/Controls/CardAction/CardAction.cs | 5 -- .../Controls/CardExpander/CardExpander.cs | 2 - .../Controls/ContentDialog/ContentDialog.cs | 4 +- src/Wpf.Ui/Controls/DateTimeHelper.cs | 1 - .../Controls/DropDownButton/DropDownButton.cs | 2 - src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs | 2 - src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 7 +- .../NavigationView.Navigation.cs | 29 ++++--- .../NavigationViewContentPresenter.cs | 4 +- .../NavigationView/NavigationViewItem.cs | 2 - src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 21 +++-- .../Controls/PasswordBox/PasswordBox.cs | 8 +- .../Controls/ProgressRing/ProgressRing.cs | 3 - .../Controls/RatingControl/RatingControl.cs | 17 ++--- src/Wpf.Ui/Controls/SymbolFilled.cs | 1 - src/Wpf.Ui/Controls/SymbolRegular.cs | 1 - src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 6 +- .../Controls/TitleBar/TitleBarButton.cs | 4 +- src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs | 76 +++++++++---------- src/Wpf.Ui/Controls/TypedEventHandler.cs | 1 - .../VirtualizingGridView.cs | 2 +- .../VirtualizingItemsControl.cs | 4 +- .../VirtualizingWrapPanel.cs | 4 +- src/Wpf.Ui/Input/RelayCommand{T}.cs | 4 +- src/Wpf.Ui/Interop/Libraries.cs | 55 ++++++-------- src/Wpf.Ui/Interop/Shell32.cs | 4 +- src/Wpf.Ui/Interop/UxTheme.cs | 8 +- src/Wpf.Ui/UiApplication.cs | 1 - src/Wpf.Ui/Win32/Utilities.cs | 2 + 36 files changed, 121 insertions(+), 177 deletions(-) diff --git a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs index fe37e05ce..66b134f24 100644 --- a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs +++ b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs @@ -31,6 +31,7 @@ public static void ApplyTheme(this FrameworkElement frameworkElement) { ApplicationThemeManager.Changed += themeChanged; } + frameworkElement.Loaded += (s, e) => { ApplicationThemeManager.Changed += themeChanged; diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 0c187ef16..b3d00041c 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -28,8 +28,6 @@ namespace Wpf.Ui.Tray.Controls; /// </tray:NotifyIcon> /// /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(NotifyIcon), "NotifyIcon.bmp")] public class NotifyIcon : System.Windows.FrameworkElement { private readonly Wpf.Ui.Tray.Internal.InternalNotifyIconManager internalNotifyIconManager; diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs index 86397e655..57dd7f598 100644 --- a/src/Wpf.Ui.Tray/Interop/User32.cs +++ b/src/Wpf.Ui.Tray/Interop/User32.cs @@ -511,7 +511,7 @@ public enum WM TABLET_DEFBASE = 0x02C0, - //WM_TABLET_MAXOFFSET = 0x20, + /*WM_TABLET_MAXOFFSET = 0x20,*/ TABLET_ADDED = TABLET_DEFBASE + 8, TABLET_DELETED = TABLET_DEFBASE + 9, @@ -562,7 +562,7 @@ public enum WM /// This is the hard-coded message value used by WinForms for Shell_NotifyIcon. /// It's relatively safe to reuse. /// - TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024 + TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024 APP = 0x8000, } diff --git a/src/Wpf.Ui/Controls/Anchor/Anchor.cs b/src/Wpf.Ui/Controls/Anchor/Anchor.cs index 033626ee0..0e88c29cc 100644 --- a/src/Wpf.Ui/Controls/Anchor/Anchor.cs +++ b/src/Wpf.Ui/Controls/Anchor/Anchor.cs @@ -2,8 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - - +// - // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/anchor // ReSharper disable once CheckNamespace @@ -18,6 +17,4 @@ namespace Wpf.Ui.Controls; /// NavigateUri="https://dev.lepo.co/" /> /// /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(Anchor), "Anchor.bmp")] public class Anchor : Wpf.Ui.Controls.HyperlinkButton { } diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index e46b0cb42..4c9dd12fe 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -27,8 +27,6 @@ namespace Wpf.Ui.Controls; /// </ui:AutoSuggestBox> /// /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(AutoSuggestBox), "AutoSuggestBox.bmp")] [TemplatePart(Name = ElementTextBox, Type = typeof(TextBox))] [TemplatePart(Name = ElementSuggestionsPopup, Type = typeof(Popup))] [TemplatePart(Name = ElementSuggestionsList, Type = typeof(ListView))] diff --git a/src/Wpf.Ui/Controls/Badge/Badge.cs b/src/Wpf.Ui/Controls/Badge/Badge.cs index 2906ee02f..4236d28d8 100644 --- a/src/Wpf.Ui/Controls/Badge/Badge.cs +++ b/src/Wpf.Ui/Controls/Badge/Badge.cs @@ -18,8 +18,6 @@ namespace Wpf.Ui.Controls; /// </ui:Badge> /// /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(Badge), "Badge.bmp")] public class Badge : System.Windows.Controls.ContentControl, IAppearanceControl { /// diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index 25d80539f..d3067b1a3 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -4,8 +4,6 @@ // All Rights Reserved. // Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. - using Wpf.Ui.Converters; // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index 9eabc789c..b00720731 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -11,11 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Inherited from the interactive card styled according to Fluent Design. /// -//#if NETFRAMEWORK -// //[ToolboxBitmap(typeof(Button))] -//#endif -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(CardAction), "CardAction.bmp")] public class CardAction : System.Windows.Controls.Primitives.ButtonBase { /// diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 5846ffd57..4e3df62cc 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Inherited from the control which can hide the collapsible content. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(CardExpander), "CardExpander.bmp")] public class CardExpander : System.Windows.Controls.Expander { /// diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 5d72a436f..9a7439951 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -720,7 +720,7 @@ private void ResizeWidth(UIElement element) if (DialogHeight > DialogMaxHeight) { DialogMaxHeight = DialogHeight; - //Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogHeight > DialogMaxHeight after resizing width!"); + /*Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogHeight > DialogMaxHeight after resizing width!");*/ } } @@ -737,7 +737,7 @@ private void ResizeHeight(UIElement element) if (DialogWidth > DialogMaxWidth) { DialogMaxWidth = DialogWidth; - //Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogWidth > DialogMaxWidth after resizing height!"); + /*Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogWidth > DialogMaxWidth after resizing height!");*/ } } diff --git a/src/Wpf.Ui/Controls/DateTimeHelper.cs b/src/Wpf.Ui/Controls/DateTimeHelper.cs index 9e49a13f8..61c6a815d 100644 --- a/src/Wpf.Ui/Controls/DateTimeHelper.cs +++ b/src/Wpf.Ui/Controls/DateTimeHelper.cs @@ -6,7 +6,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System.Diagnostics; using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs index 847fa463f..aa5923235 100644 --- a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs +++ b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs @@ -3,8 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// ReSharper disable once CheckNamespace - using System.Windows.Controls; // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs index 14a48f70c..d308e2536 100644 --- a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Represents a text element containing an icon glyph. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(SymbolIcon), "SymbolIcon.bmp")] public class SymbolIcon : FontIcon { /// diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 3978011c5..d6eccc470 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -13,8 +13,6 @@ namespace Wpf.Ui.Controls; /// /// Customized window for notifications. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(MessageBox), "MessageBox.bmp")] public class MessageBox : System.Windows.Window { #region Static properties @@ -361,7 +359,7 @@ protected virtual void ResizeToContentSize(UIElement rootElement) { Size desiredSize = rootElement.DesiredSize; - //left and right margin + // left and right margin const double margin = 12.0 * 2; Width = desiredSize.Width + margin; @@ -383,8 +381,7 @@ protected override void OnClosing(CancelEventArgs e) protected virtual void CenterWindowOnScreen() { - //TODO MessageBox should be displayed on the window on which the application - + // TODO: MessageBox should be displayed on the window on which the application double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 4db2ffe56..47029026e 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -2,9 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - // Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. using System.Collections.ObjectModel; using System.Diagnostics; @@ -115,19 +113,19 @@ public virtual bool GoForward() { throw new NotImplementedException(); - //if (Journal.Count <= 1) - //{ - // return false; - //} + /*if (Journal.Count <= 1) + { + return false; + } - //_currentIndexInJournal += 1; + _currentIndexInJournal += 1; - //if (_currentIndexInJournal > Journal.Count - 1) - //{ - // return false; - //} + if (_currentIndexInJournal > Journal.Count - 1) + { + return false; + } - //return Navigate(Journal[_currentIndexInJournal]); + return Navigate(Journal[_currentIndexInJournal]);*/ } /// @@ -345,8 +343,8 @@ System.Windows.Navigation.NavigationEventArgs e _ = frame.RemoveBackEntry(); - //var replaced = 1; - //((NavigationViewContentPresenter)sender).JournalOwnership = + /*var replaced = 1; + ((NavigationViewContentPresenter)sender).JournalOwnership =*/ } #region Navigation stack methods @@ -458,8 +456,7 @@ private void AddToNavigationStackHistory(INavigationViewItem viewItem) int arrayLength = NavigationStack.Count - 1 - startIndex; INavigationViewItem[] array; - //Initializing an array every time well... not an ideal - + // OPTIMIZATION: Initializing an array every time well... not an ideal #if NET6_0_OR_GREATER array = System.Buffers.ArrayPool.Shared.Rent(arrayLength); #else diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index ea46fc8a6..fbbecb01c 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -2,9 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - // Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. using System.Windows.Controls; using System.Windows.Input; @@ -130,7 +128,7 @@ protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); - //I didn't understand something, but why is it necessary? + // REVIEW: I didn't understand something, but why is it necessary? Unloaded += static (sender, _) => { if (sender is NavigationViewContentPresenter navigator) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index 6f95b82f1..cf8c737f3 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -19,8 +19,6 @@ namespace Wpf.Ui.Controls; /// Represents the container for an item in a NavigationView control. /// When needed, it can be used as a normal button with a action. /// -//[ToolboxItem(true)] -//[System.Drawing.ToolboxBitmap(typeof(NavigationViewItem), "NavigationViewItem.bmp")] [TemplatePart(Name = TemplateElementChevronGrid, Type = typeof(Grid))] public class NavigationViewItem : System.Windows.Controls.Primitives.ButtonBase, diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index 208954d9c..caed296f0 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -2,7 +2,6 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - // This Source Code is partially based on the source code provided by the .NET Foundation. using System.Windows.Data; @@ -19,8 +18,6 @@ namespace Wpf.Ui.Controls; /// /// Represents a control that can be used to display and edit numbers. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(NumberBox), "NumberBox.bmp")] public class NumberBox : Wpf.Ui.Controls.TextBox { private bool _valueUpdating; @@ -332,17 +329,17 @@ protected override void OnLostFocus(RoutedEventArgs e) ValidateInput(); } - /// - //protected override void OnTextChanged(System.Windows.Controls.TextChangedEventArgs e) - //{ - // base.OnTextChanged(e); + /*/// + protected override void OnTextChanged(System.Windows.Controls.TextChangedEventArgs e) + { + base.OnTextChanged(e); - // //if (new string[] { ",", ".", " " }.Any(s => Text.EndsWith(s))) - // // return; + //if (new string[] { ",", ".", " " }.Any(s => Text.EndsWith(s))) + // return; - // //if (!_textUpdating) - // // UpdateValueToText(); - //} + //if (!_textUpdating) + // UpdateValueToText(); + }*/ /// protected override void OnTemplateChanged( diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index bb5c182f0..ea14972fd 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -9,11 +9,9 @@ namespace Wpf.Ui.Controls; // TODO: This is an initial implementation and requires the necessary corrections, tests and adjustments. - -/** - * TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true - * PasswordProperty always contains raw password - */ +// - +// TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true +// PasswordProperty always contains raw password /// /// The modified password control. diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index 2efb52761..a4f437ee0 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -2,7 +2,6 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/progress-ring using Brush = System.Windows.Media.Brush; @@ -14,8 +13,6 @@ namespace Wpf.Ui.Controls; /// /// Rotating loading ring. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(ProgressRing), "ProgressRing.bmp")] public class ProgressRing : System.Windows.Controls.Control { /// diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index be1285236..b4b6e69d0 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Displays the rating scale with interactions. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(RatingControl), "RatingControl.bmp")] [TemplatePart(Name = "PART_Star1", Type = typeof(SymbolIcon))] [TemplatePart(Name = "PART_Star2", Type = typeof(SymbolIcon))] [TemplatePart(Name = "PART_Star3", Type = typeof(SymbolIcon))] @@ -28,20 +26,15 @@ private enum StarValue } private const double MaxValue = 5.0D; - private const double MinValue = 0.0D; - private const int OffsetTolerance = 8; - private static readonly SymbolRegular StarSymbol = SymbolRegular.Star28; - private static readonly SymbolRegular StarHalfSymbol = SymbolRegular.StarHalf28; - - private SymbolIcon? _symbolIconStarOne, - _symbolIconStarTwo, - _symbolIconStarThree, - _symbolIconStarFour, - _symbolIconStarFive; + private SymbolIcon? _symbolIconStarOne; + private SymbolIcon? _symbolIconStarTwo; + private SymbolIcon? _symbolIconStarThree; + private SymbolIcon? _symbolIconStarFour; + private SymbolIcon? _symbolIconStarFive; /// /// Property for . diff --git a/src/Wpf.Ui/Controls/SymbolFilled.cs b/src/Wpf.Ui/Controls/SymbolFilled.cs index 87ad4df24..99755c424 100644 --- a/src/Wpf.Ui/Controls/SymbolFilled.cs +++ b/src/Wpf.Ui/Controls/SymbolFilled.cs @@ -18,7 +18,6 @@ public enum SymbolFilled Empty = 0x0, // Automatically generated, may contain bugs. - AccessTime20 = 0xE000, Accessibility32 = 0xE001, Accessibility48 = 0xE002, diff --git a/src/Wpf.Ui/Controls/SymbolRegular.cs b/src/Wpf.Ui/Controls/SymbolRegular.cs index 7ab46c489..d758f994d 100644 --- a/src/Wpf.Ui/Controls/SymbolRegular.cs +++ b/src/Wpf.Ui/Controls/SymbolRegular.cs @@ -18,7 +18,6 @@ public enum SymbolRegular Empty = 0x0, // Automatically generated, may contain bugs. - AccessTime20 = 0xE000, Accessibility32 = 0xE001, Accessibility48 = 0xE002, diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 1846948ec..3c822aa7a 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -633,8 +633,7 @@ or User32.WM.NCLBUTTONUP if (!button.ReactToHwndHook(message, lParam, out var returnIntPtr)) continue; - //It happens that the background is not removed from the buttons and you can make all the buttons are in the IsHovered=true - //It cleans up + // Fix for when sometimes, button hover backgrounds aren't cleared correctly, causing multiple buttons to appear as if hovered. foreach (var anotherButton in _buttons) { if (anotherButton == button) @@ -661,8 +660,9 @@ or User32.WM.NCLBUTTONUP { case User32.WM.NCHITTEST when (CloseWindowByDoubleClickOnIcon && _icon.IsMouseOverElement(lParam)): + + // Ideally, clicking on the icon should open the system menu, but when the system menu is opened manually, double-clicking on the icon does not close the window handled = true; - //Ideally, clicking on the icon should open the system menu, but when the system menu is opened manually, double-clicking on the icon does not close the window return (IntPtr)User32.WM_NCHITTEST.HTSYSMENU; case User32.WM.NCHITTEST when this.IsMouseOverElement(lParam) && !isMouseOverHeaderContent: handled = true; diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index abd02bd0e..c68c24882 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -96,7 +96,7 @@ public Brush RenderButtonsForeground public bool IsHovered { get; private set; } private User32.WM_NCHITTEST _returnValue; - private Brush _defaultBackgroundBrush = Brushes.Transparent; //Should it be transparent? + private Brush _defaultBackgroundBrush = Brushes.Transparent; // REVIEW: Should it be transparent? private bool _isClickedDown; @@ -184,7 +184,7 @@ internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnInt case User32.WM.NCHITTEST: if (this.IsMouseOverElement(lParam)) { - //Debug.WriteLine($"Hitting {ButtonType} | return code {_returnValue}"); + /*Debug.WriteLine($"Hitting {ButtonType} | return code {_returnValue}");*/ Hover(); returnIntPtr = (IntPtr)_returnValue; diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs index 8fdfe6f63..e4d15422b 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs @@ -23,11 +23,11 @@ public class TreeGrid : System.Windows.Controls.Primitives.Selector new PropertyMetadata(new ObservableCollection(), OnHeadersChanged) ); - ///// - ///// Property for . - ///// - //public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), - // typeof(object), typeof(TreeGrid), new PropertyMetadata(null, OnContentChanged)); + /*/// + /// Property for . + /// + public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), + typeof(object), typeof(TreeGrid), new PropertyMetadata(null, OnContentChanged));*/ /// /// Content is the data used to generate the child elements of this control. @@ -39,15 +39,15 @@ public ObservableCollection Headers set => SetValue(HeadersProperty, value); } - ///// - ///// Content is the data used to generate the child elements of this control. - ///// - //[Bindable(true)] - //public object Content - //{ - // get => GetValue(ContentProperty); - // set => SetValue(ContentProperty, value); - //} + /*/// + /// Content is the data used to generate the child elements of this control. + /// + [Bindable(true)] + public object Content + { + get => GetValue(ContentProperty); + set => SetValue(ContentProperty, value); + }*/ public TreeGrid() { @@ -56,30 +56,30 @@ public TreeGrid() var z = new System.Windows.Controls.ListBox(); } - ///// - ///// Add an object child to this control - ///// - //void IAddChild.AddChild(object value) - //{ - // AddChild(value); - //} - - //public void AddText(string text) - //{ - // throw new NotImplementedException(); - //} - - ///// - ///// Add an object child to this control - ///// - //protected virtual void AddChild(object value) - //{ - // // if conent is the first child or being cleared, set directly - // if (Content == null || value == null) - // Content = value; - // else - // throw new InvalidOperationException($"{typeof(TreeGrid)} cannot have multiple content"); - //} + /*/// + /// Add an object child to this control + /// + void IAddChild.AddChild(object value) + { + AddChild(value); + } + + public void AddText(string text) + { + throw new NotImplementedException(); + } + + /// + /// Add an object child to this control + /// + protected virtual void AddChild(object value) + { + // if conent is the first child or being cleared, set directly + if (Content == null || value == null) + Content = value; + else + throw new InvalidOperationException($"{typeof(TreeGrid)} cannot have multiple content"); + }*/ protected virtual void OnHeadersChanged() { diff --git a/src/Wpf.Ui/Controls/TypedEventHandler.cs b/src/Wpf.Ui/Controls/TypedEventHandler.cs index 075190923..6ca2bedfc 100644 --- a/src/Wpf.Ui/Controls/TypedEventHandler.cs +++ b/src/Wpf.Ui/Controls/TypedEventHandler.cs @@ -2,7 +2,6 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs index 96df73901..4d3cfede8 100644 --- a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs +++ b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger diff --git a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs index 269d92178..2904e2a59 100644 --- a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs +++ b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger @@ -17,8 +17,6 @@ namespace Wpf.Ui.Controls; /// Virtualized . /// Based on . /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(VirtualizingItemsControl), "VirtualizingItemsControl.bmp")] public class VirtualizingItemsControl : System.Windows.Controls.ItemsControl { /// diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 968842c40..165c03a11 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -1,8 +1,8 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger diff --git a/src/Wpf.Ui/Input/RelayCommand{T}.cs b/src/Wpf.Ui/Input/RelayCommand{T}.cs index 8c2285099..73a95b2b4 100644 --- a/src/Wpf.Ui/Input/RelayCommand{T}.cs +++ b/src/Wpf.Ui/Input/RelayCommand{T}.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - +// - // This file is inspired from the MvvmLight library (lbugnion/MvvmLight) using System.Runtime.CompilerServices; diff --git a/src/Wpf.Ui/Interop/Libraries.cs b/src/Wpf.Ui/Interop/Libraries.cs index 308f8132a..50c746af9 100644 --- a/src/Wpf.Ui/Interop/Libraries.cs +++ b/src/Wpf.Ui/Interop/Libraries.cs @@ -10,39 +10,34 @@ namespace Wpf.Ui.Interop; /// internal static class Libraries { - //internal const string Advapi32 = "advapi32.dll"; - //internal const string BCrypt = "BCrypt.dll"; - //internal const string CoreComm_L1_1_1 = "api-ms-win-core-comm-l1-1-1.dll"; - //internal const string Crypt32 = "crypt32.dll"; - internal const string Dwmapi = "dwmapi.dll"; - - //internal const string Error_L1 = "api-ms-win-core-winrt-error-l1-1-0.dll"; - //internal const string HttpApi = "httpapi.dll"; - //internal const string IpHlpApi = "iphlpapi.dll"; + /*internal const string Advapi32 = "advapi32.dll"; + internal const string BCrypt = "BCrypt.dll"; + internal const string CoreComm_L1_1_1 = "api-ms-win-core-comm-l1-1-1.dll"; + internal const string Crypt32 = "crypt32.dll"; + internal const string Error_L1 = "api-ms-win-core-winrt-error-l1-1-0.dll"; + internal const string HttpApi = "httpapi.dll"; + internal const string IpHlpApi = "iphlpapi.dll";*/ internal const string Kernel32 = "kernel32.dll"; - - //internal const string Memory_L1_3 = "api-ms-win-core-memory-l1-1-3.dll"; - //internal const string Mswsock = "mswsock.dll"; - //internal const string NCrypt = "ncrypt.dll"; - //internal const string NtDll = "ntdll.dll"; - //internal const string Odbc32 = "odbc32.dll"; - //internal const string OleAut32 = "oleaut32.dll"; - //internal const string PerfCounter = "perfcounter.dll"; - //internal const string RoBuffer = "api-ms-win-core-winrt-robuffer-l1-1-0.dll"; - //internal const string Secur32 = "secur32.dll"; + /*internal const string Memory_L1_3 = "api-ms-win-core-memory-l1-1-3.dll"; + internal const string Mswsock = "mswsock.dll"; + internal const string NCrypt = "ncrypt.dll"; + internal const string NtDll = "ntdll.dll"; + internal const string Odbc32 = "odbc32.dll"; + internal const string OleAut32 = "oleaut32.dll"; + internal const string PerfCounter = "perfcounter.dll"; + internal const string RoBuffer = "api-ms-win-core-winrt-robuffer-l1-1-0.dll"; + internal const string Secur32 = "secur32.dll";*/ internal const string Shell32 = "shell32.dll"; - - //internal const string SspiCli = "sspicli.dll"; + /*internal const string SspiCli = "sspicli.dll";*/ internal const string User32 = "user32.dll"; internal const string UxTheme = "uxtheme.dll"; - - //internal const string Gdi32 = "gdi32.dll"; - //internal const string Gdip = "gdiplus.dll"; + /*internal const string Gdi32 = "gdi32.dll"; + internal const string Gdip = "gdiplus.dll";*/ internal const string Version = "version.dll"; - //internal const string WebSocket = "websocket.dll"; - //internal const string WinHttp = "winhttp.dll"; - //internal const string WinMM = "winmm.dll"; - //internal const string Ws2_32 = "ws2_32.dll"; - //internal const string Wtsapi32 = "wtsapi32.dll"; - //internal const string CompressionNative = "System.IO.Compression.Native.dll"; + /*internal const string WebSocket = "websocket.dll"; + internal const string WinHttp = "winhttp.dll"; + internal const string WinMM = "winmm.dll"; + internal const string Ws2_32 = "ws2_32.dll"; + internal const string Wtsapi32 = "wtsapi32.dll"; + internal const string CompressionNative = "System.IO.Compression.Native.dll";*/ } diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index c777c2421..1ca55f925 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - +// - // NOTE // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. diff --git a/src/Wpf.Ui/Interop/UxTheme.cs b/src/Wpf.Ui/Interop/UxTheme.cs index 1857e3c8a..f554a3318 100644 --- a/src/Wpf.Ui/Interop/UxTheme.cs +++ b/src/Wpf.Ui/Interop/UxTheme.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - -// NOTE +// - +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods @@ -31,7 +31,7 @@ public struct MARGINS /// public int cxLeftWidth; - /// + /// /// Width of right border that retains its size. /// public int cxRightWidth; diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 8b6ff9326..6e3631cc5 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -112,5 +112,4 @@ public void Shutdown() { _application?.Shutdown(); } - } diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index db934637b..5cf4bd1af 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -137,6 +137,7 @@ out var majorObj major = (int)majorObj; } + // When the 'CurrentMajorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' else if ( TryGetRegistryKey( @@ -173,6 +174,7 @@ out var minorObj minor = (int)minorObj; } + // When the 'CurrentMinorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' else if ( TryGetRegistryKey( From 8d46fb150074ec5dac73d481fef12b4b78c36a71 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 10:29:23 -0700 Subject: [PATCH 05/33] Fix missing braces or single-lined braces - Add stylecop supression of 1502 "element should not be on a single line" - Wrap with braces where needed --- .editorconfig | 1 + .../Utilities/ThemeUtilities.cs | 2 ++ .../Helpers/EnumToBooleanConverter.cs | 8 +++++- src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs | 6 +++- .../ViewModels/DataViewModel.cs | 2 ++ .../ViewModels/SettingsViewModel.cs | 6 ++++ .../Controllers/MonacoController.cs | 2 ++ .../Services/WindowsProviderService.cs | 2 ++ .../Pages/BasicInput/ToggleSwitchViewModel.cs | 2 ++ src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 14 ++++++++++ src/Wpf.Ui/Controls/Card/Card.cs | 2 ++ src/Wpf.Ui/Controls/CardColor/CardColor.cs | 6 ++++ .../Controls/ContentDialog/ContentDialog.cs | 6 ++++ src/Wpf.Ui/Controls/ControlsServices.cs | 2 ++ src/Wpf.Ui/Controls/DataGrid/DataGrid.cs | 6 ++++ .../DynamicScrollBar/DynamicScrollBar.cs | 16 +++++++++++ src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 10 +++++++ .../IconElement/IconElementConverter.cs | 4 +++ src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs | 4 +++ src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 10 +++++++ .../NavigationView/NavigationView.Base.cs | 28 ++++++++++++++++++- .../NavigationView.TemplateParts.cs | 2 ++ .../NavigationView/NavigationViewActivator.cs | 8 ++++++ .../NavigationViewContentPresenter.cs | 2 ++ .../NavigationView/NavigationViewItem.cs | 22 +++++++++++++++ .../Controls/PasswordBox/PasswordBox.cs | 20 +++++++++++++ .../Controls/ProgressRing/ProgressRing.cs | 8 ++++++ .../Controls/RatingControl/RatingControl.cs | 28 +++++++++++++++++++ src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 4 +++ src/Wpf.Ui/Controls/SymbolGlyph.cs | 4 +++ src/Wpf.Ui/Controls/TextBox/TextBox.cs | 10 +++++++ src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 10 +++++++ .../Controls/TitleBar/TitleBarButton.cs | 6 ++++ src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs | 4 +++ .../VirtualizingWrapPanel.cs | 28 +++++++++++++++++++ src/Wpf.Ui/UiApplication.cs | 4 ++- src/Wpf.Ui/Win32/Utilities.cs | 2 ++ 37 files changed, 297 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2bbf5d745..1eb2d7ce5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -397,3 +397,4 @@ dotnet_diagnostic.SA1204.severity = none dotnet_diagnostic.SA1208.severity = none dotnet_diagnostic.SA1518.severity = none dotnet_diagnostic.SA1615.severity = none +dotnet_diagnostic.SA1502.severity = none diff --git a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs index 66b134f24..1152f4ddd 100644 --- a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs +++ b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs @@ -18,12 +18,14 @@ public static void ApplyTheme(this FrameworkElement frameworkElement) if (frameworkElement is Window window) { if (window != UiApplication.Current.MainWindow) + { WindowBackgroundManager.UpdateBackground( window, sender, Wpf.Ui.Controls.WindowBackdropType.None, true ); + } } }; diff --git a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs b/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs index 263b2be21..f65faa6fb 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -13,10 +13,14 @@ internal class EnumToBooleanConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter is not String enumString) + { throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); + } if (!Enum.IsDefined(typeof(Wpf.Ui.Appearance.ApplicationTheme), value)) + { throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum"); + } var enumValue = Enum.Parse(typeof(Wpf.Ui.Appearance.ApplicationTheme), enumString); @@ -26,7 +30,9 @@ public object Convert(object value, Type targetType, object parameter, CultureIn public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter is not String enumString) + { throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); + } return Enum.Parse(typeof(Wpf.Ui.Appearance.ApplicationTheme), enumString); } diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs b/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs index 0b0ceb45b..f01f5f9f0 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -28,7 +28,9 @@ public PageService(IServiceProvider serviceProvider) where T : class { if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T))) + { throw new InvalidOperationException("The page should be a WPF control."); + } return (T?)_serviceProvider.GetService(typeof(T)); } @@ -37,7 +39,9 @@ public PageService(IServiceProvider serviceProvider) public FrameworkElement? GetPage(Type pageType) { if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) + { throw new InvalidOperationException("The page should be a WPF control."); + } return _serviceProvider.GetService(pageType) as FrameworkElement; } diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs index fe6e4d45f..4162e76e6 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs @@ -19,7 +19,9 @@ public partial class DataViewModel : ObservableObject, INavigationAware public void OnNavigatedTo() { if (!_isInitialized) + { InitializeViewModel(); + } } public void OnNavigatedFrom() { } diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs index 86c56258f..43ac63c8c 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs @@ -23,7 +23,9 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware public void OnNavigatedTo() { if (!_isInitialized) + { InitializeViewModel(); + } } public void OnNavigatedFrom() { } @@ -49,7 +51,9 @@ private void OnChangeTheme(string parameter) { case "theme_light": if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Light) + { break; + } Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Light); CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Light; @@ -58,7 +62,9 @@ private void OnChangeTheme(string parameter) default: if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Dark) + { break; + } Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Dark); CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Dark; diff --git a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs index 5ea1c948b..a4eb20a29 100644 --- a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs +++ b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs @@ -72,7 +72,9 @@ public async Task SetContentAsync(string contents) public void DispatchScript(string script) { if (_webView == null) + { return; + } Application.Current.Dispatcher.InvokeAsync(async () => await _webView!.ExecuteScriptAsync(script)); } diff --git a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs index 249f0af11..0752cf1bb 100644 --- a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs +++ b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs @@ -18,7 +18,9 @@ public void Show() where T : class { if (!typeof(Window).IsAssignableFrom(typeof(T))) + { throw new InvalidOperationException($"The window class should be derived from {typeof(Window)}."); + } var windowInstance = _serviceProvider.GetService() as Window ?? throw new InvalidOperationException("Window is not registered as service."); diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs index 53b67d545..57f3d5dd7 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs @@ -16,7 +16,9 @@ public partial class ToggleSwitchViewModel : ObservableObject private void OnToggleSwitchCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsToggleSwitchEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index b3d00041c..9d6199b68 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -326,7 +326,9 @@ protected override void OnRender(DrawingContext drawingContext) base.OnRender(drawingContext); if (this.internalNotifyIconManager.IsRegistered) + { return; + } InitializeIcon(); @@ -398,12 +400,16 @@ protected virtual void OnMiddleDoubleClick() protected virtual void Dispose(bool disposing) { if (Disposed) + { return; + } Disposed = true; if (!disposing) + { return; + } #if DEBUG System.Diagnostics.Debug.WriteLine($"INFO | {typeof(NotifyIcon)} disposed.", "Wpf.Ui.NotifyIcon"); @@ -450,7 +456,9 @@ private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedE private static void OnFocusOnLeftClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not NotifyIcon notifyIcon) + { return; + } if (e.NewValue is not bool newValue) { @@ -465,7 +473,9 @@ private static void OnFocusOnLeftClickChanged(DependencyObject d, DependencyProp private static void OnMenuOnRightClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not NotifyIcon notifyIcon) + { return; + } if (e.NewValue is not bool newValue) { @@ -480,10 +490,14 @@ private static void OnMenuOnRightClickChanged(DependencyObject d, DependencyProp private static void OnMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not NotifyIcon notifyIcon) + { return; + } if (e.NewValue is not ContextMenu contextMenu) + { return; + } notifyIcon.OnMenuChanged(contextMenu); } diff --git a/src/Wpf.Ui/Controls/Card/Card.cs b/src/Wpf.Ui/Controls/Card/Card.cs index 0b9045201..3eaa0ecaa 100644 --- a/src/Wpf.Ui/Controls/Card/Card.cs +++ b/src/Wpf.Ui/Controls/Card/Card.cs @@ -54,7 +54,9 @@ public bool HasFooter private static void FooterChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not Card control) + { return; + } control.SetValue(HasFooterProperty, control.Footer != null); } diff --git a/src/Wpf.Ui/Controls/CardColor/CardColor.cs b/src/Wpf.Ui/Controls/CardColor/CardColor.cs index 26f302bc3..abaada38a 100644 --- a/src/Wpf.Ui/Controls/CardColor/CardColor.cs +++ b/src/Wpf.Ui/Controls/CardColor/CardColor.cs @@ -152,7 +152,9 @@ protected virtual void OnBrushPropertyChanged() private static void OnSubtitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) + { return; + } cardColor.OnSubtitlePropertyChanged(); } @@ -160,7 +162,9 @@ private static void OnSubtitlePropertyChanged(DependencyObject d, DependencyProp private static void OnColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) + { return; + } cardColor.OnColorPropertyChanged(); } @@ -168,7 +172,9 @@ private static void OnColorPropertyChanged(DependencyObject d, DependencyPropert private static void OnBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) + { return; + } cardColor.OnBrushPropertyChanged(); } diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 9a7439951..e82c68373 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -611,7 +611,9 @@ public virtual void Hide(ContentDialogResult result = ContentDialogResult.None) RaiseEvent(closingEventArgs); if (!closingEventArgs.Cancel) + { Tcs?.TrySetResult(result); + } } #endregion @@ -710,7 +712,9 @@ private Size GetNewDialogSize(Size desiredSize) private void ResizeWidth(UIElement element) { if (DialogWidth <= DialogMaxWidth) + { return; + } DialogWidth = DialogMaxWidth; element.UpdateLayout(); @@ -727,7 +731,9 @@ private void ResizeWidth(UIElement element) private void ResizeHeight(UIElement element) { if (DialogHeight <= DialogMaxHeight) + { return; + } DialogHeight = DialogMaxHeight; element.UpdateLayout(); diff --git a/src/Wpf.Ui/Controls/ControlsServices.cs b/src/Wpf.Ui/Controls/ControlsServices.cs index c8d1f3a57..e357b3fa2 100644 --- a/src/Wpf.Ui/Controls/ControlsServices.cs +++ b/src/Wpf.Ui/Controls/ControlsServices.cs @@ -21,7 +21,9 @@ public static class ControlsServices public static void Initialize(IServiceProvider? serviceProvider) { if (serviceProvider == null) + { throw new ArgumentNullException(nameof(serviceProvider)); + } ControlsServiceProvider = serviceProvider; } diff --git a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs index 79a0ee145..c5f6ad31e 100644 --- a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs +++ b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs @@ -73,7 +73,9 @@ private void ColumnsOnCollectionChanged(object? sender, NotifyCollectionChangedE private void UpdateColumnElementStyles() { foreach (var singleColumn in Columns) + { UpdateSingleColumn(singleColumn); + } } private void UpdateSingleColumn(DataGridColumn dataGridColumn) @@ -84,16 +86,19 @@ private void UpdateSingleColumn(DataGridColumn dataGridColumn) checkBoxColumn.ReadLocalValue(DataGridCheckBoxColumn.ElementStyleProperty) == DependencyProperty.UnsetValue ) + { BindingOperations.SetBinding( checkBoxColumn, DataGridCheckBoxColumn.ElementStyleProperty, new Binding { Path = new PropertyPath(CheckBoxColumnElementStyleProperty), Source = this } ); + } if ( checkBoxColumn.ReadLocalValue(DataGridCheckBoxColumn.EditingElementStyleProperty) == DependencyProperty.UnsetValue ) + { BindingOperations.SetBinding( checkBoxColumn, DataGridCheckBoxColumn.EditingElementStyleProperty, @@ -103,6 +108,7 @@ private void UpdateSingleColumn(DataGridColumn dataGridColumn) Source = this } ); + } } } } diff --git a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs index c3a84fe7c..55ab3acb8 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs @@ -69,7 +69,9 @@ public bool IsInteracted set { if ((bool)GetValue(IsInteractedProperty) != value) + { SetValue(IsInteractedProperty, value); + } } } @@ -108,13 +110,19 @@ private async Task UpdateScroll() var shouldScroll = IsMouseOver || _isScrolling; if (shouldScroll == _isInteracted) + { return; + } if (!shouldScroll) + { await Task.Delay(Timeout); + } if (!_interactiveIdentifier.IsEqual(currentEvent)) + { return; + } IsInteracted = shouldScroll; } @@ -122,10 +130,14 @@ private async Task UpdateScroll() private static void IsScrollingProperty_OnChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not DynamicScrollBar bar) + { return; + } if (bar._isScrolling == bar.IsScrolling) + { return; + } bar._isScrolling = !bar._isScrolling; @@ -138,10 +150,14 @@ DependencyPropertyChangedEventArgs e ) { if (d is not DynamicScrollBar bar) + { return; + } if (bar._isInteracted == bar.IsInteracted) + { return; + } bar._isInteracted = !bar._isInteracted; diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index bc3e7ee3c..11343efe5 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -164,7 +164,9 @@ private static void OnFontFamilyChanged(DependencyObject d, DependencyPropertyCh { var self = (FontIcon)d; if (self.TextBlock is null) + { return; + } self.TextBlock.FontFamily = (FontFamily)e.NewValue; } @@ -173,7 +175,9 @@ private static void OnFontSizeChanged(DependencyObject d, DependencyPropertyChan { var self = (FontIcon)d; if (self.TextBlock is null) + { return; + } self.TextBlock.FontSize = (double)e.NewValue; } @@ -182,7 +186,9 @@ private static void OnFontStyleChanged(DependencyObject d, DependencyPropertyCha { var self = (FontIcon)d; if (self.TextBlock is null) + { return; + } self.TextBlock.FontStyle = (FontStyle)e.NewValue; } @@ -191,7 +197,9 @@ private static void OnFontWeightChanged(DependencyObject d, DependencyPropertyCh { var self = (FontIcon)d; if (self.TextBlock is null) + { return; + } self.TextBlock.FontWeight = (FontWeight)e.NewValue; } @@ -200,7 +208,9 @@ private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChanged { var self = (FontIcon)d; if (self.TextBlock is null) + { return; + } self.TextBlock.Text = (string)e.NewValue; } diff --git a/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs b/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs index 6404494d6..119bd3a2a 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElementConverter.cs @@ -16,10 +16,14 @@ public class IconElementConverter : TypeConverter public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { if (sourceType == typeof(SymbolRegular)) + { return true; + } if (sourceType == typeof(SymbolFilled)) + { return true; + } return false; } diff --git a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs index d308e2536..e610ff72d 100644 --- a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs @@ -70,9 +70,13 @@ protected override void OnInitialized(EventArgs e) private void OnGlyphChanged() { if (Filled) + { Glyph = Symbol.Swap().GetString(); + } else + { Glyph = Symbol.GetString(); + } } private void SetFontReference() diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index d6eccc470..1a467f49d 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -324,9 +324,13 @@ public async Task ShowDialogAsync( RemoveTitleBarAndApplyMica(); if (showAsDialog) + { base.ShowDialog(); + } else + { base.Show(); + } return await Tcs.Task; } @@ -374,7 +378,9 @@ protected override void OnClosing(CancelEventArgs e) base.OnClosing(e); if (e.Cancel) + { return; + } Tcs?.TrySetResult(MessageBoxResult.None); } @@ -417,7 +423,9 @@ private void RemoveTitleBarAndApplyMica() private void ResizeWidth(UIElement element) { if (Width <= MaxWidth) + { return; + } Width = MaxWidth; element.UpdateLayout(); @@ -433,7 +441,9 @@ private void ResizeWidth(UIElement element) private void ResizeHeight(UIElement element) { if (Height <= MaxHeight) + { return; + } Height = MaxHeight; element.UpdateLayout(); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index 2e3be8132..e3c2a27e7 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -129,21 +129,29 @@ protected virtual void OnUnloaded(object sender, RoutedEventArgs e) } if (Header is BreadcrumbBar breadcrumbBar) + { breadcrumbBar.ItemClicked -= BreadcrumbBarOnItemClicked; + } if (ToggleButton is not null) + { ToggleButton.Click -= OnToggleButtonClick; + } if (BackButton is not null) + { BackButton.Click -= OnToggleButtonClick; + } if (AutoSuggestBoxSymbolButton is not null) + { AutoSuggestBoxSymbolButton.Click -= AutoSuggestBoxSymbolButtonOnClick; + } } protected override void OnMouseDown(MouseButtonEventArgs e) { - //Back button + // Back button if (e.ChangedButton is MouseButton.XButton1) { GoBack(); @@ -232,7 +240,9 @@ BreadcrumbBarItemClickedEventArgs e private void UpdateAutoSuggestBoxSuggestions() { if (AutoSuggestBox == null) + { return; + } _autoSuggestBoxItems.Clear(); @@ -248,13 +258,19 @@ AutoSuggestBoxSuggestionChosenEventArgs args ) { if (sender.IsSuggestionListOpen) + { return; + } if (args.SelectedItem is not string selectedSuggestBoxItem) + { return; + } if (NavigateToMenuItemFromAutoSuggestBox(MenuItems, selectedSuggestBoxItem)) + { return; + } NavigateToMenuItemFromAutoSuggestBox(FooterMenuItems, selectedSuggestBoxItem); } @@ -274,20 +290,28 @@ AutoSuggestBoxQuerySubmittedEventArgs args foreach (string queryToken in querySplit) { if (item.IndexOf(queryToken, StringComparison.CurrentCultureIgnoreCase) < 0) + { isMatch = false; + } } if (isMatch) + { suggestions.Add(item); + } } if (suggestions.Count <= 0) + { return; + } var element = suggestions.First(); if (NavigateToMenuItemFromAutoSuggestBox(MenuItems, element)) + { return; + } NavigateToMenuItemFromAutoSuggestBox(FooterMenuItems, element); } @@ -422,7 +446,9 @@ protected virtual void UpdateMenuItemsTemplate() protected virtual void CloseNavigationViewItemMenus() { if (Journal.Count <= 0 || IsPaneOpen) + { return; + } DeactivateMenuItems(MenuItems); DeactivateMenuItems(FooterMenuItems); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs index d5a99d713..d354f3d54 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs @@ -146,7 +146,9 @@ protected T GetTemplateChild(string name) where T : DependencyObject { if (GetTemplateChild(name) is not T dependencyObject) + { throw new ArgumentNullException(name); + } return dependencyObject; } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs index b588de91f..190786fcc 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs @@ -24,11 +24,14 @@ internal static class NavigationViewActivator public static FrameworkElement? CreateInstance(Type pageType, object? dataContext = null) { if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) + { throw new InvalidCastException( $"PageType of the ${typeof(INavigationViewItem)} must be derived from {typeof(FrameworkElement)}. {pageType} is not." ); + } if (DesignerHelper.IsInDesignMode) + { return new Page { Content = new TextBlock @@ -36,6 +39,7 @@ internal static class NavigationViewActivator Text = "Pages are not rendered while using the Designer. Edit the page template directly." } }; + } FrameworkElement? instance; @@ -135,7 +139,9 @@ internal static class NavigationViewActivator : tPage.GetConstructor(new[] { dataContext!.GetType() }); if (ctor != null) + { return ctor.Invoke(new[] { dataContext }) as FrameworkElement; + } return null; } @@ -153,6 +159,8 @@ internal static class NavigationViewActivator private static void SetDataContext(FrameworkElement? element, object? dataContext) { if (element != null && dataContext != null) + { element.DataContext = dataContext; + } } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index fbbecb01c..cb507a5d4 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -208,7 +208,9 @@ content is INavigableView private static void NotifyContentAboutNavigatingFrom(object content) { if (content is INavigationAware navigationAwareNavigationContent) + { navigationAwareNavigationContent.OnNavigatedFrom(); + } if ( content is INavigableView diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index cf8c737f3..e51cb2245 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -303,7 +303,9 @@ public virtual void Activate(INavigationView navigationView) IsActive = true; if (!navigationView.IsPaneOpen && NavigationViewItemParent is not null) + { NavigationViewItemParent.Activate(navigationView); + } if (NavigationViewItemParent is not null) { @@ -324,7 +326,9 @@ public virtual void Activate(INavigationView navigationView) Icon is SymbolIcon symbolIcon && navigationView.PaneDisplayMode == NavigationViewPaneDisplayMode.LeftFluent ) + { symbolIcon.Filled = true; + } } /// @@ -336,13 +340,17 @@ public virtual void Deactivate(INavigationView navigationView) NavigationViewItemParent?.Deactivate(navigationView); if (!navigationView.IsPaneOpen && HasMenuItems) + { IsExpanded = false; + } if ( Icon is SymbolIcon symbolIcon && navigationView.PaneDisplayMode == NavigationViewPaneDisplayMode.LeftFluent ) + { symbolIcon.Filled = false; + } } /// @@ -371,13 +379,19 @@ protected override void OnInitialized(EventArgs e) protected override void OnClick() { if (NavigationView.GetNavigationParent(this) is not { } navigationView) + { return; + } if (HasMenuItems && navigationView.IsPaneOpen) + { IsExpanded = !IsExpanded; + } if (TargetPageType is not null) + { navigationView.OnNavigationViewItemClick(this); + } base.OnClick(); } @@ -394,7 +408,9 @@ protected override void OnMouseDown(MouseButtonEventArgs e) } if (NavigationView.GetNavigationParent(this) is not { } navigationView) + { return; + } if ( !navigationView.IsPaneOpen @@ -420,12 +436,18 @@ protected override void OnMouseDown(MouseButtonEventArgs e) object? menuItem = MenuItems[i]; if (menuItem is not INavigationViewItem { IsActive: true }) + { continue; + } if (IsExpanded) + { Deactivate(navigationView); + } else + { Activate(navigationView); + } break; } diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index ea14972fd..e0635d56b 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -136,10 +136,14 @@ protected override void OnTextChanged(TextChangedEventArgs e) else { if (PlaceholderEnabled && Text.Length > 0) + { PlaceholderEnabled = false; + } if (!PlaceholderEnabled && Text.Length < 1) + { PlaceholderEnabled = true; + } RevealClearButton(); } @@ -161,7 +165,9 @@ protected virtual void OnPasswordCharChanged() // If password is currently revealed, // do not replace displayed text with asterisks if (IsPasswordRevealed) + { return; + } _lockUpdatingContents = true; @@ -209,12 +215,16 @@ protected override void OnTemplateButtonClick(string? parameter) private void UpdateTextContents(bool isTriggeredByTextInput) { if (_lockUpdatingContents) + { return; + } if (IsPasswordRevealed) { if (Password == Text) + { return; + } _lockUpdatingContents = true; @@ -246,10 +256,12 @@ private void UpdateTextContents(bool isTriggeredByTextInput) var newCharacters = currentText.Replace(PasswordChar.ToString(), String.Empty); if (currentText.Length < currentPassword.Length) + { newPasswordValue = currentPassword.Remove( selectionIndex, currentPassword.Length - currentText.Length ); + } if (newCharacters.Length > 1) { @@ -265,7 +277,9 @@ private void UpdateTextContents(bool isTriggeredByTextInput) for (int i = 0; i < currentText.Length; i++) { if (currentText[i] == PasswordChar) + { continue; + } newPasswordValue = currentText.Length == newPasswordValue.Length @@ -292,7 +306,9 @@ private void UpdateTextContents(bool isTriggeredByTextInput) private static void OnPasswordPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not PasswordBox control) + { return; + } control.OnPasswordChanged(); } @@ -306,7 +322,9 @@ DependencyPropertyChangedEventArgs e ) { if (d is not PasswordBox control) + { return; + } control.OnPasswordCharChanged(); } @@ -320,7 +338,9 @@ DependencyPropertyChangedEventArgs e ) { if (d is not PasswordBox control) + { return; + } control.OnPasswordRevealModeChanged(); } diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index a4f437ee0..668387b7a 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -143,16 +143,22 @@ protected void UpdateProgressAngle() var percentage = Progress; if (percentage > 100) + { percentage = 100; + } if (percentage < 0) + { percentage = 0; + } // (360 / 100) * percentage var endAngle = 3.6d * percentage; if (endAngle >= 360) + { endAngle = 359; + } EngAngle = endAngle; } @@ -163,7 +169,9 @@ protected void UpdateProgressAngle() protected static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not ProgressRing control) + { return; + } control.UpdateProgressAngle(); } diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index b4b6e69d0..64ab430f2 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -132,7 +132,9 @@ protected virtual void OnValueChanged(double oldValue) } if (!Value.Equals(oldValue)) + { RaiseEvent(new RoutedEventArgs(ValueChangedEvent)); + } UpdateStarsFromValue(); } @@ -158,7 +160,9 @@ protected override void OnMouseMove(MouseEventArgs e) var mouseOffset = currentPossition.X * 100 / ActualWidth; if (e.LeftButton != MouseButtonState.Pressed) + { UpdateStarsOnMousePreview(mouseOffset); + } } /// @@ -172,7 +176,9 @@ protected override void OnMouseDown(MouseButtonEventArgs e) var mouseOffset = currentPossition.X * 100 / ActualWidth; if (e.LeftButton == MouseButtonState.Pressed) + { UpdateStarsOnMouseClick(mouseOffset); + } } /// @@ -184,10 +190,14 @@ protected override void OnKeyUp(KeyEventArgs e) base.OnKeyUp(e); if ((e.Key == Key.Right || e.Key == Key.Up) && Value < MaxValue) + { Value += HalfStarEnabled ? 0.5D : 1; + } if ((e.Key == Key.Left || e.Key == Key.Down) && Value > MinValue) + { Value -= HalfStarEnabled ? 0.5D : 1; + } } /// @@ -198,19 +208,29 @@ public override void OnApplyTemplate() base.OnApplyTemplate(); if (GetTemplateChild("PART_Star1") is SymbolIcon starOne) + { _symbolIconStarOne = starOne; + } if (GetTemplateChild("PART_Star2") is SymbolIcon starTwo) + { _symbolIconStarTwo = starTwo; + } if (GetTemplateChild("PART_Star3") is SymbolIcon starThree) + { _symbolIconStarThree = starThree; + } if (GetTemplateChild("PART_Star4") is SymbolIcon starFour) + { _symbolIconStarFour = starFour; + } if (GetTemplateChild("PART_Star5") is SymbolIcon starFive) + { _symbolIconStarFive = starFive; + } UpdateStarsFromValue(); } @@ -338,7 +358,9 @@ private void UpdateStar(int starIndex, StarValue starValue) }; if (_selectedIcon is null) + { return; + } switch (starValue) { @@ -366,10 +388,14 @@ private int ExtractValueFromOffset(double offset) if (!HalfStarEnabled) { if (starValue < 2) + { return 0; + } if (starValue % 2 != 0) + { starValue += 1; + } } return starValue; @@ -378,7 +404,9 @@ private int ExtractValueFromOffset(double offset) private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not RatingControl ratingControl) + { return; + } ratingControl.OnValueChanged((double)e.OldValue); } diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index 8e4d96b56..80611efec 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -175,9 +175,13 @@ public bool IsShown SetValue(IsShownProperty, value); if (value) + { OnOpened(); + } else + { OnClosed(); + } } } diff --git a/src/Wpf.Ui/Controls/SymbolGlyph.cs b/src/Wpf.Ui/Controls/SymbolGlyph.cs index 172fd729f..5094a035a 100644 --- a/src/Wpf.Ui/Controls/SymbolGlyph.cs +++ b/src/Wpf.Ui/Controls/SymbolGlyph.cs @@ -27,7 +27,9 @@ public static class SymbolGlyph public static SymbolRegular Parse(string name) { if (String.IsNullOrEmpty(name)) + { return DefaultIcon; + } try { @@ -50,7 +52,9 @@ public static SymbolRegular Parse(string name) public static SymbolFilled ParseFilled(string name) { if (String.IsNullOrEmpty(name)) + { return DefaultFilledIcon; + } try { diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index 513511573..f6ceafc33 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -186,10 +186,14 @@ protected override void OnTextChanged(TextChangedEventArgs e) base.OnTextChanged(e); if (PlaceholderEnabled && Text.Length > 0) + { PlaceholderEnabled = false; + } if (!PlaceholderEnabled && Text.Length < 1) + { PlaceholderEnabled = true; + } RevealClearButton(); } @@ -218,7 +222,9 @@ protected override void OnLostFocus(RoutedEventArgs e) protected void RevealClearButton() { if (ClearButtonEnabled && IsKeyboardFocusWithin) + { ShowClearButton = Text.Length > 0; + } } /// @@ -227,7 +233,9 @@ protected void RevealClearButton() protected void HideClearButton() { if (ClearButtonEnabled && !IsKeyboardFocusWithin && ShowClearButton) + { ShowClearButton = false; + } } /// @@ -236,7 +244,9 @@ protected void HideClearButton() protected virtual void OnClearButtonClick() { if (Text.Length > 0) + { Text = string.Empty; + } } /// diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 3c822aa7a..cebe30df9 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -542,7 +542,9 @@ private void MinimizeWindow() private void MaximizeWindow() { if (!CanMaximize) + { return; + } if (MaximizeActionOverride is not null) { @@ -566,7 +568,9 @@ private void MaximizeWindow() private void OnParentWindowStateChanged(object? sender, EventArgs e) { if (IsMaximized != (_currentWindow.WindowState == WindowState.Maximized)) + { IsMaximized = _currentWindow.WindowState == WindowState.Maximized; + } } private void OnTemplateButtonClick(TitleBarButtonType buttonType) @@ -626,18 +630,24 @@ or User32.WM.NCLBUTTONDOWN or User32.WM.NCLBUTTONUP ) ) + { return IntPtr.Zero; + } foreach (var button in _buttons) { if (!button.ReactToHwndHook(message, lParam, out var returnIntPtr)) + { continue; + } // Fix for when sometimes, button hover backgrounds aren't cleared correctly, causing multiple buttons to appear as if hovered. foreach (var anotherButton in _buttons) { if (anotherButton == button) + { continue; + } if (anotherButton.IsHovered && button.IsHovered) { diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index c68c24882..c0394dfc9 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -135,7 +135,9 @@ private void OnButtonsForegroundChanged(object? sender, EventArgs e) public void Hover() { if (IsHovered) + { return; + } Background = MouseOverBackground; if (MouseOverButtonsForeground != null) @@ -152,7 +154,9 @@ public void Hover() public void RemoveHover() { if (!IsHovered) + { return; + } Background = _defaultBackgroundBrush; RenderButtonsForeground = ButtonsForeground; @@ -170,7 +174,9 @@ public void InvokeClick() new ButtonAutomationPeer(this).GetPattern(PatternInterface.Invoke) is IInvokeProvider invokeProvider ) + { invokeProvider.Invoke(); + } _isClickedDown = false; } diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs index e4d15422b..05f29c9d5 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs @@ -94,7 +94,9 @@ protected virtual void OnContentChanged() private static void OnHeadersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not TreeGrid treeGrid) + { return; + } treeGrid.OnHeadersChanged(); } @@ -102,7 +104,9 @@ private static void OnHeadersChanged(DependencyObject d, DependencyPropertyChang private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not TreeGrid treeGrid) + { return; + } treeGrid.OnContentChanged(); } diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 165c03a11..6d33d46af 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -141,7 +141,9 @@ protected virtual void OnOrientationChanged() private static void OnOrientationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not VirtualizingWrapPanel panel) + { return; + } panel.OnOrientationChanged(); } @@ -177,11 +179,17 @@ ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem } if (ItemSize != Size.Empty) + { ChildSize = ItemSize; + } else if (InternalChildren.Count != 0) + { ChildSize = InternalChildren[0].DesiredSize; + } else + { ChildSize = CalculateChildSize(availableSize); + } ItemsPerRowCount = Double.IsInfinity(GetWidth(availableSize)) ? Items.Count @@ -196,7 +204,9 @@ ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem private Size CalculateChildSize(Size availableSize) { if (Items.Count == 0) + { return new Size(0, 0); + } var startPosition = ItemContainerGenerator.GeneratorPositionFromIndex(0); @@ -223,10 +233,12 @@ protected override Size CalculateExtent(Size availableSize) : GetWidth(ChildSize) * ItemsPerRowCount; if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) + { extentWidth = Orientation == Orientation.Vertical ? Math.Max(extentWidth - (Margin.Left + Margin.Right), 0) : Math.Max(extentWidth - (Margin.Top + Margin.Bottom), 0); + } var extentHeight = GetHeight(ChildSize) * RowCount; @@ -279,7 +291,9 @@ protected override Size ArrangeOverride(Size finalSize) /* When the items owner is a group item offset is handled by the parent panel. */ if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) + { offsetY = 0; + } Size childSize = CalculateChildArrangeSize(finalSize); @@ -320,7 +334,9 @@ protected override Size ArrangeOverride(Size finalSize) protected Size CalculateChildArrangeSize(Size finalSize) { if (!StretchItems) + { return ChildSize; + } if (Orientation == Orientation.Vertical) { @@ -359,7 +375,9 @@ private T ReadItemContainerStyle(DependencyProperty property, T fallbackValue protected override ItemRange UpdateItemRange() { if (!IsVirtualizing) + { return new ItemRange(0, Items.Count - 1); + } int startIndex; int endIndex; @@ -367,7 +385,9 @@ protected override ItemRange UpdateItemRange() if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) { if (!VirtualizingPanel.GetIsVirtualizingWhenGrouping(ItemsControl)) + { return new ItemRange(0, Items.Count - 1); + } var offset = new Point(Offset.X, groupItem.Constraints.Viewport.Location.Y); @@ -482,20 +502,28 @@ private int GetRowIndex(double location) protected override void BringIndexIntoView(int index) { if (index < 0 || index >= Items.Count) + { throw new ArgumentOutOfRangeException( nameof(index), $"The argument {nameof(index)} must be >= 0 and < the number of items." ); + } if (ItemsPerRowCount == 0) + { throw new InvalidOperationException(); + } var offset = (index / ItemsPerRowCount) * GetHeight(ChildSize); if (Orientation == Orientation.Horizontal) + { SetHorizontalOffset(offset); + } else + { SetVerticalOffset(offset); + } } /// diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 6e3631cc5..29098c302 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -80,7 +80,9 @@ public ResourceDictionary Resources _resources.MergedDictionaries.Add(themesDictionary); _resources.MergedDictionaries.Add(controlsDictionary); } - catch { } + catch + { + } } return _application?.Resources ?? _resources; diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index 5cf4bd1af..367e41495 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -189,7 +189,9 @@ out var version var versionParts = ((string)version).Split('.'); if (versionParts.Length >= 2) + { minor = int.TryParse(versionParts[1], out int minorAsInt) ? minorAsInt : 0; + } } } From 211b2992f73fe7645859801073237a8ae36031b5 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 11:57:07 -0700 Subject: [PATCH 06/33] Fix warnings on registered dependency properties WPF0100, WPF0005, WPF0012 --- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 4 ++-- src/Wpf.Ui/Appearance/SystemThemeManager.cs | 4 ++-- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 4 ++-- .../Controls/BreadcrumbBar/BreadcrumbBar.cs | 14 +++++------ .../BreadcrumbBar/BreadcrumbBarItem.cs | 2 +- src/Wpf.Ui/Controls/Button/Button.cs | 2 +- src/Wpf.Ui/Controls/Card/Card.cs | 6 ++--- src/Wpf.Ui/Controls/CardAction/CardAction.cs | 2 +- src/Wpf.Ui/Controls/CardColor/CardColor.cs | 12 +++++----- .../Controls/CardControl/CardControl.cs | 4 ++-- .../Controls/CardExpander/CardExpander.cs | 4 ++-- .../Controls/ContentDialog/ContentDialog.cs | 12 +++++----- src/Wpf.Ui/Controls/DataGrid/DataGrid.cs | 8 +++---- .../Controls/DropDownButton/DropDownButton.cs | 8 +++---- .../DynamicScrollBar/DynamicScrollBar.cs | 10 ++++---- .../DynamicScrollViewer.cs | 16 ++++++------- .../Controls/FluentWindow/FluentWindow.cs | 8 +++---- .../Controls/IconElement/IconElement.cs | 4 ++-- src/Wpf.Ui/Controls/IconElement/ImageIcon.cs | 6 ++--- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs | 17 +++++++------ src/Wpf.Ui/Controls/Menu/MenuItem.cs | 1 + .../NavigationView.Properties.cs | 24 +++++++++---------- .../NavigationView/NavigationViewItem.cs | 6 ++--- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 12 +++++----- .../Controls/PasswordBox/PasswordBox.cs | 12 +++++----- .../Controls/ProgressRing/ProgressRing.cs | 4 ++-- .../Controls/RatingControl/RatingControl.cs | 4 ++-- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 8 +++---- .../Controls/Snackbar/SnackbarPresenter.cs | 3 ++- .../Controls/SplitButton/SplitButton.cs | 8 +++---- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 4 ++-- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 8 +++---- .../Controls/TitleBar/TitleBarButton.cs | 6 ++--- .../Controls/ToggleSwitch/ToggleSwitch.cs | 8 +++---- src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs | 2 +- src/Wpf.Ui/Interop/Libraries.cs | 5 ++-- 36 files changed, 131 insertions(+), 131 deletions(-) diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 9d6199b68..3b572d339 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -152,9 +152,9 @@ public ImageSource Icon /// /// Context menu. /// - public ContextMenu Menu + public ContextMenu? Menu { - get => (ContextMenu)GetValue(MenuProperty); + get => (ContextMenu?)GetValue(MenuProperty); set => SetValue(MenuProperty, value); } diff --git a/src/Wpf.Ui/Appearance/SystemThemeManager.cs b/src/Wpf.Ui/Appearance/SystemThemeManager.cs index 4b48e1899..422323406 100644 --- a/src/Wpf.Ui/Appearance/SystemThemeManager.cs +++ b/src/Wpf.Ui/Appearance/SystemThemeManager.cs @@ -128,8 +128,8 @@ private static SystemTheme GetCurrentSystemTheme() } } - //if (currentTheme.Contains("custom.theme")) - // return ; custom can be light or dark + /*if (currentTheme.Contains("custom.theme")) + return ; custom can be light or dark*/ var rawAppsUseLightTheme = Registry.GetValue( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 4c9dd12fe..159258548 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -63,7 +63,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl nameof(Text), typeof(string), typeof(AutoSuggestBox), - new PropertyMetadata(String.Empty, TextPropertyChangedCallback) + new PropertyMetadata(String.Empty, OnTextChanged) ); /// @@ -588,7 +588,7 @@ private void DefaultFiltering(string text) return displayMemberPathText ?? obj as string ?? obj.ToString(); } - private static void TextPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var self = (AutoSuggestBox)d; var newText = (string)e.NewValue; diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index cd592e864..0be5f9061 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -53,7 +53,7 @@ public class BreadcrumbBar : System.Windows.Controls.ItemsControl /// /// Property for . /// - public static readonly RoutedEvent ItemClickedRoutedEvent = EventManager.RegisterRoutedEvent( + public static readonly RoutedEvent ItemClickedEvent = EventManager.RegisterRoutedEvent( nameof(ItemClicked), RoutingStrategy.Bubble, typeof(TypedEventHandler), @@ -66,9 +66,9 @@ public class BreadcrumbBar : System.Windows.Controls.ItemsControl [Bindable(true)] [Category("Action")] [Localizability(LocalizationCategory.NeverLocalize)] - public ICommand Command + public ICommand? Command { - get => (ICommand)GetValue(CommandProperty); + get => (ICommand?)GetValue(CommandProperty); set => SetValue(CommandProperty, value); } @@ -77,8 +77,8 @@ public ICommand Command /// public event TypedEventHandler ItemClicked { - add => AddHandler(ItemClickedRoutedEvent, value); - remove => RemoveHandler(ItemClickedRoutedEvent, value); + add => AddHandler(ItemClickedEvent, value); + remove => RemoveHandler(ItemClickedEvent, value); } /// @@ -94,7 +94,7 @@ public BreadcrumbBar() protected virtual void OnItemClicked(object item, int index) { - var args = new BreadcrumbBarItemClickedEventArgs(ItemClickedRoutedEvent, this, item, index); + var args = new BreadcrumbBarItemClickedEventArgs(ItemClickedEvent, this, item, index); RaiseEvent(args); if (Command?.CanExecute(item) ?? false) diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index d3067b1a3..5bbcad3d4 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -49,7 +49,7 @@ public class BreadcrumbBarItem : System.Windows.Controls.ContentControl /// public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index 1cfdcb9fa..55495aebc 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -123,7 +123,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/Card/Card.cs b/src/Wpf.Ui/Controls/Card/Card.cs index 3eaa0ecaa..ed0c9b2df 100644 --- a/src/Wpf.Ui/Controls/Card/Card.cs +++ b/src/Wpf.Ui/Controls/Card/Card.cs @@ -20,7 +20,7 @@ public class Card : System.Windows.Controls.ContentControl nameof(Footer), typeof(object), typeof(Card), - new PropertyMetadata(null, FooterChangedCallback) + new PropertyMetadata(null, OnFooterChanged) ); /// @@ -36,7 +36,7 @@ public class Card : System.Windows.Controls.ContentControl /// /// Gets or sets additional content displayed at the bottom. /// - public object Footer + public object? Footer { get => GetValue(FooterProperty); set => SetValue(FooterProperty, value); @@ -51,7 +51,7 @@ public bool HasFooter internal set => SetValue(HasFooterProperty, value); } - private static void FooterChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnFooterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not Card control) { diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index b00720731..64713907c 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -49,7 +49,7 @@ public bool IsChevronVisible [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } } diff --git a/src/Wpf.Ui/Controls/CardColor/CardColor.cs b/src/Wpf.Ui/Controls/CardColor/CardColor.cs index abaada38a..89fe5c6c4 100644 --- a/src/Wpf.Ui/Controls/CardColor/CardColor.cs +++ b/src/Wpf.Ui/Controls/CardColor/CardColor.cs @@ -28,7 +28,7 @@ public class CardColor : System.Windows.Controls.Control nameof(Subtitle), typeof(string), typeof(CardColor), - new PropertyMetadata(String.Empty, OnSubtitlePropertyChanged) + new PropertyMetadata(String.Empty, OnSubtitleChanged) ); /// @@ -48,7 +48,7 @@ public class CardColor : System.Windows.Controls.Control nameof(Color), typeof(Color), typeof(CardColor), - new PropertyMetadata(Color.FromArgb(0, 0, 0, 0), OnColorPropertyChanged) + new PropertyMetadata(Color.FromArgb(0, 0, 0, 0), OnColorChanged) ); /// @@ -60,7 +60,7 @@ public class CardColor : System.Windows.Controls.Control typeof(CardColor), new PropertyMetadata( new SolidColorBrush { Color = Color.FromArgb(0, 0, 0, 0) }, - OnBrushPropertyChanged + OnBrushChanged ) ); @@ -149,7 +149,7 @@ protected virtual void OnBrushPropertyChanged() CardBrush = Brush; } - private static void OnSubtitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnSubtitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) { @@ -159,7 +159,7 @@ private static void OnSubtitlePropertyChanged(DependencyObject d, DependencyProp cardColor.OnSubtitlePropertyChanged(); } - private static void OnColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) { @@ -169,7 +169,7 @@ private static void OnColorPropertyChanged(DependencyObject d, DependencyPropert cardColor.OnColorPropertyChanged(); } - private static void OnBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not CardColor cardColor) { diff --git a/src/Wpf.Ui/Controls/CardControl/CardControl.cs b/src/Wpf.Ui/Controls/CardControl/CardControl.cs index eacd0f80f..f14648927 100644 --- a/src/Wpf.Ui/Controls/CardControl/CardControl.cs +++ b/src/Wpf.Ui/Controls/CardControl/CardControl.cs @@ -49,7 +49,7 @@ public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconC /// Header is the data used to for the header of each item in the control. /// [Bindable(true)] - public object Header + public object? Header { get => GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); @@ -61,7 +61,7 @@ public object Header [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 4e3df62cc..9f369c63a 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -52,7 +52,7 @@ public class CardExpander : System.Windows.Controls.Expander [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } @@ -60,7 +60,7 @@ public IconElement? Icon /// Gets or sets displayed . /// [Bindable(true), Category("Appearance")] - public CornerRadius? CornerRadius + public CornerRadius CornerRadius { get => (CornerRadius)GetValue(CornerRadiusProperty); set => SetValue(CornerRadiusProperty, value); diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index e82c68373..8685ede76 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -301,7 +301,7 @@ public class ContentDialog : ContentControl /// /// Gets or sets the title of the . /// - public object Title + public object? Title { get => GetValue(TitleProperty); set => SetValue(TitleProperty, value); @@ -310,9 +310,9 @@ public object Title /// /// Gets or sets the title template of the . /// - public DataTemplate TitleTemplate + public DataTemplate? TitleTemplate { - get => (DataTemplate)GetValue(TitleTemplateProperty); + get => (DataTemplate?)GetValue(TitleTemplateProperty); set => SetValue(TitleTemplateProperty, value); } @@ -393,7 +393,7 @@ public string CloseButtonText /// public IconElement? PrimaryButtonIcon { - get => (IconElement)GetValue(PrimaryButtonIconProperty); + get => (IconElement?)GetValue(PrimaryButtonIconProperty); set => SetValue(PrimaryButtonIconProperty, value); } @@ -402,7 +402,7 @@ public IconElement? PrimaryButtonIcon /// public IconElement? SecondaryButtonIcon { - get => (IconElement)GetValue(SecondaryButtonIconProperty); + get => (IconElement?)GetValue(SecondaryButtonIconProperty); set => SetValue(SecondaryButtonIconProperty, value); } @@ -411,7 +411,7 @@ public IconElement? SecondaryButtonIcon /// public IconElement? CloseButtonIcon { - get => (IconElement)GetValue(CloseButtonIconProperty); + get => (IconElement?)GetValue(CloseButtonIconProperty); set => SetValue(CloseButtonIconProperty, value); } diff --git a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs index c5f6ad31e..17f3b6892 100644 --- a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs +++ b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs @@ -41,18 +41,18 @@ public class DataGrid : System.Windows.Controls.DataGrid /// /// A style to apply to all checkbox column in the DataGrid /// - public Style CheckBoxColumnElementStyle + public Style? CheckBoxColumnElementStyle { - get => (Style)GetValue(CheckBoxColumnElementStyleProperty); + get => (Style?)GetValue(CheckBoxColumnElementStyleProperty); set => SetValue(CheckBoxColumnElementStyleProperty, value); } /// /// A style to apply to all checkbox column in the DataGrid /// - public Style CheckBoxColumnEditingElementStyle + public Style? CheckBoxColumnEditingElementStyle { - get => (Style)GetValue(CheckBoxColumnEditingElementStyleProperty); + get => (Style?)GetValue(CheckBoxColumnEditingElementStyleProperty); set => SetValue(CheckBoxColumnEditingElementStyleProperty, value); } diff --git a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs index aa5923235..7ae2a4062 100644 --- a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs +++ b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs @@ -22,7 +22,7 @@ public class DropDownButton : Button nameof(Flyout), typeof(object), typeof(DropDownButton), - new PropertyMetadata(null, OnFlyoutChangedCallback) + new PropertyMetadata(null, OnFlyoutChanged) ); /// @@ -59,15 +59,15 @@ public bool IsDropDownOpen set => SetValue(IsDropDownOpenProperty, value); } - private static void OnFlyoutChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnFlyoutChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is DropDownButton dropDownButton) { - dropDownButton.OnFlyoutChangedCallback(e.NewValue); + dropDownButton.OnFlyoutChanged(e.NewValue); } } - protected virtual void OnFlyoutChangedCallback(object value) + protected virtual void OnFlyoutChanged(object value) { if (value is ContextMenu contextMenu) { diff --git a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs index 55ab3acb8..e06aacac7 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Custom with events depending on actions taken by the user. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(DynamicScrollBar), "DynamicScrollBar.bmp")] public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar { private bool _isScrolling = false; @@ -28,7 +26,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar nameof(IsScrolling), typeof(bool), typeof(DynamicScrollBar), - new PropertyMetadata(false, IsScrollingProperty_OnChange) + new PropertyMetadata(false, OnIsScrollingChanged) ); /// @@ -38,7 +36,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar nameof(IsInteracted), typeof(bool), typeof(DynamicScrollBar), - new PropertyMetadata(false, IsInteractedProperty_OnChange) + new PropertyMetadata(false, OnIsInteractedChanged) ); /// @@ -127,7 +125,7 @@ private async Task UpdateScroll() IsInteracted = shouldScroll; } - private static void IsScrollingProperty_OnChange(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnIsScrollingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not DynamicScrollBar bar) { @@ -144,7 +142,7 @@ private static void IsScrollingProperty_OnChange(DependencyObject d, DependencyP bar.UpdateScroll().GetAwaiter(); } - private static void IsInteractedProperty_OnChange( + private static void OnIsInteractedChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) diff --git a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs index fd7759e10..834b45e5d 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs @@ -36,7 +36,7 @@ public class DynamicScrollViewer : PassiveScrollViewer nameof(IsScrollingVertically), typeof(bool), typeof(DynamicScrollViewer), - new PropertyMetadata(false, IsScrollingVerticallyProperty_OnChanged) + new PropertyMetadata(false, OnIsScrollingVerticallyChanged) ); /// @@ -46,7 +46,7 @@ public class DynamicScrollViewer : PassiveScrollViewer nameof(IsScrollingHorizontally), typeof(bool), typeof(DynamicScrollViewer), - new PropertyMetadata(false, IsScrollingHorizontally_OnChanged) + new PropertyMetadata(false, OnIsScrollingHorizontallyChanged) ); /// @@ -56,7 +56,7 @@ public class DynamicScrollViewer : PassiveScrollViewer nameof(MinimalChange), typeof(double), typeof(DynamicScrollViewer), - new PropertyMetadata(40d, MinimalChangeProperty_OnChanged) + new PropertyMetadata(40d, OnMinimalChangeChanged) ); /// @@ -66,7 +66,7 @@ public class DynamicScrollViewer : PassiveScrollViewer nameof(Timeout), typeof(int), typeof(DynamicScrollViewer), - new PropertyMetadata(1200, TimeoutProperty_OnChanged) + new PropertyMetadata(1200, OnTimeoutChanged) ); /// @@ -175,7 +175,7 @@ private async void UpdateHorizontalScrollingState() } } - private static void IsScrollingVerticallyProperty_OnChanged( + private static void OnIsScrollingVerticallyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -188,7 +188,7 @@ DependencyPropertyChangedEventArgs e scroll._scrollingVertically = scroll.IsScrollingVertically; } - private static void IsScrollingHorizontally_OnChanged( + private static void OnIsScrollingHorizontallyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -201,7 +201,7 @@ DependencyPropertyChangedEventArgs e scroll._scrollingHorizontally = scroll.IsScrollingHorizontally; } - private static void MinimalChangeProperty_OnChanged( + private static void OnMinimalChangeChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -214,7 +214,7 @@ DependencyPropertyChangedEventArgs e scroll._minimalChange = scroll.MinimalChange; } - private static void TimeoutProperty_OnChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnTimeoutChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not DynamicScrollViewer scroll) { diff --git a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs index 75c4231c3..4d68ad345 100644 --- a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs +++ b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs @@ -33,7 +33,7 @@ protected WindowInteropHelper InteropHelper nameof(WindowCornerPreference), typeof(WindowCornerPreference), typeof(FluentWindow), - new PropertyMetadata(WindowCornerPreference.Round, OnCornerPreferenceChanged) + new PropertyMetadata(WindowCornerPreference.Round, OnWindowCornerPreferenceChanged) ); /// @@ -43,7 +43,7 @@ protected WindowInteropHelper InteropHelper nameof(WindowBackdropType), typeof(WindowBackdropType), typeof(FluentWindow), - new PropertyMetadata(WindowBackdropType.None, OnBackdropTypeChanged) + new PropertyMetadata(WindowBackdropType.None, OnWindowBackdropTypeChanged) ); /// @@ -120,7 +120,7 @@ protected override void OnSourceInitialized(EventArgs e) /// /// Private property callback. /// - private static void OnCornerPreferenceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnWindowCornerPreferenceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not FluentWindow window) { @@ -157,7 +157,7 @@ WindowCornerPreference newValue /// /// Private property callback. /// - private static void OnBackdropTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnWindowBackdropTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not FluentWindow window) { diff --git a/src/Wpf.Ui/Controls/IconElement/IconElement.cs b/src/Wpf.Ui/Controls/IconElement/IconElement.cs index d1d0f3def..c86f9d316 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElement.cs @@ -33,7 +33,7 @@ static IconElement() new FrameworkPropertyMetadata( SystemColors.ControlTextBrush, FrameworkPropertyMetadataOptions.Inherits, - static (d, args) => ((IconElement)d).OnForegroundPropertyChanged(args) + static (d, args) => ((IconElement)d).OnForegroundChanged(args) ) ); @@ -51,7 +51,7 @@ public Brush Foreground protected abstract UIElement InitializeChildren(); - protected virtual void OnForegroundPropertyChanged(DependencyPropertyChangedEventArgs args) { } + protected virtual void OnForegroundChanged(DependencyPropertyChangedEventArgs args) { } private void EnsureLayoutRoot() { diff --git a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs index 6a2a3968e..5c4f73ba7 100644 --- a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs @@ -21,7 +21,7 @@ public class ImageIcon : IconElement new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, - OnSourcePropertyChanged + OnSourceChanged ) ); @@ -30,7 +30,7 @@ public class ImageIcon : IconElement /// public ImageSource? Source { - get => (ImageSource)GetValue(SourceProperty); + get => (ImageSource?)GetValue(SourceProperty); set => SetValue(SourceProperty, value); } @@ -43,7 +43,7 @@ protected override UIElement InitializeChildren() return Image; } - private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ImageIcon self = (ImageIcon)d; diff --git a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs index c79293f75..007599820 100644 --- a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs +++ b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs @@ -46,12 +46,11 @@ public class InfoBadge : System.Windows.Controls.Control nameof(CornerRadius), typeof(CornerRadius), typeof(InfoBadge), - (PropertyMetadata) - new FrameworkPropertyMetadata( - (object)new CornerRadius(8), - FrameworkPropertyMetadataOptions.AffectsMeasure - | FrameworkPropertyMetadataOptions.AffectsRender - ) + new FrameworkPropertyMetadata( + new CornerRadius(8), + FrameworkPropertyMetadataOptions.AffectsMeasure + | FrameworkPropertyMetadataOptions.AffectsRender + ) ); /// @@ -77,8 +76,8 @@ public string Value /// public CornerRadius CornerRadius { - get => (CornerRadius)GetValue(ValueProperty); - set => SetValue(ValueProperty, value); + get => (CornerRadius)GetValue(CornerRadiusProperty); + set => SetValue(CornerRadiusProperty, value); } /// @@ -87,7 +86,7 @@ public CornerRadius CornerRadius [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } } diff --git a/src/Wpf.Ui/Controls/Menu/MenuItem.cs b/src/Wpf.Ui/Controls/Menu/MenuItem.cs index a2f6111cb..26dc5e71b 100644 --- a/src/Wpf.Ui/Controls/Menu/MenuItem.cs +++ b/src/Wpf.Ui/Controls/Menu/MenuItem.cs @@ -19,6 +19,7 @@ static MenuItem() /// /// Gets or sets displayed . /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0012:CLR property type should match registered type", Justification = "seems harmless")] public new IconElement Icon { get => (IconElement)GetValue(IconProperty); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index 8a9b9872b..4bb4267b8 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -143,7 +143,7 @@ public partial class NavigationView nameof(IsPaneOpen), typeof(bool), typeof(NavigationView), - new FrameworkPropertyMetadata(true, IsPaneOpenChangedCallback) + new FrameworkPropertyMetadata(true, OnIsPaneOpenChanged) ); /// @@ -213,7 +213,7 @@ public partial class NavigationView nameof(PaneDisplayMode), typeof(NavigationViewPaneDisplayMode), typeof(NavigationView), - new FrameworkPropertyMetadata(NavigationViewPaneDisplayMode.Left, OnPaneDisplayModePropertyChanged) + new FrameworkPropertyMetadata(NavigationViewPaneDisplayMode.Left, OnPaneDisplayModeChanged) ); /// @@ -223,7 +223,7 @@ public partial class NavigationView nameof(AutoSuggestBox), typeof(AutoSuggestBox), typeof(NavigationView), - new FrameworkPropertyMetadata(null, OnAutoSuggestBoxPropertyChangedCallback) + new FrameworkPropertyMetadata(null, OnAutoSuggestBoxChanged) ); /// @@ -233,7 +233,7 @@ public partial class NavigationView nameof(TitleBar), typeof(TitleBar), typeof(NavigationView), - new FrameworkPropertyMetadata(null, OnTitleBarPropertyChangedCallback) + new FrameworkPropertyMetadata(null, OnTitleBarChanged) ); /// @@ -243,7 +243,7 @@ public partial class NavigationView nameof(BreadcrumbBar), typeof(BreadcrumbBar), typeof(NavigationView), - new FrameworkPropertyMetadata(null, OnBreadcrumbBarPropertyChangedCallback) + new FrameworkPropertyMetadata(null, OnBreadcrumbBarChanged) ); /// @@ -256,7 +256,7 @@ public partial class NavigationView new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.AffectsMeasure, - OnItemTemplatePropertyChanged + OnItemTemplateChanged ) ); @@ -566,7 +566,7 @@ DependencyPropertyChangedEventArgs e } } - private static void OnPaneDisplayModePropertyChanged( + private static void OnPaneDisplayModeChanged( DependencyObject? d, DependencyPropertyChangedEventArgs e ) @@ -579,7 +579,7 @@ DependencyPropertyChangedEventArgs e navigationView.OnPaneDisplayModeChanged(); } - private static void OnItemTemplatePropertyChanged( + private static void OnItemTemplateChanged( DependencyObject? d, DependencyPropertyChangedEventArgs e ) @@ -592,7 +592,7 @@ DependencyPropertyChangedEventArgs e navigationView.OnItemTemplateChanged(); } - private static void IsPaneOpenChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnIsPaneOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not NavigationView navigationView) { @@ -623,7 +623,7 @@ private static void IsPaneOpenChangedCallback(DependencyObject d, DependencyProp UpdateVisualState(navigationView); } - private static void OnTitleBarPropertyChangedCallback( + private static void OnTitleBarChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -660,7 +660,7 @@ DependencyPropertyChangedEventArgs e } } - private static void OnAutoSuggestBoxPropertyChangedCallback( + private static void OnAutoSuggestBoxChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -695,7 +695,7 @@ DependencyPropertyChangedEventArgs e } } - private static void OnBreadcrumbBarPropertyChangedCallback( + private static void OnBreadcrumbBarChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index e51cb2245..81eaaf8a2 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -201,7 +201,7 @@ public bool IsPaneOpen [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } @@ -215,13 +215,13 @@ public string TargetPageTag /// public Type? TargetPageType { - get => (Type)GetValue(TargetPageTypeProperty); + get => (Type?)GetValue(TargetPageTypeProperty); set => SetValue(TargetPageTypeProperty, value); } public InfoBadge? InfoBadge { - get => (InfoBadge)GetValue(InfoBadgeProperty); + get => (InfoBadge?)GetValue(InfoBadgeProperty); set => SetValue(InfoBadgeProperty, value); } diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index caed296f0..2ded15f10 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -34,7 +34,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, - OnValuePropertyChanged, + OnValueChanged, null, false, UpdateSourceTrigger.LostFocus @@ -128,7 +128,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox nameof(NumberFormatter), typeof(INumberFormatter), typeof(NumberBox), - new PropertyMetadata(null, OnNumberFormatterPropertyChanged) + new PropertyMetadata(null, OnNumberFormatterChanged) ); /// @@ -207,9 +207,9 @@ public bool AcceptsExpression /// /// Gets or sets the number formatter. /// - public INumberFormatter NumberFormatter + public INumberFormatter? NumberFormatter { - get => (INumberFormatter)GetValue(NumberFormatterProperty); + get => (INumberFormatter?)GetValue(NumberFormatterProperty); set => SetValue(NumberFormatterProperty, value); } @@ -500,7 +500,7 @@ private INumberFormatter GetRegionalSettingsAwareDecimalFormatter() return new ValidateNumberFormatter(); } - private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not NumberBox numberBox) { @@ -510,7 +510,7 @@ private static void OnValuePropertyChanged(DependencyObject d, DependencyPropert numberBox.OnValueChanged(d, (double?)e.OldValue); } - private static void OnNumberFormatterPropertyChanged( + private static void OnNumberFormatterChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index e0635d56b..34fab84eb 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -27,7 +27,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox nameof(Password), typeof(string), typeof(PasswordBox), - new PropertyMetadata(String.Empty, OnPasswordPropertyChanged) + new PropertyMetadata(String.Empty, OnPasswordChanged) ); /// @@ -37,7 +37,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox nameof(PasswordChar), typeof(char), typeof(PasswordBox), - new PropertyMetadata('*', OnPasswordCharPropertyChanged) + new PropertyMetadata('*', OnPasswordCharChanged) ); /// @@ -47,7 +47,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox nameof(IsPasswordRevealed), typeof(bool), typeof(PasswordBox), - new PropertyMetadata(false, OnPasswordRevealModePropertyChanged) + new PropertyMetadata(false, OnIsPasswordRevealedChanged) ); /// @@ -303,7 +303,7 @@ private void UpdateTextContents(bool isTriggeredByTextInput) /// /// Called when is changed. /// - private static void OnPasswordPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not PasswordBox control) { @@ -316,7 +316,7 @@ private static void OnPasswordPropertyChanged(DependencyObject d, DependencyProp /// /// Called if the character is changed in the during the run. /// - private static void OnPasswordCharPropertyChanged( + private static void OnPasswordCharChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -332,7 +332,7 @@ DependencyPropertyChangedEventArgs e /// /// Called if the reveal mode is changed in the during the run. /// - private static void OnPasswordRevealModePropertyChanged( + private static void OnIsPasswordRevealedChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index 668387b7a..89f9f7837 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -22,7 +22,7 @@ public class ProgressRing : System.Windows.Controls.Control nameof(Progress), typeof(double), typeof(ProgressRing), - new PropertyMetadata(50d, PropertyChangedCallback) + new PropertyMetadata(50d, OnProgressChanged) ); /// @@ -166,7 +166,7 @@ protected void UpdateProgressAngle() /// /// Validates the entered and redraws the . /// - protected static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + protected static void OnProgressChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not ProgressRing control) { diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index 64ab430f2..7df1c47ab 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -43,7 +43,7 @@ private enum StarValue nameof(Value), typeof(double), typeof(RatingControl), - new PropertyMetadata(0.0D, OnValuePropertyChanged) + new PropertyMetadata(0.0D, OnValueChanged) ); /// @@ -401,7 +401,7 @@ private int ExtractValueFromOffset(double offset) return starValue; } - private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not RatingControl ratingControl) { diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index 80611efec..e421cabb2 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -197,7 +197,7 @@ public TimeSpan Timeout /// /// Gets or sets the title of the . /// - public object Title + public object? Title { get => GetValue(TitleProperty); set => SetValue(TitleProperty, value); @@ -206,9 +206,9 @@ public object Title /// /// Gets or sets the title template of the . /// - public DataTemplate TitleTemplate + public DataTemplate? TitleTemplate { - get => (DataTemplate)GetValue(TitleTemplateProperty); + get => (DataTemplate?)GetValue(TitleTemplateProperty); set => SetValue(TitleTemplateProperty, value); } @@ -218,7 +218,7 @@ public DataTemplate TitleTemplate [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs index 05a63222a..1e249d68b 100644 --- a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs +++ b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs @@ -8,9 +8,10 @@ namespace Wpf.Ui.Controls; public class SnackbarPresenter : System.Windows.Controls.ContentPresenter { + [System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0012:CLR property type should match registered type", Justification = "seems harmless")] public new Snackbar? Content { - get => (Snackbar)GetValue(ContentProperty); + get => (Snackbar?)GetValue(ContentProperty); protected set => SetValue(ContentProperty, value); } diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index c168fd27f..9cc187ff3 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -34,7 +34,7 @@ public class SplitButton : Wpf.Ui.Controls.Button nameof(Flyout), typeof(object), typeof(SplitButton), - new PropertyMetadata(null, OnFlyoutChangedCallback) + new PropertyMetadata(null, OnFlyoutChanged) ); /// @@ -81,15 +81,15 @@ public SplitButton() }; } - private static void OnFlyoutChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnFlyoutChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is SplitButton dropDownButton) { - dropDownButton.OnFlyoutChangedCallback(e.NewValue); + dropDownButton.OnFlyoutChanged(e.NewValue); } } - protected virtual void OnFlyoutChangedCallback(object value) + protected virtual void OnFlyoutChanged(object value) { if (value is ContextMenu contextMenu) { diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index f6ceafc33..d22ab3d46 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -105,9 +105,9 @@ public class TextBox : System.Windows.Controls.TextBox /// /// Gets or sets displayed . /// - public IconElement Icon + public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index cebe30df9..50a47d781 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -247,16 +247,16 @@ public Appearance.ApplicationTheme ApplicationTheme /// /// Gets or sets title displayed on the left. /// - public string Title + public string? Title { - get => (string)GetValue(TitleProperty); + get => (string?)GetValue(TitleProperty); set => SetValue(TitleProperty, value); } /// /// Gets or sets the content displayed in the . /// - public object Header + public object? Header { get => GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); @@ -350,7 +350,7 @@ public bool CanMaximize /// public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index c0394dfc9..e738f9ba9 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -20,7 +20,7 @@ public class TitleBarButton : Wpf.Ui.Controls.Button nameof(ButtonType), typeof(TitleBarButtonType), typeof(TitleBarButton), - new PropertyMetadata(TitleBarButtonType.Unknown, ButtonTypePropertyCallback) + new PropertyMetadata(TitleBarButtonType.Unknown, OnButtonTypeChanged) ); /// @@ -83,7 +83,7 @@ public Brush ButtonsForeground /// public Brush? MouseOverButtonsForeground { - get => (Brush)GetValue(MouseOverButtonsForegroundProperty); + get => (Brush?)GetValue(MouseOverButtonsForegroundProperty); set => SetValue(MouseOverButtonsForegroundProperty, value); } @@ -225,7 +225,7 @@ private void UpdateReturnValue(TitleBarButtonType buttonType) => _ => throw new ArgumentOutOfRangeException(nameof(buttonType), buttonType, null) }; - private static void ButtonTypePropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnButtonTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var titleBarButton = (TitleBarButton)d; titleBarButton.UpdateReturnValue((TitleBarButtonType)e.NewValue); diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs index 3f3ab9b4b..b6281d352 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs @@ -20,7 +20,7 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton /// Property for . /// public static readonly DependencyProperty OffContentProperty = DependencyProperty.Register( - "OffContent", + nameof(OffContent), typeof(object), typeof(ToggleSwitch), new PropertyMetadata(null) @@ -30,7 +30,7 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton /// Property for . /// public static readonly DependencyProperty OnContentProperty = DependencyProperty.Register( - "OnContent", + nameof(OnContent), typeof(object), typeof(ToggleSwitch), new PropertyMetadata(null) @@ -41,7 +41,7 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton /// has state of "Off". /// [Bindable(true)] - public object OffContent + public object? OffContent { get => GetValue(OffContentProperty); set => SetValue(OffContentProperty, value); @@ -52,7 +52,7 @@ public object OffContent /// has state of "On". /// [Bindable(true)] - public object OnContent + public object? OnContent { get => GetValue(OnContentProperty); set => SetValue(OnContentProperty, value); diff --git a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs index 70738ecc5..c2ad76cba 100644 --- a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs +++ b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs @@ -27,7 +27,7 @@ public class TreeViewItem : System.Windows.Controls.TreeViewItem [Bindable(true), Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } } diff --git a/src/Wpf.Ui/Interop/Libraries.cs b/src/Wpf.Ui/Interop/Libraries.cs index 50c746af9..9b8cca8fd 100644 --- a/src/Wpf.Ui/Interop/Libraries.cs +++ b/src/Wpf.Ui/Interop/Libraries.cs @@ -13,8 +13,9 @@ internal static class Libraries /*internal const string Advapi32 = "advapi32.dll"; internal const string BCrypt = "BCrypt.dll"; internal const string CoreComm_L1_1_1 = "api-ms-win-core-comm-l1-1-1.dll"; - internal const string Crypt32 = "crypt32.dll"; - internal const string Error_L1 = "api-ms-win-core-winrt-error-l1-1-0.dll"; + internal const string Crypt32 = "crypt32.dll";*/ + internal const string Dwmapi = "dwmapi.dll"; + /*internal const string Error_L1 = "api-ms-win-core-winrt-error-l1-1-0.dll"; internal const string HttpApi = "httpapi.dll"; internal const string IpHlpApi = "iphlpapi.dll";*/ internal const string Kernel32 = "kernel32.dll"; From 3388a5eac555f1291c459c44613969a5e1e9b510 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 17:02:02 -0700 Subject: [PATCH 07/33] Fix documentation warnings WPF0108, WPF0060, SA1642, SA1623 --- src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs | 2 +- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 63 +++------- src/Wpf.Ui.Tray/INotifyIcon.cs | 10 +- src/Wpf.Ui.Tray/INotifyIconService.cs | 6 +- src/Wpf.Ui.Tray/Interop/Shell32.cs | 5 +- src/Wpf.Ui.Tray/Interop/User32.cs | 14 +-- src/Wpf.Ui.Tray/TrayData.cs | 2 +- src/Wpf.Ui/Controls/Arc/Arc.cs | 10 +- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 44 ++----- src/Wpf.Ui/Controls/Badge/Badge.cs | 4 +- .../Controls/BreadcrumbBar/BreadcrumbBar.cs | 12 +- .../BreadcrumbBar/BreadcrumbBarItem.cs | 16 +-- src/Wpf.Ui/Controls/Button/Button.cs | 42 ++----- .../CalendarDatePicker/CalendarDatePicker.cs | 16 +-- src/Wpf.Ui/Controls/Card/Card.cs | 12 +- src/Wpf.Ui/Controls/CardAction/CardAction.cs | 10 +- src/Wpf.Ui/Controls/CardColor/CardColor.cs | 24 +--- .../Controls/CardControl/CardControl.cs | 14 +-- .../Controls/CardExpander/CardExpander.cs | 12 +- .../Controls/ContentDialog/ContentDialog.cs | 112 +++++------------- src/Wpf.Ui/Controls/ControlsServices.cs | 2 - src/Wpf.Ui/Controls/DataGrid/DataGrid.cs | 12 +- .../Controls/DropDownButton/DropDownButton.cs | 10 +- .../DynamicScrollBar/DynamicScrollBar.cs | 16 +-- .../DynamicScrollViewer.cs | 16 +-- .../Controls/FluentWindow/FluentWindow.cs | 20 +--- src/Wpf.Ui/Controls/Flyout/Flyout.cs | 16 +-- .../HyperlinkButton/HyperlinkButton.cs | 6 +- src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 22 +--- .../Controls/IconElement/IconElement.cs | 4 +- .../Controls/IconElement/IconSourceElement.cs | 4 +- src/Wpf.Ui/Controls/IconElement/ImageIcon.cs | 4 +- src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs | 10 +- .../Controls/IconSource/FontIconSource.cs | 20 +--- src/Wpf.Ui/Controls/IconSource/IconSource.cs | 6 +- .../Controls/IconSource/SymbolIconSource.cs | 22 +--- src/Wpf.Ui/Controls/Image/Image.cs | 25 +--- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs | 16 +-- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 68 ++++------- .../NavigationView.Navigation.cs | 3 + .../NavigationView.Properties.cs | 105 +++++----------- .../NavigationView.TemplateParts.cs | 3 + .../NavigationView/NavigationViewActivator.cs | 8 +- .../NavigationViewContentPresenter.cs | 14 +-- .../NavigationView/NavigationViewItem.cs | 33 ++---- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 46 ++----- .../Controls/PasswordBox/PasswordBox.cs | 23 +--- .../Controls/ProgressRing/ProgressRing.cs | 32 ++--- .../Controls/RatingControl/RatingControl.cs | 22 ++-- .../Controls/RichTextBox/RichTextBox.cs | 8 +- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 60 +++------- .../Controls/SplitButton/SplitButton.cs | 10 +- src/Wpf.Ui/Controls/TextBlock/TextBlock.cs | 12 +- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 46 +++---- src/Wpf.Ui/Controls/TimePicker/TimePicker.cs | 20 +--- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 106 ++++++----------- .../Controls/TitleBar/TitleBarButton.cs | 22 ++-- .../Controls/ToggleSwitch/ToggleSwitch.cs | 16 +-- src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs | 14 +-- src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs | 4 +- src/Wpf.Ui/Controls/TypedEventHandler.cs | 8 +- .../VirtualizingGridView.cs | 14 +-- .../VirtualizingItemsControl.cs | 6 +- .../VirtualizingWrapPanel.cs | 28 ++--- src/Wpf.Ui/Interop/Shell32.cs | 5 +- src/Wpf.Ui/Win32/Utilities.cs | 18 +-- 66 files changed, 430 insertions(+), 985 deletions(-) diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs b/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs index f01f5f9f0..1484a122e 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs @@ -16,7 +16,7 @@ public class PageService : IPageService private readonly IServiceProvider _serviceProvider; /// - /// Creates new instance and attaches the . + /// Initializes a new instance of the class and attaches the . /// public PageService(IServiceProvider serviceProvider) { diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 3b572d339..9ca7946f6 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -39,27 +39,22 @@ public class NotifyIcon : System.Windows.FrameworkElement #region Public variables - /// public int Id => this.internalNotifyIconManager.Id; /// - /// Whether the icon is registered in the tray menu. + /// Gets a value indicating whether the icon is registered in the tray menu. /// public bool IsRegistered => this.internalNotifyIconManager.IsRegistered; - /// public HwndSource? HookWindow { get; set; } - /// public IntPtr ParentHandle { get; set; } #endregion #region Properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TooltipTextProperty = DependencyProperty.Register( nameof(TooltipText), typeof(string), @@ -67,9 +62,7 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata(String.Empty, OnTooltipTextChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FocusOnLeftClickProperty = DependencyProperty.Register( nameof(FocusOnLeftClick), typeof(bool), @@ -77,9 +70,7 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata(true, OnFocusOnLeftClickChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MenuOnRightClickProperty = DependencyProperty.Register( nameof(MenuOnRightClick), typeof(bool), @@ -87,9 +78,7 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata(true, OnMenuOnRightClickChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(ImageSource), @@ -97,9 +86,7 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata((ImageSource)null!, OnIconChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MenuProperty = DependencyProperty.Register( nameof(Menu), typeof(ContextMenu), @@ -107,9 +94,7 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata(null, OnMenuChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MenuFontSizeProperty = DependencyProperty.Register( nameof(MenuFontSize), typeof(double), @@ -117,7 +102,6 @@ public class NotifyIcon : System.Windows.FrameworkElement new PropertyMetadata(14d) ); - /// public string TooltipText { get => (string)GetValue(TooltipTextProperty); @@ -125,7 +109,7 @@ public string TooltipText } /// - /// Gets or sets the value indicating whether to show the on single right click. + /// Gets or sets a value indicating whether to show the on single right click. /// public bool MenuOnRightClick { @@ -134,7 +118,7 @@ public bool MenuOnRightClick } /// - /// Gets or sets the value indicating whether to focus the on single left click. + /// Gets or sets a value indicating whether to focus the on single left click. /// public bool FocusOnLeftClick { @@ -142,7 +126,6 @@ public bool FocusOnLeftClick set => SetValue(FocusOnLeftClickProperty, value); } - /// public ImageSource Icon { get => (ImageSource)GetValue(IconProperty); @@ -150,7 +133,7 @@ public ImageSource Icon } /// - /// Context menu. + /// Gets or sets the context menu. /// public ContextMenu? Menu { @@ -168,9 +151,7 @@ public double MenuFontSize #region Events - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent LeftClickEvent = EventManager.RegisterRoutedEvent( nameof(LeftClick), RoutingStrategy.Bubble, @@ -178,9 +159,7 @@ public double MenuFontSize typeof(NotifyIcon) ); - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent LeftDoubleClickEvent = EventManager.RegisterRoutedEvent( nameof(LeftDoubleClick), RoutingStrategy.Bubble, @@ -188,9 +167,7 @@ public double MenuFontSize typeof(NotifyIcon) ); - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent RightClickEvent = EventManager.RegisterRoutedEvent( nameof(RightClick), RoutingStrategy.Bubble, @@ -198,9 +175,7 @@ public double MenuFontSize typeof(NotifyIcon) ); - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent RightDoubleClickEvent = EventManager.RegisterRoutedEvent( nameof(RightDoubleClick), RoutingStrategy.Bubble, @@ -208,9 +183,7 @@ public double MenuFontSize typeof(NotifyIcon) ); - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent MiddleClickEvent = EventManager.RegisterRoutedEvent( nameof(MiddleClick), RoutingStrategy.Bubble, @@ -218,9 +191,7 @@ public double MenuFontSize typeof(NotifyIcon) ); - /// - /// Registration for . - /// + /// Identifies the routed event. public static readonly RoutedEvent MiddleDoubleClickEvent = EventManager.RegisterRoutedEvent( nameof(MiddleDoubleClick), RoutingStrategy.Bubble, @@ -294,7 +265,7 @@ public NotifyIcon() } /// - /// Control finalizer. + /// Finalizes an instance of the class. /// ~NotifyIcon() => Dispose(false); diff --git a/src/Wpf.Ui.Tray/INotifyIcon.cs b/src/Wpf.Ui.Tray/INotifyIcon.cs index 1852a4bb7..13108eab4 100644 --- a/src/Wpf.Ui.Tray/INotifyIcon.cs +++ b/src/Wpf.Ui.Tray/INotifyIcon.cs @@ -17,17 +17,17 @@ namespace Wpf.Ui.Tray; internal interface INotifyIcon { /// - /// Notify icon shell data. + /// Gets or sets the notify icon shell data. /// public Interop.Shell32.NOTIFYICONDATA ShellIconData { get; set; } /// - /// Whether the icon is currently registered in the tray area. + /// Gets or sets a value indicating whether the icon is currently registered in the tray area. /// bool IsRegistered { get; set; } /// - /// Gets the Shell identifier of the icon. + /// Gets or sets the Shell identifier of the icon. /// int Id { get; set; } @@ -52,12 +52,12 @@ internal interface INotifyIcon ContextMenu? ContextMenu { get; set; } /// - /// Gets or sets the value indicating whether to focus the on single left click. + /// Gets or sets a value indicating whether to focus the on single left click. /// bool FocusOnLeftClick { get; set; } /// - /// Gets or sets the value indicating whether to show the on single right click. + /// Gets or sets a value indicating whether to show the on single right click. /// bool MenuOnRightClick { get; set; } diff --git a/src/Wpf.Ui.Tray/INotifyIconService.cs b/src/Wpf.Ui.Tray/INotifyIconService.cs index 6fc0f3d51..27cab614a 100644 --- a/src/Wpf.Ui.Tray/INotifyIconService.cs +++ b/src/Wpf.Ui.Tray/INotifyIconService.cs @@ -15,12 +15,12 @@ namespace Wpf.Ui.Tray; public interface INotifyIconService { /// - /// Whether the notify icon is registered in the tray. + /// Gets the notify icon id. /// public int Id { get; } /// - /// Whether the notify icon is registered in the tray. + /// Gets a value indicating whether the notify icon is registered in the tray. /// public bool IsRegistered { get; } @@ -30,7 +30,7 @@ public interface INotifyIconService public string TooltipText { get; set; } /// - /// Context menu displayed after clicking the icon. + /// Gets or sets the context menu displayed after clicking the icon. /// ContextMenu? ContextMenu { get; set; } diff --git a/src/Wpf.Ui.Tray/Interop/Shell32.cs b/src/Wpf.Ui.Tray/Interop/Shell32.cs index 12377b2f8..d91eeb8c0 100644 --- a/src/Wpf.Ui.Tray/Interop/Shell32.cs +++ b/src/Wpf.Ui.Tray/Interop/Shell32.cs @@ -158,7 +158,7 @@ public static extern int SHCreateItemFromParsingName( /// /// Sets the User Model AppID for the current process, enabling Windows to retrieve this ID /// - /// + /// The string ID to be assigned [DllImport(Libraries.Shell32, PreserveSig = false)] public static extern void SetCurrentProcessExplicitAppUserModelID( [MarshalAs(UnmanagedType.LPWStr)] string AppID @@ -167,7 +167,8 @@ public static extern void SetCurrentProcessExplicitAppUserModelID( /// /// Retrieves the User Model AppID that has been explicitly set for the current process via SetCurrentProcessExplicitAppUserModelID /// - /// + /// Out parameter that receives the string ID. + /// An HRESULT indicating success (S_OK) or failure of the operation. If the function fails, the returned AppID is null. [DllImport(Libraries.Shell32)] public static extern int GetCurrentProcessExplicitAppUserModelID( [Out, MarshalAs(UnmanagedType.LPWStr)] out string AppID diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs index 57dd7f598..0a5a3dcf3 100644 --- a/src/Wpf.Ui.Tray/Interop/User32.cs +++ b/src/Wpf.Ui.Tray/Interop/User32.cs @@ -899,7 +899,7 @@ public static extern bool ChangeWindowMessageFilterEx( /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -917,7 +917,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -934,7 +934,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -951,7 +951,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure will receive the message. /// The message to be sent. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// The return value specifies the result of the message processing; it depends on the message sent. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern int SendMessage( @@ -1086,7 +1086,7 @@ public static IntPtr CreateWindowEx( /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Unicode)] public static extern IntPtr DefWindowProcW( @@ -1104,7 +1104,7 @@ [In] IntPtr lParam /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern IntPtr DefWindowProcA( @@ -1121,7 +1121,7 @@ [In] IntPtr lParam /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern IntPtr DefWindowProc( diff --git a/src/Wpf.Ui.Tray/TrayData.cs b/src/Wpf.Ui.Tray/TrayData.cs index 791a5e84e..a701b5f8c 100644 --- a/src/Wpf.Ui.Tray/TrayData.cs +++ b/src/Wpf.Ui.Tray/TrayData.cs @@ -13,7 +13,7 @@ namespace Wpf.Ui.Tray; internal static class TrayData { /// - /// Collection of registered tray icons. + /// Gets or sets the collection of registered tray icons. /// public static List NotifyIcons { get; set; } = new(); } diff --git a/src/Wpf.Ui/Controls/Arc/Arc.cs b/src/Wpf.Ui/Controls/Arc/Arc.cs index ef3d37b4c..4d14713a8 100644 --- a/src/Wpf.Ui/Controls/Arc/Arc.cs +++ b/src/Wpf.Ui/Controls/Arc/Arc.cs @@ -22,13 +22,9 @@ namespace Wpf.Ui.Controls; /// Visibility="Visible" /> /// /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(Arc), "Arc.bmp")] public class Arc : System.Windows.Shapes.Shape { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty StartAngleProperty = DependencyProperty.Register( nameof(StartAngle), typeof(double), @@ -36,9 +32,7 @@ public class Arc : System.Windows.Shapes.Shape new PropertyMetadata(0.0d, PropertyChangedCallback) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty EndAngleProperty = DependencyProperty.Register( nameof(EndAngle), typeof(double), diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 159258548..26c0c3fe9 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -36,9 +36,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl protected const string ElementSuggestionsPopup = "PART_SuggestionsPopup"; protected const string ElementSuggestionsList = "PART_SuggestionsList"; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OriginalItemsSourceProperty = DependencyProperty.Register( nameof(OriginalItemsSource), typeof(IList), @@ -46,9 +44,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(Array.Empty()) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsSuggestionListOpenProperty = DependencyProperty.Register( nameof(IsSuggestionListOpen), typeof(bool), @@ -56,9 +52,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TextProperty = DependencyProperty.Register( nameof(Text), typeof(string), @@ -66,9 +60,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(String.Empty, OnTextChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register( nameof(PlaceholderText), typeof(string), @@ -76,9 +68,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty UpdateTextOnSelectProperty = DependencyProperty.Register( nameof(UpdateTextOnSelect), typeof(bool), @@ -86,9 +76,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MaxSuggestionListHeightProperty = DependencyProperty.Register( nameof(MaxSuggestionListHeight), typeof(double), @@ -96,9 +84,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -106,9 +92,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FocusCommandProperty = DependencyProperty.Register( nameof(FocusCommand), typeof(ICommand), @@ -190,9 +174,7 @@ public IconElement? Icon /// public ICommand FocusCommand => (ICommand)GetValue(FocusCommandProperty); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent QuerySubmittedEvent = EventManager.RegisterRoutedEvent( nameof(QuerySubmitted), RoutingStrategy.Bubble, @@ -200,9 +182,7 @@ public IconElement? Icon typeof(AutoSuggestBox) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent SuggestionChosenEvent = EventManager.RegisterRoutedEvent( nameof(SuggestionChosen), RoutingStrategy.Bubble, @@ -210,9 +190,7 @@ public IconElement? Icon typeof(AutoSuggestBox) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent TextChangedEvent = EventManager.RegisterRoutedEvent( nameof(TextChanged), RoutingStrategy.Bubble, diff --git a/src/Wpf.Ui/Controls/Badge/Badge.cs b/src/Wpf.Ui/Controls/Badge/Badge.cs index 4236d28d8..2106341f9 100644 --- a/src/Wpf.Ui/Controls/Badge/Badge.cs +++ b/src/Wpf.Ui/Controls/Badge/Badge.cs @@ -20,9 +20,7 @@ namespace Wpf.Ui.Controls; /// public class Badge : System.Windows.Controls.ContentControl, IAppearanceControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register( nameof(Appearance), typeof(Controls.ControlAppearance), diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index 0be5f9061..b408bc6dd 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -25,9 +25,7 @@ namespace Wpf.Ui.Controls; [StyleTypedProperty(Property = nameof(ItemContainerStyle), StyleTargetType = typeof(BreadcrumbBarItem))] public class BreadcrumbBar : System.Windows.Controls.ItemsControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CommandProperty = DependencyProperty.Register( nameof(Command), typeof(ICommand), @@ -35,9 +33,7 @@ public class BreadcrumbBar : System.Windows.Controls.ItemsControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -50,9 +46,7 @@ public class BreadcrumbBar : System.Windows.Controls.ItemsControl /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ItemClickedEvent = EventManager.RegisterRoutedEvent( nameof(ItemClicked), RoutingStrategy.Bubble, diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index 5bbcad3d4..8ca69ce7b 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -14,9 +14,7 @@ namespace Wpf.Ui.Controls; /// public class BreadcrumbBarItem : System.Windows.Controls.ContentControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -24,9 +22,7 @@ public class BreadcrumbBarItem : System.Windows.Controls.ContentControl new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconMarginProperty = DependencyProperty.Register( nameof(IconMargin), typeof(Thickness), @@ -34,9 +30,7 @@ public class BreadcrumbBarItem : System.Windows.Controls.ContentControl new PropertyMetadata(new Thickness(0)) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsLastProperty = DependencyProperty.Register( nameof(IsLast), typeof(bool), @@ -54,7 +48,7 @@ public IconElement? Icon } /// - /// Get or sets margin for the + /// Gets or sets get or sets margin for the /// public Thickness IconMargin { @@ -63,7 +57,7 @@ public Thickness IconMargin } /// - /// Whether the current item is the last one. + /// Gets or sets a value indicating whether the current item is the last one. /// public bool IsLast { diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index 55495aebc..63e799fcb 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -31,9 +31,7 @@ namespace Wpf.Ui.Controls; /// public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -41,9 +39,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register( nameof(Appearance), typeof(ControlAppearance), @@ -51,9 +47,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(ControlAppearance.Primary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MouseOverBackgroundProperty = DependencyProperty.Register( nameof(MouseOverBackground), typeof(Brush), @@ -61,9 +55,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(Border.BackgroundProperty.DefaultMetadata.DefaultValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MouseOverBorderBrushProperty = DependencyProperty.Register( nameof(MouseOverBorderBrush), typeof(Brush), @@ -71,9 +63,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(Border.BorderBrushProperty.DefaultMetadata.DefaultValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PressedForegroundProperty = DependencyProperty.Register( nameof(PressedForeground), typeof(Brush), @@ -84,9 +74,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PressedBackgroundProperty = DependencyProperty.Register( nameof(PressedBackground), typeof(Brush), @@ -94,9 +82,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(Border.BackgroundProperty.DefaultMetadata.DefaultValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PressedBorderBrushProperty = DependencyProperty.Register( nameof(PressedBorderBrush), typeof(Brush), @@ -104,9 +90,7 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC new PropertyMetadata(Border.BorderBrushProperty.DefaultMetadata.DefaultValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof(CornerRadius), @@ -136,7 +120,7 @@ public ControlAppearance Appearance } /// - /// Background when the user interacts with an element with a pointing device. + /// Gets or sets background . /// [Bindable(true), Category("Appearance")] public Brush MouseOverBackground @@ -146,7 +130,7 @@ public Brush MouseOverBackground } /// - /// Border when the user interacts with an element with a pointing device. + /// Gets or sets border when the user mouses over the button. /// [Bindable(true), Category("Appearance")] public Brush MouseOverBorderBrush @@ -156,7 +140,7 @@ public Brush MouseOverBorderBrush } /// - /// Foreground when pressed. + /// Gets or sets the foreground when the user clicks the button. /// [Bindable(true), Category("Appearance")] public Brush PressedForeground @@ -166,7 +150,7 @@ public Brush PressedForeground } /// - /// Background when the user clicks the button. + /// Gets or sets background when the user clicks the button. /// [Bindable(true), Category("Appearance")] public Brush PressedBackground @@ -176,7 +160,7 @@ public Brush PressedBackground } /// - /// Border when the user clicks the button. + /// Gets or sets border when the user clicks the button. /// [Bindable(true), Category("Appearance")] public Brush PressedBorderBrush diff --git a/src/Wpf.Ui/Controls/CalendarDatePicker/CalendarDatePicker.cs b/src/Wpf.Ui/Controls/CalendarDatePicker/CalendarDatePicker.cs index 09a60a97d..1267a64c0 100644 --- a/src/Wpf.Ui/Controls/CalendarDatePicker/CalendarDatePicker.cs +++ b/src/Wpf.Ui/Controls/CalendarDatePicker/CalendarDatePicker.cs @@ -23,9 +23,7 @@ public class CalendarDatePicker : Wpf.Ui.Controls.Button { private Popup? _popup; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsCalendarOpenProperty = DependencyProperty.Register( nameof(IsCalendarOpen), typeof(bool), @@ -33,9 +31,7 @@ public class CalendarDatePicker : Wpf.Ui.Controls.Button new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsTodayHighlightedProperty = DependencyProperty.Register( nameof(IsTodayHighlighted), typeof(bool), @@ -43,9 +39,7 @@ public class CalendarDatePicker : Wpf.Ui.Controls.Button new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DateProperty = DependencyProperty.Register( nameof(Date), typeof(DateTime?), @@ -53,9 +47,7 @@ public class CalendarDatePicker : Wpf.Ui.Controls.Button new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FirstDayOfWeekProperty = DependencyProperty.Register( nameof(FirstDayOfWeek), typeof(DayOfWeek), diff --git a/src/Wpf.Ui/Controls/Card/Card.cs b/src/Wpf.Ui/Controls/Card/Card.cs index ed0c9b2df..c0656e058 100644 --- a/src/Wpf.Ui/Controls/Card/Card.cs +++ b/src/Wpf.Ui/Controls/Card/Card.cs @@ -9,13 +9,9 @@ namespace Wpf.Ui.Controls; /// /// Simple Card with content and . /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(Card), "Card.bmp")] public class Card : System.Windows.Controls.ContentControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FooterProperty = DependencyProperty.Register( nameof(Footer), typeof(object), @@ -23,9 +19,7 @@ public class Card : System.Windows.Controls.ContentControl new PropertyMetadata(null, OnFooterChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HasFooterProperty = DependencyProperty.Register( nameof(HasFooter), typeof(bool), @@ -43,7 +37,7 @@ public object? Footer } /// - /// Gets information whether the has a . + /// Gets a value indicating whether the has a . /// public bool HasFooter { diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index 64713907c..8f54bf12d 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class CardAction : System.Windows.Controls.Primitives.ButtonBase { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsChevronVisibleProperty = DependencyProperty.Register( nameof(IsChevronVisible), typeof(bool), @@ -23,9 +21,7 @@ public class CardAction : System.Windows.Controls.Primitives.ButtonBase new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -34,7 +30,7 @@ public class CardAction : System.Windows.Controls.Primitives.ButtonBase ); /// - /// Gets or sets information whether to display the chevron icon on the right side of the card. + /// Gets or sets a value indicating whether to display the chevron icon on the right side of the card. /// [Bindable(true), Category("Appearance")] public bool IsChevronVisible diff --git a/src/Wpf.Ui/Controls/CardColor/CardColor.cs b/src/Wpf.Ui/Controls/CardColor/CardColor.cs index 89fe5c6c4..91a8cdc9f 100644 --- a/src/Wpf.Ui/Controls/CardColor/CardColor.cs +++ b/src/Wpf.Ui/Controls/CardColor/CardColor.cs @@ -11,9 +11,7 @@ namespace Wpf.Ui.Controls; /// public class CardColor : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(string), @@ -21,9 +19,7 @@ public class CardColor : System.Windows.Controls.Control new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SubtitleProperty = DependencyProperty.Register( nameof(Subtitle), typeof(string), @@ -31,9 +27,7 @@ public class CardColor : System.Windows.Controls.Control new PropertyMetadata(String.Empty, OnSubtitleChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SubtitleFontSizeProperty = DependencyProperty.Register( nameof(SubtitleFontSize), typeof(double), @@ -41,9 +35,7 @@ public class CardColor : System.Windows.Controls.Control new PropertyMetadata(11.0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ColorProperty = DependencyProperty.Register( nameof(Color), typeof(Color), @@ -51,9 +43,7 @@ public class CardColor : System.Windows.Controls.Control new PropertyMetadata(Color.FromArgb(0, 0, 0, 0), OnColorChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty BrushProperty = DependencyProperty.Register( nameof(Brush), typeof(Brush), @@ -64,9 +54,7 @@ public class CardColor : System.Windows.Controls.Control ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CardBrushProperty = DependencyProperty.Register( nameof(CardBrush), typeof(Brush), diff --git a/src/Wpf.Ui/Controls/CardControl/CardControl.cs b/src/Wpf.Ui/Controls/CardControl/CardControl.cs index f14648927..976faf821 100644 --- a/src/Wpf.Ui/Controls/CardControl/CardControl.cs +++ b/src/Wpf.Ui/Controls/CardControl/CardControl.cs @@ -15,9 +15,7 @@ namespace Wpf.Ui.Controls; /// public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( nameof(Header), typeof(object), @@ -25,9 +23,7 @@ public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconC new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -35,9 +31,7 @@ public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconC new PropertyMetadata(null) ); - /// - /// Property for - /// + /// Identifies the dependency property. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof(CornerRadius), @@ -46,7 +40,7 @@ public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconC ); /// - /// Header is the data used to for the header of each item in the control. + /// Gets or sets header which is used for each item in the control. /// [Bindable(true)] public object? Header diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 9f369c63a..819d7c935 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class CardExpander : System.Windows.Controls.Expander { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -23,9 +21,7 @@ public class CardExpander : System.Windows.Controls.Expander new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof(CornerRadius), @@ -33,9 +29,7 @@ public class CardExpander : System.Windows.Controls.Expander new PropertyMetadata(new CornerRadius(4)) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ContentPaddingProperty = DependencyProperty.Register( nameof(ContentPadding), typeof(Thickness), diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 8685ede76..0063c0b1c 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -45,9 +45,7 @@ public class ContentDialog : ContentControl { #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(object), @@ -55,9 +53,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleTemplateProperty = DependencyProperty.Register( nameof(TitleTemplate), typeof(DataTemplate), @@ -65,9 +61,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DialogWidthProperty = DependencyProperty.Register( nameof(DialogWidth), typeof(double), @@ -75,9 +69,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(Double.PositiveInfinity) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DialogHeightProperty = DependencyProperty.Register( nameof(DialogHeight), typeof(double), @@ -85,9 +77,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(Double.PositiveInfinity) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DialogMaxWidthProperty = DependencyProperty.Register( nameof(DialogMaxWidth), typeof(double), @@ -95,9 +85,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(Double.PositiveInfinity) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DialogMaxHeightProperty = DependencyProperty.Register( nameof(DialogMaxHeight), typeof(double), @@ -105,18 +93,14 @@ public class ContentDialog : ContentControl new PropertyMetadata(Double.PositiveInfinity) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DialogMarginProperty = DependencyProperty.Register( nameof(DialogMargin), typeof(Thickness), typeof(ContentDialog) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonTextProperty = DependencyProperty.Register( nameof(PrimaryButtonText), typeof(string), @@ -124,9 +108,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonTextProperty = DependencyProperty.Register( nameof(SecondaryButtonText), typeof(string), @@ -134,9 +116,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonTextProperty = DependencyProperty.Register( nameof(CloseButtonText), typeof(string), @@ -144,9 +124,7 @@ public class ContentDialog : ContentControl new PropertyMetadata("Close") ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonIconProperty = DependencyProperty.Register( nameof(PrimaryButtonIcon), typeof(IconElement), @@ -154,9 +132,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonIconProperty = DependencyProperty.Register( nameof(SecondaryButtonIcon), typeof(IconElement), @@ -164,9 +140,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonIconProperty = DependencyProperty.Register( nameof(CloseButtonIcon), typeof(IconElement), @@ -174,9 +148,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPrimaryButtonEnabledProperty = DependencyProperty.Register( nameof(IsPrimaryButtonEnabled), typeof(bool), @@ -184,9 +156,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsSecondaryButtonEnabledProperty = DependencyProperty.Register( nameof(IsSecondaryButtonEnabled), typeof(bool), @@ -194,9 +164,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonAppearanceProperty = DependencyProperty.Register( nameof(PrimaryButtonAppearance), typeof(ControlAppearance), @@ -204,9 +172,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(ControlAppearance.Primary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonAppearanceProperty = DependencyProperty.Register( nameof(SecondaryButtonAppearance), typeof(ControlAppearance), @@ -214,9 +180,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(ControlAppearance.Secondary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonAppearanceProperty = DependencyProperty.Register( nameof(CloseButtonAppearance), typeof(ControlAppearance), @@ -224,9 +188,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(ControlAppearance.Secondary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty DefaultButtonProperty = DependencyProperty.Register( nameof(DefaultButton), typeof(ContentDialogButton), @@ -234,9 +196,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(ContentDialogButton.Primary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsFooterVisibleProperty = DependencyProperty.Register( nameof(IsFooterVisible), typeof(bool), @@ -244,9 +204,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -254,9 +212,7 @@ public class ContentDialog : ContentControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( nameof(Opened), RoutingStrategy.Bubble, @@ -264,9 +220,7 @@ public class ContentDialog : ContentControl typeof(ContentDialog) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ClosingEvent = EventManager.RegisterRoutedEvent( nameof(Closing), RoutingStrategy.Bubble, @@ -274,9 +228,7 @@ public class ContentDialog : ContentControl typeof(ContentDialog) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent( nameof(Closed), RoutingStrategy.Bubble, @@ -284,9 +236,7 @@ public class ContentDialog : ContentControl typeof(ContentDialog) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ButtonClickedEvent = EventManager.RegisterRoutedEvent( nameof(ButtonClicked), RoutingStrategy.Bubble, @@ -416,7 +366,7 @@ public IconElement? CloseButtonIcon } /// - /// Gets or sets whether the primary button is enabled. + /// Gets or sets a value indicating whether the primary button is enabled. /// public bool IsPrimaryButtonEnabled { @@ -425,7 +375,7 @@ public bool IsPrimaryButtonEnabled } /// - /// Gets or sets whether the secondary button is enabled. + /// Gets or sets a value indicating whether the secondary button is enabled. /// public bool IsSecondaryButtonEnabled { @@ -470,7 +420,7 @@ public ContentDialogButton DefaultButton } /// - /// Gets or sets a value that indicates the visibility of the footer buttons. + /// Gets or sets a value indicating whether the footer buttons are visible. /// public bool IsFooterVisible { @@ -479,7 +429,7 @@ public bool IsFooterVisible } /// - /// Command triggered after clicking the button in the template. + /// Gets command triggered after clicking the button in the template. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); @@ -634,9 +584,9 @@ protected virtual void OnClosed(ContentDialogResult result) } /// - /// Occurs after the is clicked + /// Invoked when a is clicked. /// - /// + /// The button that was clicked. protected virtual void OnButtonClick(ContentDialogButton button) { ContentDialogButtonClickEventArgs buttonClickEventArgs = new ContentDialogButtonClickEventArgs( diff --git a/src/Wpf.Ui/Controls/ControlsServices.cs b/src/Wpf.Ui/Controls/ControlsServices.cs index e357b3fa2..dcf8844db 100644 --- a/src/Wpf.Ui/Controls/ControlsServices.cs +++ b/src/Wpf.Ui/Controls/ControlsServices.cs @@ -16,8 +16,6 @@ public static class ControlsServices /// /// Accepts a ServiceProvider for configuring dependency injection. /// - /// - /// public static void Initialize(IServiceProvider? serviceProvider) { if (serviceProvider == null) diff --git a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs index 17f3b6892..d1b71b040 100644 --- a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs +++ b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs @@ -16,9 +16,7 @@ namespace Wpf.Ui.Controls; /// public class DataGrid : System.Windows.Controls.DataGrid { - /// - /// The DependencyProperty that represents the property. - /// + /// Identifies the dependency property. public static readonly DependencyProperty CheckBoxColumnElementStyleProperty = DependencyProperty.Register( nameof(CheckBoxColumnElementStyle), @@ -27,9 +25,7 @@ public class DataGrid : System.Windows.Controls.DataGrid new FrameworkPropertyMetadata(null) ); - /// - /// The DependencyProperty that represents the property. - /// + /// Identifies the dependency property. public static readonly DependencyProperty CheckBoxColumnEditingElementStyleProperty = DependencyProperty.Register( nameof(CheckBoxColumnEditingElementStyle), @@ -39,7 +35,7 @@ public class DataGrid : System.Windows.Controls.DataGrid ); /// - /// A style to apply to all checkbox column in the DataGrid + /// Gets or sets the style which is applied to all checkbox column in the DataGrid /// public Style? CheckBoxColumnElementStyle { @@ -48,7 +44,7 @@ public Style? CheckBoxColumnElementStyle } /// - /// A style to apply to all checkbox column in the DataGrid + /// Gets or sets the style for all the column checkboxes in the DataGrid /// public Style? CheckBoxColumnEditingElementStyle { diff --git a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs index 7ae2a4062..522dd023a 100644 --- a/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs +++ b/src/Wpf.Ui/Controls/DropDownButton/DropDownButton.cs @@ -15,9 +15,7 @@ public class DropDownButton : Button { private ContextMenu? _contextMenu; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FlyoutProperty = DependencyProperty.Register( nameof(Flyout), typeof(object), @@ -25,9 +23,7 @@ public class DropDownButton : Button new PropertyMetadata(null, OnFlyoutChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register( nameof(IsDropDownOpen), typeof(bool), @@ -67,6 +63,8 @@ private static void OnFlyoutChanged(DependencyObject d, DependencyPropertyChange } } + /// This method is invoked when the changes. + /// The new value of . protected virtual void OnFlyoutChanged(object value) { if (value is ContextMenu contextMenu) diff --git a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs index e06aacac7..2b425c7bd 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs @@ -19,9 +19,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar private readonly EventIdentifier _interactiveIdentifier = new(); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsScrollingProperty = DependencyProperty.Register( nameof(IsScrolling), typeof(bool), @@ -29,9 +27,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar new PropertyMetadata(false, OnIsScrollingChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsInteractedProperty = DependencyProperty.Register( nameof(IsInteracted), typeof(bool), @@ -39,9 +35,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar new PropertyMetadata(false, OnIsInteractedChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TimeoutProperty = DependencyProperty.Register( nameof(Timeout), typeof(int), @@ -50,7 +44,7 @@ public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar ); /// - /// Gets or sets information whether the user was scrolling for the last few seconds. + /// Gets or sets a value indicating whether the user was recently scrolling in the last few seconds. /// public bool IsScrolling { @@ -59,7 +53,7 @@ public bool IsScrolling } /// - /// Informs whether the user has taken an action related to scrolling. + /// Gets or sets a value indicating whether the user has taken an action related to scrolling. /// public bool IsInteracted { diff --git a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs index 834b45e5d..fd3f29074 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs @@ -29,9 +29,7 @@ public class DynamicScrollViewer : PassiveScrollViewer private double _minimalChange = 40d; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsScrollingVerticallyProperty = DependencyProperty.Register( nameof(IsScrollingVertically), typeof(bool), @@ -39,9 +37,7 @@ public class DynamicScrollViewer : PassiveScrollViewer new PropertyMetadata(false, OnIsScrollingVerticallyChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsScrollingHorizontallyProperty = DependencyProperty.Register( nameof(IsScrollingHorizontally), typeof(bool), @@ -49,9 +45,7 @@ public class DynamicScrollViewer : PassiveScrollViewer new PropertyMetadata(false, OnIsScrollingHorizontallyChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MinimalChangeProperty = DependencyProperty.Register( nameof(MinimalChange), typeof(double), @@ -59,9 +53,7 @@ public class DynamicScrollViewer : PassiveScrollViewer new PropertyMetadata(40d, OnMinimalChangeChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TimeoutProperty = DependencyProperty.Register( nameof(Timeout), typeof(int), diff --git a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs index 4d68ad345..954d7f00b 100644 --- a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs +++ b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs @@ -12,23 +12,19 @@ namespace Wpf.Ui.Controls; /// /// A custom WinUI Window with more convenience methods. /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(FluentWindow), "FluentWindow.bmp")] public class FluentWindow : System.Windows.Window { private WindowInteropHelper? _interopHelper = null; /// - /// Contains helper for accessing this window handle. + /// Gets contains helper for accessing this window handle. /// protected WindowInteropHelper InteropHelper { get => _interopHelper ??= new WindowInteropHelper(this); } - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty WindowCornerPreferenceProperty = DependencyProperty.Register( nameof(WindowCornerPreference), typeof(WindowCornerPreference), @@ -36,9 +32,7 @@ protected WindowInteropHelper InteropHelper new PropertyMetadata(WindowCornerPreference.Round, OnWindowCornerPreferenceChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty WindowBackdropTypeProperty = DependencyProperty.Register( nameof(WindowBackdropType), typeof(WindowBackdropType), @@ -46,9 +40,7 @@ protected WindowInteropHelper InteropHelper new PropertyMetadata(WindowBackdropType.None, OnWindowBackdropTypeChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ExtendsContentIntoTitleBarProperty = DependencyProperty.Register( nameof(ExtendsContentIntoTitleBar), @@ -76,7 +68,7 @@ public WindowBackdropType WindowBackdropType } /// - /// Gets or sets a value that specifies whether the default title bar of the window should be hidden to create space for app content. + /// Gets or sets a value indicating whether the default title bar of the window should be hidden to create space for app content. /// public bool ExtendsContentIntoTitleBar { @@ -85,7 +77,7 @@ public bool ExtendsContentIntoTitleBar } /// - /// Initializes static members of the class. + /// Initializes a new instance of the class. /// public FluentWindow() { diff --git a/src/Wpf.Ui/Controls/Flyout/Flyout.cs b/src/Wpf.Ui/Controls/Flyout/Flyout.cs index 0a3baf9f7..446bf27e7 100644 --- a/src/Wpf.Ui/Controls/Flyout/Flyout.cs +++ b/src/Wpf.Ui/Controls/Flyout/Flyout.cs @@ -18,9 +18,7 @@ public class Flyout : System.Windows.Controls.ContentControl private System.Windows.Controls.Primitives.Popup? _popup = default; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register( nameof(IsOpen), typeof(bool), @@ -28,9 +26,7 @@ public class Flyout : System.Windows.Controls.ContentControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PlacementProperty = DependencyProperty.Register( nameof(Placement), typeof(PlacementMode), @@ -38,9 +34,7 @@ public class Flyout : System.Windows.Controls.ContentControl new PropertyMetadata(PlacementMode.Top) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( nameof(Opened), RoutingStrategy.Bubble, @@ -48,9 +42,7 @@ public class Flyout : System.Windows.Controls.ContentControl typeof(Flyout) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent( nameof(Closed), RoutingStrategy.Bubble, diff --git a/src/Wpf.Ui/Controls/HyperlinkButton/HyperlinkButton.cs b/src/Wpf.Ui/Controls/HyperlinkButton/HyperlinkButton.cs index 1b109dba8..60be1880b 100644 --- a/src/Wpf.Ui/Controls/HyperlinkButton/HyperlinkButton.cs +++ b/src/Wpf.Ui/Controls/HyperlinkButton/HyperlinkButton.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class HyperlinkButton : Wpf.Ui.Controls.Button { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty NavigateUriProperty = DependencyProperty.Register( nameof(NavigateUri), typeof(string), @@ -24,7 +22,7 @@ public class HyperlinkButton : Wpf.Ui.Controls.Button ); /// - /// The URL (or application shortcut) to open. + /// Gets or sets the URL (or application shortcut) to open. /// public string NavigateUri { diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index 11343efe5..2ace9f6a2 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -15,15 +15,11 @@ namespace Wpf.Ui.Controls; /// /// Represents an icon that uses a glyph from the specified font. /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(FontIcon), "FontIcon.bmp")] public class FontIcon : IconElement { #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register( nameof(FontFamily), typeof(FontFamily), @@ -31,9 +27,7 @@ public class FontIcon : IconElement new FrameworkPropertyMetadata(SystemFonts.MessageFontFamily, OnFontFamilyChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner( typeof(FontIcon), new FrameworkPropertyMetadata( @@ -43,9 +37,7 @@ public class FontIcon : IconElement ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register( nameof(FontStyle), typeof(FontStyle), @@ -53,9 +45,7 @@ public class FontIcon : IconElement new FrameworkPropertyMetadata(FontStyles.Normal, OnFontStyleChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register( nameof(FontWeight), typeof(FontWeight), @@ -63,9 +53,7 @@ public class FontIcon : IconElement new FrameworkPropertyMetadata(FontWeights.Normal, OnFontWeightChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register( nameof(Glyph), typeof(string), diff --git a/src/Wpf.Ui/Controls/IconElement/IconElement.cs b/src/Wpf.Ui/Controls/IconElement/IconElement.cs index c86f9d316..708047776 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElement.cs @@ -25,9 +25,7 @@ static IconElement() ); } - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ForegroundProperty = TextElement.ForegroundProperty.AddOwner( typeof(IconElement), new FrameworkPropertyMetadata( diff --git a/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs b/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs index d45ec388f..90241627c 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconSourceElement.cs @@ -15,9 +15,7 @@ namespace Wpf.Ui.Controls; [ContentProperty(nameof(IconSource))] public class IconSourceElement : IconElement { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register( nameof(IconSource), typeof(IconSource), diff --git a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs index 5c4f73ba7..bd5201a67 100644 --- a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs @@ -11,9 +11,7 @@ namespace Wpf.Ui.Controls; /// public class ImageIcon : IconElement { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( nameof(Source), typeof(ImageSource), diff --git a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs index e610ff72d..387adce2e 100644 --- a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class SymbolIcon : FontIcon { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register( nameof(Symbol), typeof(SymbolRegular), @@ -23,9 +21,7 @@ public class SymbolIcon : FontIcon new PropertyMetadata(SymbolRegular.Empty, static (o, _) => ((SymbolIcon)o).OnGlyphChanged()) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FilledProperty = DependencyProperty.Register( nameof(Filled), typeof(bool), @@ -43,7 +39,7 @@ public SymbolRegular Symbol } /// - /// Defines whether or not we should use the . + /// Gets or sets a value indicating whether or not we should use the . /// public bool Filled { diff --git a/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs b/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs index 46110ba1f..923225bd5 100644 --- a/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs +++ b/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class FontIconSource : IconSource { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register( nameof(FontFamily), typeof(FontFamily), @@ -23,9 +21,7 @@ public class FontIconSource : IconSource new PropertyMetadata(SystemFonts.MessageFontFamily) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register( nameof(FontSize), typeof(double), @@ -33,9 +29,7 @@ public class FontIconSource : IconSource new PropertyMetadata(SystemFonts.MessageFontSize) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register( nameof(FontStyle), typeof(FontStyle), @@ -43,9 +37,7 @@ public class FontIconSource : IconSource new PropertyMetadata(FontStyles.Normal) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register( nameof(FontWeight), typeof(FontWeight), @@ -53,9 +45,7 @@ public class FontIconSource : IconSource new PropertyMetadata(FontWeights.Normal) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register( nameof(Glyph), typeof(string), diff --git a/src/Wpf.Ui/Controls/IconSource/IconSource.cs b/src/Wpf.Ui/Controls/IconSource/IconSource.cs index fdf5b588a..dd07efcd3 100644 --- a/src/Wpf.Ui/Controls/IconSource/IconSource.cs +++ b/src/Wpf.Ui/Controls/IconSource/IconSource.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public abstract class IconSource : DependencyObject { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register( nameof(Foreground), typeof(Brush), @@ -23,9 +21,7 @@ public abstract class IconSource : DependencyObject new FrameworkPropertyMetadata(SystemColors.ControlTextBrush) ); - /// /// - /// public Brush Foreground { get => (Brush)GetValue(ForegroundProperty); diff --git a/src/Wpf.Ui/Controls/IconSource/SymbolIconSource.cs b/src/Wpf.Ui/Controls/IconSource/SymbolIconSource.cs index 6a865d18a..95a548503 100644 --- a/src/Wpf.Ui/Controls/IconSource/SymbolIconSource.cs +++ b/src/Wpf.Ui/Controls/IconSource/SymbolIconSource.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class SymbolIconSource : IconSource { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register( nameof(FontSize), typeof(double), @@ -23,9 +21,7 @@ public class SymbolIconSource : IconSource new PropertyMetadata(SystemFonts.MessageFontSize) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register( nameof(FontStyle), typeof(FontStyle), @@ -33,9 +29,7 @@ public class SymbolIconSource : IconSource new PropertyMetadata(FontStyles.Normal) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register( nameof(FontWeight), typeof(FontWeight), @@ -43,9 +37,7 @@ public class SymbolIconSource : IconSource new PropertyMetadata(FontWeights.Normal) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register( nameof(Symbol), typeof(SymbolRegular), @@ -53,9 +45,7 @@ public class SymbolIconSource : IconSource new PropertyMetadata(SymbolRegular.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FilledProperty = DependencyProperty.Register( nameof(Filled), typeof(bool), @@ -94,7 +84,7 @@ public SymbolRegular Symbol } /// - /// Defines whether or not we should use the . + /// Gets or sets a value indicating whether or not we should use the . /// public bool Filled { diff --git a/src/Wpf.Ui/Controls/Image/Image.cs b/src/Wpf.Ui/Controls/Image/Image.cs index d7dc5884e..23c49cd78 100644 --- a/src/Wpf.Ui/Controls/Image/Image.cs +++ b/src/Wpf.Ui/Controls/Image/Image.cs @@ -13,10 +13,7 @@ namespace Wpf.Ui.Controls; /// public class Image : Control { - /// - /// Gets or sets the Source on this Image. - /// The Source property is the ImageSource that holds the actual image drawn. - /// + /// Identifies the dependency property. public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( nameof(Source), typeof(ImageSource), @@ -30,9 +27,7 @@ public class Image : Control null ); - /// - /// DependencyProperty for CornerRadius property. - /// + /// Identifies the dependency property. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof(CornerRadius), @@ -40,9 +35,7 @@ public class Image : Control new PropertyMetadata(new CornerRadius(0), new PropertyChangedCallback(OnCornerRadiusChanged)) ); - /// - /// DependencyProperty for StretchDirection property. - /// + /// Identifies the dependency property. /// public static readonly DependencyProperty StretchProperty = DependencyProperty.Register( nameof(Stretch), @@ -55,9 +48,7 @@ public class Image : Control null ); - /// - /// DependencyProperty for Stretch property. - /// + /// Identifies the dependency property. public static readonly DependencyProperty StretchDirectionProperty = DependencyProperty.Register( nameof(StretchDirection), typeof(StretchDirection), @@ -69,9 +60,7 @@ public class Image : Control null ); - /// - /// DependencyPropertyKey for InnerCornerRadius property. - /// + /// Identifies the dependency property. public static readonly DependencyPropertyKey InnerCornerRadiusPropertyKey = DependencyProperty.RegisterReadOnly( nameof(InnerCornerRadius), @@ -80,9 +69,7 @@ public class Image : Control new PropertyMetadata(new CornerRadius(0)) ); - /// - /// DependencyProperty for InnerCornerRadius property. - /// + /// Identifies the dependency property. public static readonly DependencyProperty InnerCornerRadiusProperty = InnerCornerRadiusPropertyKey.DependencyProperty; diff --git a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs index 007599820..8c8f88e2f 100644 --- a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs +++ b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs @@ -9,9 +9,7 @@ namespace Wpf.Ui.Controls; public class InfoBadge : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -19,9 +17,7 @@ public class InfoBadge : System.Windows.Controls.Control new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SeverityProperty = DependencyProperty.Register( nameof(Severity), typeof(InfoBadgeSeverity), @@ -29,9 +25,7 @@ public class InfoBadge : System.Windows.Controls.Control new PropertyMetadata(InfoBadgeSeverity.Informational) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( nameof(Value), typeof(string), @@ -39,9 +33,7 @@ public class InfoBadge : System.Windows.Controls.Control new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof(CornerRadius), diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 1a467f49d..3db5aab79 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -17,9 +17,7 @@ public class MessageBox : System.Windows.Window { #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register( nameof(ShowTitle), typeof(bool), @@ -27,9 +25,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonTextProperty = DependencyProperty.Register( nameof(PrimaryButtonText), typeof(string), @@ -37,9 +33,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonTextProperty = DependencyProperty.Register( nameof(SecondaryButtonText), typeof(string), @@ -47,9 +41,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonTextProperty = DependencyProperty.Register( nameof(CloseButtonText), typeof(string), @@ -57,9 +49,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata("Close") ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonIconProperty = DependencyProperty.Register( nameof(PrimaryButtonIcon), typeof(SymbolRegular), @@ -67,9 +57,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(SymbolRegular.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonIconProperty = DependencyProperty.Register( nameof(SecondaryButtonIcon), typeof(SymbolRegular), @@ -77,9 +65,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(SymbolRegular.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonIconProperty = DependencyProperty.Register( nameof(CloseButtonIcon), typeof(SymbolRegular), @@ -87,9 +73,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(SymbolRegular.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PrimaryButtonAppearanceProperty = DependencyProperty.Register( nameof(PrimaryButtonAppearance), typeof(ControlAppearance), @@ -97,9 +81,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(ControlAppearance.Primary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SecondaryButtonAppearanceProperty = DependencyProperty.Register( nameof(SecondaryButtonAppearance), typeof(ControlAppearance), @@ -107,9 +89,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(ControlAppearance.Secondary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseButtonAppearanceProperty = DependencyProperty.Register( nameof(CloseButtonAppearance), typeof(ControlAppearance), @@ -117,9 +97,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(ControlAppearance.Secondary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPrimaryButtonEnabledProperty = DependencyProperty.Register( nameof(IsPrimaryButtonEnabled), typeof(bool), @@ -127,9 +105,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsSecondaryButtonEnabledProperty = DependencyProperty.Register( nameof(IsSecondaryButtonEnabled), typeof(bool), @@ -137,9 +113,7 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -152,7 +126,7 @@ public class MessageBox : System.Windows.Window #region Properties /// - /// Gets or sets a value that determines whether to show the in . + /// Gets or sets a value indicating whether to show the in . /// public bool ShowTitle { @@ -242,7 +216,7 @@ public ControlAppearance CloseButtonAppearance } /// - /// Gets or sets whether the primary button is enabled. + /// Gets or sets a value indicating whether the primary button is enabled. /// public bool IsSecondaryButtonEnabled { @@ -251,7 +225,7 @@ public bool IsSecondaryButtonEnabled } /// - /// Gets or sets whether the secondary button is enabled. + /// Gets or sets a value indicating whether the secondary button is enabled. /// public bool IsPrimaryButtonEnabled { @@ -260,7 +234,7 @@ public bool IsPrimaryButtonEnabled } /// - /// Command triggered after clicking the button on the Footer. + /// Gets the command triggered after clicking the button on the Footer. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); @@ -307,7 +281,7 @@ public MessageBox() /// Displays a message box /// /// - /// + /// Thrown if the operation is canceled. public async Task ShowDialogAsync( bool showAsDialog = true, CancellationToken cancellationToken = default @@ -356,9 +330,9 @@ protected virtual void OnLoaded() } /// - /// Sets Width and Height + /// Resizes the MessageBox to fit the content's size, including margins. /// - /// + /// The root element of the MessageBox protected virtual void ResizeToContentSize(UIElement rootElement) { Size desiredSize = rootElement.DesiredSize; @@ -398,7 +372,7 @@ protected virtual void CenterWindowOnScreen() /// /// Occurs after the is clicked /// - /// + /// The MessageBox button protected virtual void OnButtonClick(MessageBoxButton button) { MessageBoxResult result = button switch diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 47029026e..4ff942ca9 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -10,6 +10,9 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines navigation logic and state management for . +/// public partial class NavigationView { protected readonly List Journal = new(50); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index 4bb4267b8..be8ccafce 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -12,11 +12,12 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines the dependency properties and dp callbacks for control +/// public partial class NavigationView { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty EnableDebugMessagesProperty = DependencyProperty.Register( nameof(EnableDebugMessages), typeof(bool), @@ -24,9 +25,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( nameof(Header), typeof(object), @@ -34,9 +33,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeaderVisibilityProperty = DependencyProperty.Register( nameof(HeaderVisibility), typeof(Visibility), @@ -44,9 +41,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(Visibility.Visible) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AlwaysShowHeaderProperty = DependencyProperty.Register( nameof(AlwaysShowHeader), typeof(bool), @@ -64,9 +59,7 @@ public partial class NavigationView /// Identifies the dependency property. public static readonly DependencyProperty MenuItemsProperty = MenuItemsPropertyKey.DependencyProperty; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MenuItemsSourceProperty = DependencyProperty.Register( nameof(MenuItemsSource), typeof(object), @@ -86,9 +79,7 @@ public partial class NavigationView public static readonly DependencyProperty FooterMenuItemsProperty = FooterMenuItemsPropertyKey.DependencyProperty; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FooterMenuItemsSourceProperty = DependencyProperty.Register( nameof(FooterMenuItemsSource), typeof(object), @@ -96,9 +87,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null, OnFooterMenuItemsSourceChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ContentOverlayProperty = DependencyProperty.Register( nameof(ContentOverlay), typeof(object), @@ -106,9 +95,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsBackEnabledProperty = DependencyProperty.Register( nameof(IsBackEnabled), typeof(bool), @@ -116,9 +103,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty.Register( nameof(IsBackButtonVisible), typeof(NavigationViewBackButtonVisible), @@ -126,9 +111,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(NavigationViewBackButtonVisible.Auto) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPaneToggleVisibleProperty = DependencyProperty.Register( nameof(IsPaneToggleVisible), typeof(bool), @@ -136,9 +119,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPaneOpenProperty = DependencyProperty.Register( nameof(IsPaneOpen), typeof(bool), @@ -146,9 +127,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(true, OnIsPaneOpenChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPaneVisibleProperty = DependencyProperty.Register( nameof(IsPaneVisible), typeof(bool), @@ -156,9 +135,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OpenPaneLengthProperty = DependencyProperty.Register( nameof(OpenPaneLength), typeof(double), @@ -166,9 +143,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(0D) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CompactPaneLengthProperty = DependencyProperty.Register( nameof(CompactPaneLength), typeof(double), @@ -176,9 +151,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(0D) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PaneHeaderProperty = DependencyProperty.Register( nameof(PaneHeader), typeof(object), @@ -186,9 +159,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PaneTitleProperty = DependencyProperty.Register( nameof(PaneTitle), typeof(string), @@ -196,9 +167,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PaneFooterProperty = DependencyProperty.Register( nameof(PaneFooter), typeof(object), @@ -206,9 +175,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PaneDisplayModeProperty = DependencyProperty.Register( nameof(PaneDisplayMode), typeof(NavigationViewPaneDisplayMode), @@ -216,9 +183,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(NavigationViewPaneDisplayMode.Left, OnPaneDisplayModeChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AutoSuggestBoxProperty = DependencyProperty.Register( nameof(AutoSuggestBox), typeof(AutoSuggestBox), @@ -226,9 +191,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null, OnAutoSuggestBoxChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleBarProperty = DependencyProperty.Register( nameof(TitleBar), typeof(TitleBar), @@ -236,9 +199,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null, OnTitleBarChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty BreadcrumbBarProperty = DependencyProperty.Register( nameof(BreadcrumbBar), typeof(BreadcrumbBar), @@ -246,9 +207,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(null, OnBreadcrumbBarChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register( nameof(ItemTemplate), typeof(ControlTemplate), @@ -260,9 +219,7 @@ public partial class NavigationView ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TransitionDurationProperty = DependencyProperty.Register( nameof(TransitionDuration), typeof(int), @@ -270,9 +227,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(200) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TransitionProperty = DependencyProperty.Register( nameof(Transition), typeof(Transition), @@ -280,9 +235,7 @@ public partial class NavigationView new FrameworkPropertyMetadata(Transition.FadeInWithSlide) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FrameMarginProperty = DependencyProperty.Register( nameof(FrameMargin), typeof(Thickness), @@ -291,7 +244,7 @@ public partial class NavigationView ); /// - /// Enables or disables debugging messages for this control + /// Gets or sets a value indicating whether debugging messages for this control are enabled /// public bool EnableDebugMessages { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs index d354f3d54..ced7ead58 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs @@ -9,6 +9,9 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines the template parts for the control +/// [TemplatePart( Name = TemplateElementNavigationViewContentPresenter, Type = typeof(NavigationViewContentPresenter) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs index 190786fcc..69b6008c3 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs @@ -101,11 +101,11 @@ internal static class NavigationViewActivator } /// - /// Picks a constructor which has the most satisfiable arguments count. + /// Picks the constructor with the highest number of satisfiable parameters based on the provided context. /// - /// - /// - /// + /// Array of constructors to evaluate. + /// Context used to determine parameter satisfaction. + /// The constructor with the most satisfiable arguments, or null if none are fully satisfiable. private static ConstructorInfo? FitBestConstructor(ConstructorInfo[] parameterfullCtors, object? dataContext) { return parameterfullCtors diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index cb507a5d4..08e127e46 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -14,9 +14,7 @@ namespace Wpf.Ui.Controls; public class NavigationViewContentPresenter : Frame { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TransitionDurationProperty = DependencyProperty.Register( nameof(TransitionDuration), typeof(int), @@ -24,9 +22,7 @@ public class NavigationViewContentPresenter : Frame new FrameworkPropertyMetadata(200) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TransitionProperty = DependencyProperty.Register( nameof(Transition), typeof(Transition), @@ -34,9 +30,7 @@ public class NavigationViewContentPresenter : Frame new FrameworkPropertyMetadata(Transition.FadeInWithSlide) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsDynamicScrollViewerEnabledProperty = DependencyProperty.Register( nameof(IsDynamicScrollViewerEnabled), @@ -62,7 +56,7 @@ public Transition Transition } /// - /// Gets a value indicating whether the dynamic scroll viewer is enabled. + /// Gets or sets a value indicating whether the dynamic scroll viewer is enabled. /// public bool IsDynamicScrollViewerEnabled { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index 81eaaf8a2..e6d55b819 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -47,6 +47,7 @@ public class NavigationViewItem new PropertyMetadata(null, OnMenuItemsSourceChanged) ); + /// Identifies the dependency property. internal static readonly DependencyPropertyKey HasMenuItemsPropertyKey = DependencyProperty.RegisterReadOnly( nameof(HasMenuItems), @@ -59,9 +60,7 @@ public class NavigationViewItem public static readonly DependencyProperty HasMenuItemsProperty = HasMenuItemsPropertyKey.DependencyProperty; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register( nameof(IsActive), typeof(bool), @@ -69,9 +68,7 @@ public class NavigationViewItem new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPaneOpenProperty = DependencyProperty.Register( nameof(IsPaneOpen), typeof(bool), @@ -79,9 +76,7 @@ public class NavigationViewItem new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( nameof(IsExpanded), typeof(bool), @@ -89,9 +84,7 @@ public class NavigationViewItem new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -99,9 +92,7 @@ public class NavigationViewItem new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TargetPageTagProperty = DependencyProperty.Register( nameof(TargetPageTag), typeof(string), @@ -109,9 +100,7 @@ public class NavigationViewItem new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TargetPageTypeProperty = DependencyProperty.Register( nameof(TargetPageType), typeof(Type), @@ -119,9 +108,7 @@ public class NavigationViewItem new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty InfoBadgeProperty = DependencyProperty.Register( nameof(InfoBadge), typeof(InfoBadge), @@ -129,9 +116,7 @@ public class NavigationViewItem new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty NavigationCacheModeProperty = DependencyProperty.Register( nameof(NavigationCacheMode), typeof(NavigationCacheMode), diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index 2ded15f10..c23053d91 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -24,9 +24,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox private bool _textUpdating; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( nameof(Value), typeof(double?), @@ -41,9 +39,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MaxDecimalPlacesProperty = DependencyProperty.Register( nameof(MaxDecimalPlaces), typeof(int), @@ -51,9 +47,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(6) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SmallChangeProperty = DependencyProperty.Register( nameof(SmallChange), typeof(double), @@ -61,9 +55,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(1.0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty LargeChangeProperty = DependencyProperty.Register( nameof(LargeChange), typeof(double), @@ -71,9 +63,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(10.0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register( nameof(Maximum), typeof(double), @@ -81,9 +71,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(Double.MaxValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register( nameof(Minimum), typeof(double), @@ -91,9 +79,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(Double.MinValue) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AcceptsExpressionProperty = DependencyProperty.Register( nameof(AcceptsExpression), typeof(bool), @@ -101,9 +87,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SpinButtonPlacementModeProperty = DependencyProperty.Register( nameof(SpinButtonPlacementMode), typeof(NumberBoxSpinButtonPlacementMode), @@ -111,9 +95,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(NumberBoxSpinButtonPlacementMode.Inline) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ValidationModeProperty = DependencyProperty.Register( nameof(ValidationMode), typeof(NumberBoxValidationMode), @@ -121,9 +103,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(NumberBoxValidationMode.InvalidInputOverwritten) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty NumberFormatterProperty = DependencyProperty.Register( nameof(NumberFormatter), typeof(INumberFormatter), @@ -131,9 +111,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(null, OnNumberFormatterChanged) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent( nameof(ValueChanged), RoutingStrategy.Bubble, @@ -196,7 +174,7 @@ public double Minimum } /// - /// Gets or sets whether the control will accept and evaluate a basic formulaic expression entered as input. + /// Gets or sets a value indicating whether the control will accept and evaluate a basic formulaic expression entered as input. /// public bool AcceptsExpression { diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index 34fab84eb..4f2debc65 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -20,9 +20,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox { private bool _lockUpdatingContents; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PasswordProperty = DependencyProperty.Register( nameof(Password), typeof(string), @@ -30,9 +28,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(String.Empty, OnPasswordChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PasswordCharProperty = DependencyProperty.Register( nameof(PasswordChar), typeof(char), @@ -40,9 +36,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox new PropertyMetadata('*', OnPasswordCharChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsPasswordRevealedProperty = DependencyProperty.Register( nameof(IsPasswordRevealed), typeof(bool), @@ -50,9 +44,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(false, OnIsPasswordRevealedChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty RevealButtonEnabledProperty = DependencyProperty.Register( nameof(RevealButtonEnabled), typeof(bool), @@ -60,9 +52,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox new PropertyMetadata(true) ); - /// - /// Event for "Password has changed" - /// + /// Identifies the routed event. public static readonly RoutedEvent PasswordChangedEvent = EventManager.RegisterRoutedEvent( nameof(PasswordChanged), RoutingStrategy.Bubble, @@ -98,7 +88,7 @@ public bool IsPasswordRevealed } /// - /// Gets or sets a value deciding whether to display the reveal password button. + /// Gets or sets a value indicating whether whether to display the password reveal button. /// public bool RevealButtonEnabled { @@ -188,7 +178,6 @@ protected virtual void OnPasswordRevealModeChanged() /// /// Triggered by clicking a button in the control template. /// - /// Sender of the click event. /// Additional parameters. protected override void OnTemplateButtonClick(string? parameter) { diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index 89f9f7837..a29685001 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -15,9 +15,7 @@ namespace Wpf.Ui.Controls; /// public class ProgressRing : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register( nameof(Progress), typeof(double), @@ -25,9 +23,7 @@ public class ProgressRing : System.Windows.Controls.Control new PropertyMetadata(50d, OnProgressChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsIndeterminateProperty = DependencyProperty.Register( nameof(IsIndeterminate), typeof(bool), @@ -35,9 +31,7 @@ public class ProgressRing : System.Windows.Controls.Control new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty EngAngleProperty = DependencyProperty.Register( nameof(EngAngle), typeof(double), @@ -45,9 +39,7 @@ public class ProgressRing : System.Windows.Controls.Control new PropertyMetadata(180.0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IndeterminateAngleProperty = DependencyProperty.Register( nameof(IndeterminateAngle), typeof(double), @@ -55,9 +47,7 @@ public class ProgressRing : System.Windows.Controls.Control new PropertyMetadata(180.0d) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CoverRingStrokeProperty = DependencyProperty.RegisterAttached( nameof(CoverRingStroke), typeof(Brush), @@ -70,9 +60,7 @@ public class ProgressRing : System.Windows.Controls.Control ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CoverRingVisibilityProperty = DependencyProperty.Register( nameof(CoverRingVisibility), typeof(System.Windows.Visibility), @@ -90,8 +78,8 @@ public double Progress } /// - /// Determines if shows actual values () - /// or generic, continuous progress feedback (). + /// Gets or sets a value indicating whether shows actual values () + /// or generic, continuous progress feedback. /// public bool IsIndeterminate { @@ -118,7 +106,7 @@ public double IndeterminateAngle } /// - /// Background ring fill. + /// Gets background ring fill. /// public Brush CoverRingStroke { @@ -127,7 +115,7 @@ public Brush CoverRingStroke } /// - /// Background ring visibility. + /// Gets background ring visibility. /// public System.Windows.Visibility CoverRingVisibility { diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index 7df1c47ab..3dacc6d3e 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -36,9 +36,7 @@ private enum StarValue private SymbolIcon? _symbolIconStarFour; private SymbolIcon? _symbolIconStarFive; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( nameof(Value), typeof(double), @@ -46,9 +44,7 @@ private enum StarValue new PropertyMetadata(0.0D, OnValueChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MaxRatingProperty = DependencyProperty.Register( nameof(MaxRating), typeof(int), @@ -56,9 +52,7 @@ private enum StarValue new PropertyMetadata(5) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HalfStarEnabledProperty = DependencyProperty.Register( nameof(HalfStarEnabled), typeof(bool), @@ -66,9 +60,7 @@ private enum StarValue new PropertyMetadata(true) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent( nameof(ValueChanged), RoutingStrategy.Bubble, @@ -95,7 +87,7 @@ public int MaxRating } /// - /// Gets or sets the value deciding whether half of the star can be selected. + /// Gets or sets a value indicating whether half of the star can be selected. /// public bool HalfStarEnabled { @@ -182,9 +174,9 @@ protected override void OnMouseDown(MouseButtonEventArgs e) } /// - /// Is called after lifting a keyboard key. + /// Adjusts the control's in response to keyboard input, incrementing or decrementing based on the key pressed. /// - /// + /// Key event arguments containing details about the key press. protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); diff --git a/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs b/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs index 28918e35f..69eda0b41 100644 --- a/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs +++ b/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs @@ -7,13 +7,11 @@ namespace Wpf.Ui.Controls; /// -/// TODO +/// TODO: Add description /// public class RichTextBox : System.Windows.Controls.RichTextBox { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsTextSelectionEnabledProperty = DependencyProperty.Register( nameof(IsTextSelectionEnabled), typeof(bool), @@ -22,7 +20,7 @@ public class RichTextBox : System.Windows.Controls.RichTextBox ); /// - /// TODO + /// Gets or sets a value indicating whether the user can select text in the control. /// public bool IsTextSelectionEnabled { diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index e421cabb2..eed2598c4 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -19,9 +19,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl { #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsCloseButtonEnabledProperty = DependencyProperty.Register( nameof(IsCloseButtonEnabled), typeof(bool), @@ -29,9 +27,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SlideTransformProperty = DependencyProperty.Register( nameof(SlideTransform), typeof(TranslateTransform), @@ -39,9 +35,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(new TranslateTransform()) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsShownProperty = DependencyProperty.Register( nameof(IsShown), typeof(bool), @@ -49,9 +43,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TimeoutProperty = DependencyProperty.Register( nameof(Timeout), typeof(TimeSpan), @@ -59,9 +51,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(TimeSpan.FromSeconds(2)) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(object), @@ -69,9 +59,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleTemplateProperty = DependencyProperty.Register( nameof(TitleTemplate), typeof(DataTemplate), @@ -79,9 +67,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -89,9 +75,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register( nameof(Appearance), typeof(ControlAppearance), @@ -99,9 +83,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(ControlAppearance.Secondary) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -109,9 +91,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ContentForegroundProperty = DependencyProperty.Register( nameof(ContentForeground), typeof(Brush), @@ -122,9 +102,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl ) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( nameof(Opened), RoutingStrategy.Bubble, @@ -132,9 +110,7 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl typeof(Snackbar) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent( nameof(Closed), RoutingStrategy.Bubble, @@ -165,7 +141,7 @@ public TranslateTransform SlideTransform } /// - /// Gets the information whether the is visible. + /// Gets or sets a value indicating whether the is visible. /// public bool IsShown { @@ -213,7 +189,7 @@ public DataTemplate? TitleTemplate } /// - /// TODO + /// Gets or sets the icon /// [Bindable(true), Category("Appearance")] public IconElement? Icon @@ -231,7 +207,7 @@ public ControlAppearance Appearance } /// - /// Foreground of the . + /// Gets or sets the foreground of the . /// [Bindable(true), Category("Appearance")] public Brush ContentForeground @@ -241,7 +217,7 @@ public Brush ContentForeground } /// - /// Command triggered after clicking the button in the template. + /// Gets the command triggered after clicking the button in the template. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); @@ -266,9 +242,9 @@ public event TypedEventHandler Closed #endregion /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class with a specified presenter. /// - /// + /// The to manage the snackbar's display and interactions. public Snackbar(SnackbarPresenter presenter) { Presenter = presenter; diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index 9cc187ff3..8e458e5d6 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -27,9 +27,7 @@ public class SplitButton : Wpf.Ui.Controls.Button /// protected ToggleButton SplitButtonToggleButton = null!; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FlyoutProperty = DependencyProperty.Register( nameof(Flyout), typeof(object), @@ -37,9 +35,7 @@ public class SplitButton : Wpf.Ui.Controls.Button new PropertyMetadata(null, OnFlyoutChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register( nameof(IsDropDownOpen), typeof(bool), @@ -89,6 +85,8 @@ private static void OnFlyoutChanged(DependencyObject d, DependencyPropertyChange } } + /// This method is invoked when the changes. + /// The new value of . protected virtual void OnFlyoutChanged(object value) { if (value is ContextMenu contextMenu) diff --git a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs index 86c6a2fd0..0f7884940 100644 --- a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs +++ b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs @@ -14,9 +14,7 @@ namespace Wpf.Ui.Controls; /// public class TextBlock : System.Windows.Controls.TextBlock { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty FontTypographyProperty = DependencyProperty.Register( nameof(FontTypography), typeof(FontTypography), @@ -27,9 +25,7 @@ public class TextBlock : System.Windows.Controls.TextBlock ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register( nameof(Appearance), typeof(TextColor), @@ -41,7 +37,7 @@ public class TextBlock : System.Windows.Controls.TextBlock ); /// - /// TODO + /// Gets or sets the of the text. /// public FontTypography FontTypography { @@ -50,7 +46,7 @@ public FontTypography FontTypography } /// - /// TODO + /// Gets or sets the color of the text. /// public TextColor Appearance { diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index d22ab3d46..972adbfc5 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -18,9 +18,7 @@ public class TextBox : System.Windows.Controls.TextBox { #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -28,9 +26,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(null, null, IconElement.Coerce) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register( nameof(IconPlacement), typeof(ElementPlacement), @@ -38,9 +34,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(ElementPlacement.Left) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register( nameof(PlaceholderText), typeof(string), @@ -48,9 +42,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register( nameof(PlaceholderEnabled), typeof(bool), @@ -58,9 +50,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ClearButtonEnabledProperty = DependencyProperty.Register( nameof(ClearButtonEnabled), typeof(bool), @@ -68,9 +58,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register( nameof(ShowClearButton), typeof(bool), @@ -78,9 +66,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsTextSelectionEnabledProperty = DependencyProperty.Register( nameof(IsTextSelectionEnabled), typeof(bool), @@ -88,9 +74,7 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -112,7 +96,7 @@ public IconElement? Icon } /// - /// Defines which side the icon should be placed on. + /// Gets or sets which side the icon should be placed on. /// public ElementPlacement IconPlacement { @@ -130,7 +114,7 @@ public string PlaceholderText } /// - /// Gets or sets a value determining whether to display the placeholder. + /// Gets or sets a value indicating whether to display the placeholder text. /// public bool PlaceholderEnabled { @@ -139,7 +123,7 @@ public bool PlaceholderEnabled } /// - /// Gets or sets a value determining whether to enable the clear button. + /// Gets or sets a value indicating whether to enable the clear button. /// public bool ClearButtonEnabled { @@ -148,7 +132,7 @@ public bool ClearButtonEnabled } /// - /// Gets or sets a value determining whether to show the clear button when is focused. + /// Gets or sets a value indicating whether to show the clear button when is focused. /// public bool ShowClearButton { @@ -157,7 +141,7 @@ public bool ShowClearButton } /// - /// TODO + /// Gets or sets a value indicating whether text selection is enabled. /// public bool IsTextSelectionEnabled { @@ -166,14 +150,14 @@ public bool IsTextSelectionEnabled } /// - /// Command triggered after clicking the button. + /// Gets the command triggered when clicking the button. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); #endregion /// - /// Creates a new instance and assigns default events. + /// Initializes a new instance of the class. /// public TextBox() { diff --git a/src/Wpf.Ui/Controls/TimePicker/TimePicker.cs b/src/Wpf.Ui/Controls/TimePicker/TimePicker.cs index 44c9e94f0..fa1b74949 100644 --- a/src/Wpf.Ui/Controls/TimePicker/TimePicker.cs +++ b/src/Wpf.Ui/Controls/TimePicker/TimePicker.cs @@ -11,9 +11,7 @@ namespace Wpf.Ui.Controls; /// public class TimePicker : System.Windows.Controls.Primitives.ButtonBase { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( nameof(Header), typeof(object), @@ -21,9 +19,7 @@ public class TimePicker : System.Windows.Controls.Primitives.ButtonBase new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TimeProperty = DependencyProperty.Register( nameof(Time), typeof(TimeSpan), @@ -31,9 +27,7 @@ public class TimePicker : System.Windows.Controls.Primitives.ButtonBase new PropertyMetadata(TimeSpan.Zero) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register( nameof(SelectedTime), typeof(TimeSpan?), @@ -41,9 +35,7 @@ public class TimePicker : System.Windows.Controls.Primitives.ButtonBase new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MinuteIncrementProperty = DependencyProperty.Register( nameof(MinuteIncrement), typeof(int), @@ -51,9 +43,7 @@ public class TimePicker : System.Windows.Controls.Primitives.ButtonBase new PropertyMetadata(1) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ClockIdentifierProperty = DependencyProperty.Register( nameof(ClockIdentifier), typeof(ClockIdentifier), diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 50a47d781..cc459c37a 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -39,9 +39,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl #region Static properties - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ApplicationThemeProperty = DependencyProperty.Register( nameof(ApplicationTheme), typeof(Appearance.ApplicationTheme), @@ -49,9 +47,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(Appearance.ApplicationTheme.Unknown) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(string), @@ -59,9 +55,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( nameof(Header), typeof(object), @@ -69,9 +63,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ButtonsForegroundProperty = DependencyProperty.Register( nameof(ButtonsForeground), typeof(Brush), @@ -82,9 +74,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ButtonsBackgroundProperty = DependencyProperty.Register( nameof(ButtonsBackground), typeof(Brush), @@ -92,9 +82,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new FrameworkPropertyMetadata(SystemColors.ControlBrush, FrameworkPropertyMetadataOptions.Inherits) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsMaximizedProperty = DependencyProperty.Register( nameof(IsMaximized), typeof(bool), @@ -102,9 +90,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ForceShutdownProperty = DependencyProperty.Register( nameof(ForceShutdown), typeof(bool), @@ -112,9 +98,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowMaximizeProperty = DependencyProperty.Register( nameof(ShowMaximize), typeof(bool), @@ -122,9 +106,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowMinimizeProperty = DependencyProperty.Register( nameof(ShowMinimize), typeof(bool), @@ -132,9 +114,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(true) ); - /// - /// Property for - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowHelpProperty = DependencyProperty.Register( nameof(ShowHelp), typeof(bool), @@ -142,9 +122,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ShowCloseProperty = DependencyProperty.Register( nameof(ShowClose), typeof(bool), @@ -152,9 +130,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(true) ); - /// - /// Property for - /// + /// Identifies the dependency property. public static readonly DependencyProperty CanMaximizeProperty = DependencyProperty.Register( nameof(CanMaximize), typeof(bool), @@ -162,9 +138,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -172,9 +146,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CloseWindowByDoubleClickOnIconProperty = DependencyProperty.Register( nameof(CloseWindowByDoubleClickOnIcon), @@ -183,9 +155,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(false) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent CloseClickedEvent = EventManager.RegisterRoutedEvent( nameof(CloseClicked), RoutingStrategy.Bubble, @@ -193,9 +163,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl typeof(TitleBar) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent MaximizeClickedEvent = EventManager.RegisterRoutedEvent( nameof(MaximizeClicked), RoutingStrategy.Bubble, @@ -203,9 +171,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl typeof(TitleBar) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent MinimizeClickedEvent = EventManager.RegisterRoutedEvent( nameof(MinimizeClicked), RoutingStrategy.Bubble, @@ -213,9 +179,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl typeof(TitleBar) ); - /// - /// Routed event for . - /// + /// Identifies the routed event. public static readonly RoutedEvent HelpClickedEvent = EventManager.RegisterRoutedEvent( nameof(HelpClicked), RoutingStrategy.Bubble, @@ -223,9 +187,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl typeof(TitleBar) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -263,7 +225,7 @@ public object? Header } /// - /// Foreground of the navigation buttons. + /// Gets or sets the foreground of the navigation buttons. /// [Bindable(true), Category("Appearance")] public Brush ButtonsForeground @@ -273,7 +235,7 @@ public Brush ButtonsForeground } /// - /// Background of the navigation buttons when hovered. + /// Gets or sets the background of the navigation buttons when hovered. /// [Bindable(true), Category("Appearance")] public Brush ButtonsBackground @@ -283,7 +245,7 @@ public Brush ButtonsBackground } /// - /// Gets or sets information whether the current window is maximized. + /// Gets a value indicating whether the current window is maximized. /// public bool IsMaximized { @@ -292,7 +254,7 @@ public bool IsMaximized } /// - /// Gets or sets information whether the controls affect main application window. + /// Gets or sets a value indicating whether the controls affect main application window. /// public bool ForceShutdown { @@ -301,7 +263,7 @@ public bool ForceShutdown } /// - /// Gets or sets information whether to show maximize button. + /// Gets or sets a value indicating whether to show the maximize button. /// public bool ShowMaximize { @@ -310,7 +272,7 @@ public bool ShowMaximize } /// - /// Gets or sets information whether to show minimize button. + /// Gets or sets a value indicating whether to show the minimize button. /// public bool ShowMinimize { @@ -319,7 +281,7 @@ public bool ShowMinimize } /// - /// Gets or sets information whether to show help button + /// Gets or sets a value indicating whether to show the help button /// public bool ShowHelp { @@ -328,7 +290,7 @@ public bool ShowHelp } /// - /// Gets or sets information whether to show close button. + /// Gets or sets a value indicating whether to show the close button. /// public bool ShowClose { @@ -337,7 +299,7 @@ public bool ShowClose } /// - /// Enables or disables the maximize functionality if disables the MaximizeActionOverride action won't be called + /// Gets or sets a value indicating whether the maximize functionality is enabled. If disabled the MaximizeActionOverride action won't be called /// public bool CanMaximize { @@ -346,7 +308,7 @@ public bool CanMaximize } /// - /// Titlebar icon. + /// Gets or sets the titlebar icon. /// public IconElement? Icon { @@ -355,7 +317,7 @@ public IconElement? Icon } /// - /// Enables or disable closing the window by double clicking on the icon + /// Gets or sets a value indicating whether the window can be closed by double clicking on the icon /// public bool CloseWindowByDoubleClickOnIcon { @@ -400,17 +362,17 @@ public event TypedEventHandler HelpClicked } /// - /// Command triggered after clicking the titlebar button. + /// Gets the command triggered when clicking the titlebar button. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); /// - /// Lets you override the behavior of the Maximize/Restore button with an . + /// Gets or sets the that should be executed when the Maximize button is clicked."/> /// public Action? MaximizeActionOverride { get; set; } /// - /// Lets you override the behavior of the Minimize button with an . + /// Gets or sets what should be executed when the Minimize button is clicked. /// public Action? MinimizeActionOverride { get; set; } @@ -422,7 +384,7 @@ public event TypedEventHandler HelpClicked private readonly TitleBarButton[] _buttons = new TitleBarButton[4]; /// - /// Creates a new instance of the class and sets the default event. + /// Initializes a new instance of the class and sets the default event. /// public TitleBar() { diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index e738f9ba9..88e6e014a 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; public class TitleBarButton : Wpf.Ui.Controls.Button { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ButtonTypeProperty = DependencyProperty.Register( nameof(ButtonType), typeof(TitleBarButtonType), @@ -23,9 +21,7 @@ public class TitleBarButton : Wpf.Ui.Controls.Button new PropertyMetadata(TitleBarButtonType.Unknown, OnButtonTypeChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ButtonsForegroundProperty = DependencyProperty.Register( nameof(ButtonsForeground), typeof(Brush), @@ -36,9 +32,7 @@ public class TitleBarButton : Wpf.Ui.Controls.Button ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MouseOverButtonsForegroundProperty = DependencyProperty.Register( nameof(MouseOverButtonsForeground), @@ -47,9 +41,7 @@ public class TitleBarButton : Wpf.Ui.Controls.Button new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty RenderButtonsForegroundProperty = DependencyProperty.Register( nameof(RenderButtonsForeground), typeof(Brush), @@ -61,7 +53,7 @@ public class TitleBarButton : Wpf.Ui.Controls.Button ); /// - /// Sets or gets the + /// Gets or sets the type of the button. /// public TitleBarButtonType ButtonType { @@ -70,7 +62,7 @@ public TitleBarButtonType ButtonType } /// - /// Foreground of the navigation buttons. + /// Gets or sets the foreground of the navigation buttons. /// public Brush ButtonsForeground { @@ -79,7 +71,7 @@ public Brush ButtonsForeground } /// - /// Foreground of the navigation buttons while mouse over. + /// Gets or sets the foreground of the navigation buttons when moused over. /// public Brush? MouseOverButtonsForeground { diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs index b6281d352..842374b93 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs @@ -12,13 +12,9 @@ namespace Wpf.Ui.Controls; /// /// Use to present users with two mutally exclusive options (like on/off). /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(ToggleSwitch), "ToggleSwitch.bmp")] public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OffContentProperty = DependencyProperty.Register( nameof(OffContent), typeof(object), @@ -26,9 +22,7 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OnContentProperty = DependencyProperty.Register( nameof(OnContent), typeof(object), @@ -37,8 +31,7 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton ); /// - /// Provides the object content that should be displayed when this - /// has state of "Off". + /// Gets or sets the content that should be displayed when the is in the "Off" state. /// [Bindable(true)] public object? OffContent @@ -48,8 +41,7 @@ public object? OffContent } /// - /// Provides the object content that should be displayed when this - /// has state of "On". + /// Gets or sets the content that should be displayed when the is in the "On" state. /// [Bindable(true)] public object? OnContent diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs index 05f29c9d5..38b05aefb 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs @@ -9,13 +9,11 @@ namespace Wpf.Ui.Controls; /// -/// Work in progress. +/// TODO: Work in progress. /// public class TreeGrid : System.Windows.Controls.Primitives.Selector { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty HeadersProperty = DependencyProperty.Register( nameof(Headers), typeof(ObservableCollection), @@ -23,14 +21,16 @@ public class TreeGrid : System.Windows.Controls.Primitives.Selector new PropertyMetadata(new ObservableCollection(), OnHeadersChanged) ); - /*/// + /* + /// /// Property for . /// public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), - typeof(object), typeof(TreeGrid), new PropertyMetadata(null, OnContentChanged));*/ + typeof(object), typeof(TreeGrid), new PropertyMetadata(null, OnContentChanged)); + */ /// - /// Content is the data used to generate the child elements of this control. + /// Gets or sets the data used to generate the child elements of this control. /// [Bindable(true)] public ObservableCollection Headers diff --git a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs index c2ad76cba..1a777ddcb 100644 --- a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs +++ b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs @@ -11,9 +11,7 @@ namespace Wpf.Ui.Controls; /// public class TreeViewItem : System.Windows.Controls.TreeViewItem { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), diff --git a/src/Wpf.Ui/Controls/TypedEventHandler.cs b/src/Wpf.Ui/Controls/TypedEventHandler.cs index 6ca2bedfc..4f1c17ea9 100644 --- a/src/Wpf.Ui/Controls/TypedEventHandler.cs +++ b/src/Wpf.Ui/Controls/TypedEventHandler.cs @@ -10,10 +10,10 @@ namespace Wpf.Ui.Controls; /// /// Represents a method that handles general events. /// -/// -/// -/// -/// +/// The type of the sender. +/// The type of the event data. +/// The source of the event. +/// An object that contains the event data. public delegate void TypedEventHandler(TSender sender, TArgs args) where TSender : DependencyObject where TArgs : RoutedEventArgs; diff --git a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs index 4d3cfede8..36c23aed2 100644 --- a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs +++ b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs @@ -22,9 +22,7 @@ namespace Wpf.Ui.Controls; /// public class VirtualizingGridView : ListView { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( nameof(Orientation), typeof(Orientation), @@ -32,9 +30,7 @@ public class VirtualizingGridView : ListView new PropertyMetadata(Orientation.Vertical) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SpacingModeProperty = DependencyProperty.Register( nameof(SpacingMode), typeof(SpacingMode), @@ -42,9 +38,7 @@ public class VirtualizingGridView : ListView new PropertyMetadata(SpacingMode.Uniform) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty StretchItemsProperty = DependencyProperty.Register( nameof(StretchItems), typeof(bool), @@ -71,7 +65,7 @@ public SpacingMode SpacingMode } /// - /// Gets or sets a value that specifies if the items get stretched to fill up remaining space. The default value is false. + /// Gets or sets a value indicating whether the items get stretched to fill up remaining space. The default value is false. /// /// /// The MaxWidth and MaxHeight properties of the ItemContainerStyle can be used to limit the stretching. diff --git a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs index 2904e2a59..ec98e651a 100644 --- a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs +++ b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs @@ -19,9 +19,7 @@ namespace Wpf.Ui.Controls; /// public class VirtualizingItemsControl : System.Windows.Controls.ItemsControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty CacheLengthUnitProperty = DependencyProperty.Register( nameof(CacheLengthUnit), typeof(VirtualizationCacheLengthUnit), @@ -43,7 +41,7 @@ public VirtualizationCacheLengthUnit CacheLengthUnit } /// - /// Constructor that initialize the . + /// Initializes a new instance of the class. /// public VirtualizingItemsControl() { diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 6d33d46af..65a3aac3d 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -41,9 +41,7 @@ public class VirtualizingWrapPanel : VirtualizingPanelBase /// protected int ItemsPerRowCount; - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SpacingModeProperty = DependencyProperty.Register( nameof(SpacingMode), typeof(SpacingMode), @@ -51,9 +49,7 @@ public class VirtualizingWrapPanel : VirtualizingPanelBase new FrameworkPropertyMetadata(SpacingMode.Uniform, FrameworkPropertyMetadataOptions.AffectsMeasure) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( nameof(Orientation), typeof(Orientation), @@ -65,9 +61,7 @@ public class VirtualizingWrapPanel : VirtualizingPanelBase ) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ItemSizeProperty = DependencyProperty.Register( nameof(ItemSize), typeof(Size), @@ -75,9 +69,7 @@ public class VirtualizingWrapPanel : VirtualizingPanelBase new FrameworkPropertyMetadata(Size.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty StretchItemsProperty = DependencyProperty.Register( nameof(StretchItems), typeof(bool), @@ -114,7 +106,7 @@ public Size ItemSize } /// - /// Gets or sets a value that specifies if the items get stretched to fill up remaining space. The default value is false. + /// Gets or sets a value indicating whether the items get stretched to fill up remaining space. The default value is false. /// /// /// The MaxWidth and MaxHeight properties of the ItemContainerStyle can be used to limit the stretching. @@ -355,12 +347,12 @@ protected Size CalculateChildArrangeSize(Size finalSize) } /// - /// Gets container style of the . + /// Gets the style property value for item containers within the . /// - /// - /// - /// - /// + /// The expected type of the property value. + /// The to retrieve the value for. + /// The value to return if the property is not set. + /// The value of the specified property if found; otherwise, the . private T ReadItemContainerStyle(DependencyProperty property, T fallbackValue) where T : notnull { diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index 1ca55f925..3c0339734 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -166,7 +166,7 @@ public static extern int SHCreateItemFromParsingName( /// /// Sets the User Model AppID for the current process, enabling Windows to retrieve this ID /// - /// + /// The string ID [DllImport(Libraries.Shell32, PreserveSig = false)] public static extern void SetCurrentProcessExplicitAppUserModelID( [MarshalAs(UnmanagedType.LPWStr)] string AppID @@ -175,7 +175,8 @@ public static extern void SetCurrentProcessExplicitAppUserModelID( /// /// Retrieves the User Model AppID that has been explicitly set for the current process via SetCurrentProcessExplicitAppUserModelID /// - /// + /// The returned string ID of the Application User Model. + /// An HRESULT indicating success or failure of the operation. [DllImport(Libraries.Shell32)] public static extern int GetCurrentProcessExplicitAppUserModelID( [Out, MarshalAs(UnmanagedType.LPWStr)] out string AppID diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index 367e41495..3e3f34940 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -28,47 +28,47 @@ internal class Utilities #endif /// - /// Whether the operating system is NT or newer. + /// Gets a value indicating whether the operating system is NT or newer. /// public static bool IsNT => _osPlatform == PlatformID.Win32NT; /// - /// Whether the operating system version is greater than or equal to 6.0. + /// Gets a value indicating whether the operating system version is greater than or equal to 6.0. /// public static bool IsOSVistaOrNewer => _osVersion >= new Version(6, 0); /// - /// Whether the operating system version is greater than or equal to 6.1. + /// Gets a value indicating whether the operating system version is greater than or equal to 6.1. /// public static bool IsOSWindows7OrNewer => _osVersion >= new Version(6, 1); /// - /// Whether the operating system version is greater than or equal to 6.2. + /// Gets a value indicating whether the operating system version is greater than or equal to 6.2. /// public static bool IsOSWindows8OrNewer => _osVersion >= new Version(6, 2); /// - /// Whether the operating system version is greater than or equal to 10.0* (build 10240). + /// Gets a value indicating whether the operating system version is greater than or equal to 10.0* (build 10240). /// public static bool IsOSWindows10OrNewer => _osVersion.Build >= 10240; /// - /// Whether the operating system version is greater than or equal to 10.0* (build 22000). + /// Gets a value indicating whether the operating system version is greater than or equal to 10.0* (build 22000). /// public static bool IsOSWindows11OrNewer => _osVersion.Build >= 22000; /// - /// Whether the operating system version is greater than or equal to 10.0* (build 22523). + /// Gets a value indicating whether the operating system version is greater than or equal to 10.0* (build 22523). /// public static bool IsOSWindows11Insider1OrNewer => _osVersion.Build >= 22523; /// - /// Whether the operating system version is greater than or equal to 10.0* (build 22557). + /// Gets a value indicating whether the operating system version is greater than or equal to 10.0* (build 22557). /// public static bool IsOSWindows11Insider2OrNewer => _osVersion.Build >= 22557; /// - /// Indicates whether Desktop Window Manager (DWM) composition is enabled. + /// Gets a value indicating whether Desktop Window Manager (DWM) composition is enabled. /// public static bool IsCompositionEnabled { From 5f677e1c2a52750cb55a0c519f8f353169607cfb Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 18:46:49 -0700 Subject: [PATCH 08/33] Fix warnings about using language keywords - Use string, double, int rather than String, Double, Int32, etc - remove 'this' keyword when context is obvious --- .../Helpers/EnumToBooleanConverter.cs | 4 +- .../ViewModels/SettingsViewModel.cs | 4 +- src/Wpf.Ui.FontMapper/Program.cs | 12 +++--- .../ViewModels/Pages/SettingsViewModel.cs | 4 +- .../Pages/Windows/WindowsViewModel.cs | 2 +- .../Controls/CodeBlock.cs | 4 +- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 42 +++++++++---------- .../Internal/InternalNotifyIconManager.cs | 2 +- src/Wpf.Ui.Tray/Interop/User32.cs | 4 +- src/Wpf.Ui.Tray/NotifyIconService.cs | 38 ++++++++--------- src/Wpf.Ui.Tray/TrayManager.cs | 2 +- src/Wpf.Ui/Appearance/SystemThemeManager.cs | 4 +- .../CardControlAutomationPeer.cs | 8 ++-- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 4 +- src/Wpf.Ui/Controls/CardColor/CardColor.cs | 4 +- .../Controls/ContentDialog/ContentDialog.cs | 12 +++--- src/Wpf.Ui/Controls/DateTimeHelper.cs | 10 ++--- .../NavigationView/NavigationView.Base.cs | 2 +- .../NavigationView.Navigation.cs | 2 +- .../Controls/NumberBox/INumberParser.cs | 6 +-- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 10 ++--- .../NumberBox/ValidateNumberFormatter.cs | 12 +++--- .../Controls/PasswordBox/PasswordBox.cs | 10 ++--- src/Wpf.Ui/Controls/SymbolGlyph.cs | 4 +- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 2 +- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 2 +- .../VirtualizingWrapPanel.cs | 2 +- .../Converters/TextToAsteriskConverter.cs | 2 +- src/Wpf.Ui/Extensions/UriExtensions.cs | 4 +- src/Wpf.Ui/Hardware/RenderingTier.cs | 2 +- src/Wpf.Ui/Win32/Utilities.cs | 8 ++-- 31 files changed, 113 insertions(+), 115 deletions(-) diff --git a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs b/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs index f65faa6fb..e2c8c8fc6 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs @@ -12,7 +12,7 @@ internal class EnumToBooleanConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (parameter is not String enumString) + if (parameter is not string enumString) { throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); } @@ -29,7 +29,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - if (parameter is not String enumString) + if (parameter is not string enumString) { throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); } diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs index 43ac63c8c..d9dcaae14 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs @@ -12,7 +12,7 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware private bool _isInitialized = false; [ObservableProperty] - private string _appVersion = String.Empty; + private string _appVersion = string.Empty; [ObservableProperty] private Wpf.Ui.Appearance.ApplicationTheme _currentApplicationTheme = Wpf.Ui @@ -41,7 +41,7 @@ private void InitializeViewModel() private string GetAssemblyVersion() { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() - ?? String.Empty; + ?? string.Empty; } [RelayCommand] diff --git a/src/Wpf.Ui.FontMapper/Program.cs b/src/Wpf.Ui.FontMapper/Program.cs index b4c5b34f1..62709b18e 100644 --- a/src/Wpf.Ui.FontMapper/Program.cs +++ b/src/Wpf.Ui.FontMapper/Program.cs @@ -37,23 +37,23 @@ await httpClient.GetFromJsonAsync>( ) ) ?.Last() - ?.Ref.Replace("refs/tags/", String.Empty) + ?.Ref.Replace("refs/tags/", string.Empty) .Trim() ?? throw new Exception("Unable to parse the version string"); } string FormatIconName(string rawIconName) { rawIconName = rawIconName - .Replace("ic_fluent_", String.Empty) - .Replace("_regular", String.Empty) - .Replace("_filled", String.Empty); + .Replace("ic_fluent_", string.Empty) + .Replace("_regular", string.Empty) + .Replace("_filled", string.Empty); - var iconName = String.Empty; + var iconName = string.Empty; foreach (var newPart in rawIconName.Split('_')) { var charactersArray = newPart.ToCharArray(); - charactersArray[0] = Char.ToUpper(charactersArray[0]); + charactersArray[0] = char.ToUpper(charactersArray[0]); iconName += new string(charactersArray); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs index 59b3c2556..2fa66a1fb 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs @@ -16,7 +16,7 @@ public sealed partial class SettingsViewModel : ObservableObject, INavigationAwa private bool _isInitialized = false; [ObservableProperty] - private string _appVersion = String.Empty; + private string _appVersion = string.Empty; [ObservableProperty] private ApplicationTheme _currentApplicationTheme = ApplicationTheme.Unknown; @@ -74,6 +74,6 @@ private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color syst private string GetAssemblyVersion() { - return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? String.Empty; + return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty; } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs index 79a265891..ebe905c20 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs @@ -25,7 +25,7 @@ public partial class WindowsViewModel(WindowsProviderService windowsProviderServ [RelayCommand] public void OnOpenWindow(string value) { - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) { return; } diff --git a/src/Wpf.Ui.SyntaxHighlight/Controls/CodeBlock.cs b/src/Wpf.Ui.SyntaxHighlight/Controls/CodeBlock.cs index 356091c82..924712579 100644 --- a/src/Wpf.Ui.SyntaxHighlight/Controls/CodeBlock.cs +++ b/src/Wpf.Ui.SyntaxHighlight/Controls/CodeBlock.cs @@ -16,11 +16,9 @@ namespace Wpf.Ui.SyntaxHighlight.Controls; /// /// Formats and display a fragment of the source code. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(CodeBlock), "CodeBlock.bmp")] public class CodeBlock : System.Windows.Controls.ContentControl { - private string _sourceCode = String.Empty; + private string _sourceCode = string.Empty; /// /// Property for . diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 9ca7946f6..0b68760c0 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -39,12 +39,12 @@ public class NotifyIcon : System.Windows.FrameworkElement #region Public variables - public int Id => this.internalNotifyIconManager.Id; + public int Id => internalNotifyIconManager.Id; /// /// Gets a value indicating whether the icon is registered in the tray menu. /// - public bool IsRegistered => this.internalNotifyIconManager.IsRegistered; + public bool IsRegistered => internalNotifyIconManager.IsRegistered; public HwndSource? HookWindow { get; set; } @@ -59,7 +59,7 @@ public class NotifyIcon : System.Windows.FrameworkElement nameof(TooltipText), typeof(string), typeof(NotifyIcon), - new PropertyMetadata(String.Empty, OnTooltipTextChanged) + new PropertyMetadata(string.Empty, OnTooltipTextChanged) ); /// Identifies the dependency property. @@ -259,7 +259,7 @@ public event RoutedNotifyIconEvent MiddleDoubleClick public NotifyIcon() { - this.internalNotifyIconManager = new Wpf.Ui.Tray.Internal.InternalNotifyIconManager(); + internalNotifyIconManager = new Wpf.Ui.Tray.Internal.InternalNotifyIconManager(); RegisterHandlers(); } @@ -272,12 +272,12 @@ public NotifyIcon() /// /// Tries to register the in the shell. /// - public void Register() => this.internalNotifyIconManager.Register(); + public void Register() => internalNotifyIconManager.Register(); /// /// Tries to unregister the from the shell. /// - public void Unregister() => this.internalNotifyIconManager.Unregister(); + public void Unregister() => internalNotifyIconManager.Unregister(); /// public void Dispose() @@ -296,7 +296,7 @@ protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); - if (this.internalNotifyIconManager.IsRegistered) + if (internalNotifyIconManager.IsRegistered) { return; } @@ -388,7 +388,7 @@ protected virtual void Dispose(bool disposing) Unregister(); - this.internalNotifyIconManager.Dispose(); + internalNotifyIconManager.Dispose(); } #endregion @@ -399,8 +399,8 @@ protected virtual void Dispose(bool disposing) /// New context menu object. protected virtual void OnMenuChanged(ContextMenu contextMenu) { - this.internalNotifyIconManager.ContextMenu = contextMenu; - this.internalNotifyIconManager.ContextMenu.FontSize = MenuFontSize; + internalNotifyIconManager.ContextMenu = contextMenu; + internalNotifyIconManager.ContextMenu.FontSize = MenuFontSize; } private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -410,7 +410,7 @@ private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyC return; } - notifyIcon.TooltipText = e.NewValue as string ?? String.Empty; + notifyIcon.TooltipText = e.NewValue as string ?? string.Empty; } private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -475,19 +475,19 @@ private static void OnMenuChanged(DependencyObject d, DependencyPropertyChangedE private void InitializeIcon() { - this.internalNotifyIconManager.TooltipText = TooltipText; - this.internalNotifyIconManager.Icon = Icon; - this.internalNotifyIconManager.MenuOnRightClick = MenuOnRightClick; - this.internalNotifyIconManager.FocusOnLeftClick = FocusOnLeftClick; + internalNotifyIconManager.TooltipText = TooltipText; + internalNotifyIconManager.Icon = Icon; + internalNotifyIconManager.MenuOnRightClick = MenuOnRightClick; + internalNotifyIconManager.FocusOnLeftClick = FocusOnLeftClick; } private void RegisterHandlers() { - this.internalNotifyIconManager.LeftClick += OnLeftClick; - this.internalNotifyIconManager.LeftDoubleClick += OnLeftDoubleClick; - this.internalNotifyIconManager.RightClick += OnRightClick; - this.internalNotifyIconManager.RightDoubleClick += OnRightDoubleClick; - this.internalNotifyIconManager.MiddleClick += OnMiddleClick; - this.internalNotifyIconManager.MiddleDoubleClick += OnMiddleDoubleClick; + internalNotifyIconManager.LeftClick += OnLeftClick; + internalNotifyIconManager.LeftDoubleClick += OnLeftDoubleClick; + internalNotifyIconManager.RightClick += OnRightClick; + internalNotifyIconManager.RightDoubleClick += OnRightDoubleClick; + internalNotifyIconManager.MiddleClick += OnMiddleClick; + internalNotifyIconManager.MiddleDoubleClick += OnMiddleDoubleClick; } } diff --git a/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs b/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs index 8e00c0c2a..e49be8afb 100644 --- a/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs +++ b/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs @@ -30,7 +30,7 @@ internal class InternalNotifyIconManager : IDisposable, INotifyIcon public bool IsRegistered { get; set; } /// - public string TooltipText { get; set; } = String.Empty; + public string TooltipText { get; set; } = string.Empty; /// public ImageSource? Icon { get; set; } = default!; diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs index 0a5a3dcf3..a632c6331 100644 --- a/src/Wpf.Ui.Tray/Interop/User32.cs +++ b/src/Wpf.Ui.Tray/Interop/User32.cs @@ -1134,7 +1134,7 @@ [In] IntPtr lParam /// /// Retrieves information about the specified window. The function also retrieves the 32-bit (DWORD) value at the specified offset into the extra window memory. /// If you are retrieving a pointer or a handle, this function has been superseded by the function. - /// Unicode declaration for + /// Unicode declaration for /// /// A handle to the window and, indirectly, the class to which the window belongs. /// The zero-based offset to the value to be retrieved. @@ -1145,7 +1145,7 @@ [In] IntPtr lParam /// /// Retrieves information about the specified window. The function also retrieves the 32-bit (DWORD) value at the specified offset into the extra window memory. /// If you are retrieving a pointer or a handle, this function has been superseded by the function. - /// ANSI declaration for + /// ANSI declaration for /// /// A handle to the window and, indirectly, the class to which the window belongs. /// The zero-based offset to the value to be retrieved. diff --git a/src/Wpf.Ui.Tray/NotifyIconService.cs b/src/Wpf.Ui.Tray/NotifyIconService.cs index a6d29cac8..6b5ea4931 100644 --- a/src/Wpf.Ui.Tray/NotifyIconService.cs +++ b/src/Wpf.Ui.Tray/NotifyIconService.cs @@ -19,31 +19,31 @@ public class NotifyIconService : INotifyIconService public Window ParentWindow { get; internal set; } = null!; - public int Id => this.internalNotifyIconManager.Id; + public int Id => internalNotifyIconManager.Id; - public bool IsRegistered => this.internalNotifyIconManager.IsRegistered; + public bool IsRegistered => internalNotifyIconManager.IsRegistered; public string TooltipText { - get => this.internalNotifyIconManager.TooltipText; - set => this.internalNotifyIconManager.TooltipText = value; + get => internalNotifyIconManager.TooltipText; + set => internalNotifyIconManager.TooltipText = value; } public ContextMenu? ContextMenu { - get => this.internalNotifyIconManager.ContextMenu; - set => this.internalNotifyIconManager.ContextMenu = value; + get => internalNotifyIconManager.ContextMenu; + set => internalNotifyIconManager.ContextMenu = value; } public ImageSource? Icon { - get => this.internalNotifyIconManager.Icon; - set => this.internalNotifyIconManager.Icon = value; + get => internalNotifyIconManager.Icon; + set => internalNotifyIconManager.Icon = value; } public NotifyIconService() { - this.internalNotifyIconManager = new Internal.InternalNotifyIconManager(); + internalNotifyIconManager = new Internal.InternalNotifyIconManager(); RegisterHandlers(); } @@ -52,15 +52,15 @@ public bool Register() { if (ParentWindow is not null) { - return this.internalNotifyIconManager.Register(ParentWindow); + return internalNotifyIconManager.Register(ParentWindow); } - return this.internalNotifyIconManager.Register(); + return internalNotifyIconManager.Register(); } public bool Unregister() { - return this.internalNotifyIconManager.Unregister(); + return internalNotifyIconManager.Unregister(); } /// @@ -107,16 +107,16 @@ protected virtual void OnMiddleDoubleClick() { } private void OnParentWindowClosing(object? sender, CancelEventArgs e) { - this.internalNotifyIconManager.Dispose(); + internalNotifyIconManager.Dispose(); } private void RegisterHandlers() { - this.internalNotifyIconManager.LeftClick += OnLeftClick; - this.internalNotifyIconManager.LeftDoubleClick += OnLeftDoubleClick; - this.internalNotifyIconManager.RightClick += OnRightClick; - this.internalNotifyIconManager.RightDoubleClick += OnRightDoubleClick; - this.internalNotifyIconManager.MiddleClick += OnMiddleClick; - this.internalNotifyIconManager.MiddleDoubleClick += OnMiddleDoubleClick; + internalNotifyIconManager.LeftClick += OnLeftClick; + internalNotifyIconManager.LeftDoubleClick += OnLeftDoubleClick; + internalNotifyIconManager.RightClick += OnRightClick; + internalNotifyIconManager.RightDoubleClick += OnRightDoubleClick; + internalNotifyIconManager.MiddleClick += OnMiddleClick; + internalNotifyIconManager.MiddleDoubleClick += OnMiddleDoubleClick; } } diff --git a/src/Wpf.Ui.Tray/TrayManager.cs b/src/Wpf.Ui.Tray/TrayManager.cs index f4dfdaa5c..b81560b33 100644 --- a/src/Wpf.Ui.Tray/TrayManager.cs +++ b/src/Wpf.Ui.Tray/TrayManager.cs @@ -93,7 +93,7 @@ public static bool Register(INotifyIcon notifyIcon, HwndSource? parentSource) dwState = 0x2 }; - if (!String.IsNullOrEmpty(notifyIcon.TooltipText)) + if (!string.IsNullOrEmpty(notifyIcon.TooltipText)) { notifyIcon.ShellIconData.szTip = notifyIcon.TooltipText; notifyIcon.ShellIconData.uFlags |= Interop.Shell32.NIF.TIP; diff --git a/src/Wpf.Ui/Appearance/SystemThemeManager.cs b/src/Wpf.Ui/Appearance/SystemThemeManager.cs index 422323406..f14f33f33 100644 --- a/src/Wpf.Ui/Appearance/SystemThemeManager.cs +++ b/src/Wpf.Ui/Appearance/SystemThemeManager.cs @@ -65,9 +65,9 @@ private static SystemTheme GetCurrentSystemTheme() "CurrentTheme", "aero.theme" ) as string - ?? String.Empty; + ?? string.Empty; - if (!String.IsNullOrEmpty(currentTheme)) + if (!string.IsNullOrEmpty(currentTheme)) { currentTheme = currentTheme.ToLower().Trim(); diff --git a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs index a4f6dc739..318478cf8 100644 --- a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs +++ b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs @@ -51,19 +51,19 @@ protected override AutomationPeer GetLabeledByCore() protected override string GetNameCore() { - var result = base.GetNameCore() ?? String.Empty; + var result = base.GetNameCore() ?? string.Empty; - if (result == String.Empty) + if (result == string.Empty) { result = AutomationProperties.GetName(_owner); } - if (result == String.Empty && _owner.Header is DependencyObject d) + if (result == string.Empty && _owner.Header is DependencyObject d) { result = AutomationProperties.GetName(d); } - if (result == String.Empty && _owner.Header is string s) + if (result == string.Empty && _owner.Header is string s) { result = s; } diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 26c0c3fe9..4c394f50f 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -57,7 +57,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl nameof(Text), typeof(string), typeof(AutoSuggestBox), - new PropertyMetadata(String.Empty, OnTextChanged) + new PropertyMetadata(string.Empty, OnTextChanged) ); /// Identifies the dependency property. @@ -65,7 +65,7 @@ public class AutoSuggestBox : System.Windows.Controls.ItemsControl, IIconControl nameof(PlaceholderText), typeof(string), typeof(AutoSuggestBox), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// Identifies the dependency property. diff --git a/src/Wpf.Ui/Controls/CardColor/CardColor.cs b/src/Wpf.Ui/Controls/CardColor/CardColor.cs index 91a8cdc9f..bbd21889f 100644 --- a/src/Wpf.Ui/Controls/CardColor/CardColor.cs +++ b/src/Wpf.Ui/Controls/CardColor/CardColor.cs @@ -16,7 +16,7 @@ public class CardColor : System.Windows.Controls.Control nameof(Title), typeof(string), typeof(CardColor), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// Identifies the dependency property. @@ -24,7 +24,7 @@ public class CardColor : System.Windows.Controls.Control nameof(Subtitle), typeof(string), typeof(CardColor), - new PropertyMetadata(String.Empty, OnSubtitleChanged) + new PropertyMetadata(string.Empty, OnSubtitleChanged) ); /// Identifies the dependency property. diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 0063c0b1c..9a8e701eb 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -66,7 +66,7 @@ public class ContentDialog : ContentControl nameof(DialogWidth), typeof(double), typeof(ContentDialog), - new PropertyMetadata(Double.PositiveInfinity) + new PropertyMetadata(double.PositiveInfinity) ); /// Identifies the dependency property. @@ -74,7 +74,7 @@ public class ContentDialog : ContentControl nameof(DialogHeight), typeof(double), typeof(ContentDialog), - new PropertyMetadata(Double.PositiveInfinity) + new PropertyMetadata(double.PositiveInfinity) ); /// Identifies the dependency property. @@ -82,7 +82,7 @@ public class ContentDialog : ContentControl nameof(DialogMaxWidth), typeof(double), typeof(ContentDialog), - new PropertyMetadata(Double.PositiveInfinity) + new PropertyMetadata(double.PositiveInfinity) ); /// Identifies the dependency property. @@ -90,7 +90,7 @@ public class ContentDialog : ContentControl nameof(DialogMaxHeight), typeof(double), typeof(ContentDialog), - new PropertyMetadata(Double.PositiveInfinity) + new PropertyMetadata(double.PositiveInfinity) ); /// Identifies the dependency property. @@ -105,7 +105,7 @@ public class ContentDialog : ContentControl nameof(PrimaryButtonText), typeof(string), typeof(ContentDialog), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// Identifies the dependency property. @@ -113,7 +113,7 @@ public class ContentDialog : ContentControl nameof(SecondaryButtonText), typeof(string), typeof(ContentDialog), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// Identifies the dependency property. diff --git a/src/Wpf.Ui/Controls/DateTimeHelper.cs b/src/Wpf.Ui/Controls/DateTimeHelper.cs index 61c6a815d..8641af312 100644 --- a/src/Wpf.Ui/Controls/DateTimeHelper.cs +++ b/src/Wpf.Ui/Controls/DateTimeHelper.cs @@ -165,7 +165,7 @@ public static bool InRange(DateTime date, DateTime start, DateTime end) public static string ToDayString(DateTime? date, CultureInfo culture) { - var result = String.Empty; + var result = string.Empty; DateTimeFormatInfo format = GetDateFormat(culture); if (date.HasValue && format is not null) @@ -178,7 +178,7 @@ public static string ToDayString(DateTime? date, CultureInfo culture) public static string ToYearMonthPatternString(DateTime? date, CultureInfo culture) { - var result = String.Empty; + var result = string.Empty; DateTimeFormatInfo format = GetDateFormat(culture); if (date.HasValue && format != null) @@ -191,7 +191,7 @@ public static string ToYearMonthPatternString(DateTime? date, CultureInfo cultur public static string ToYearString(DateTime? date, CultureInfo culture) { - var result = String.Empty; + var result = string.Empty; DateTimeFormatInfo format = GetDateFormat(culture); if (date.HasValue && format != null) @@ -204,7 +204,7 @@ public static string ToYearString(DateTime? date, CultureInfo culture) public static string ToAbbreviatedMonthString(DateTime? date, CultureInfo culture) { - var result = String.Empty; + var result = string.Empty; DateTimeFormatInfo format = GetDateFormat(culture); if (date.HasValue && format is not null) @@ -222,7 +222,7 @@ public static string ToAbbreviatedMonthString(DateTime? date, CultureInfo cultur public static string ToLongDateString(DateTime? date, CultureInfo culture) { - var result = String.Empty; + var result = string.Empty; DateTimeFormatInfo format = GetDateFormat(culture); if (date.HasValue && format is not null) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index e3c2a27e7..05e7c84b8 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -372,7 +372,7 @@ protected virtual void AddItemsToAutoSuggestBoxItems(IEnumerable list) { if ( singleNavigationViewItem is { Content: string content, TargetPageType: { } } - && !String.IsNullOrWhiteSpace(content) + && !string.IsNullOrWhiteSpace(content) ) { _autoSuggestBoxItems.Add(content); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 4ff942ca9..765544afb 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -199,7 +199,7 @@ private bool NavigateInternal( #if DEBUG System.Diagnostics.Debug.WriteLineIf( EnableDebugMessages, - $"DEBUG | {viewItem.Id} - {(String.IsNullOrEmpty(viewItem.TargetPageTag) ? "NO_TAG" : viewItem.TargetPageTag)} - {viewItem.TargetPageType} | NAVIGATED" + $"DEBUG | {viewItem.Id} - {(string.IsNullOrEmpty(viewItem.TargetPageTag) ? "NO_TAG" : viewItem.TargetPageTag)} - {viewItem.TargetPageType} | NAVIGATED" ); #endif diff --git a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs index 4fc5d35ab..ea472467f 100644 --- a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs +++ b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs @@ -14,17 +14,17 @@ namespace Wpf.Ui.Controls; public interface INumberParser { /// - /// Attempts to parse a string representation of a numeric value. + /// Attempts to parse a string representation of a numeric value. /// double? ParseDouble(string? value); /// - /// Attempts to parse a string representation of an numeric value. + /// Attempts to parse a string representation of an numeric value. /// int? ParseInt(string? value); /// - /// Attempts to parse a string representation of an numeric value. + /// Attempts to parse a string representation of an numeric value. /// uint? ParseUInt(string? value); } diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index c23053d91..5e3418c8d 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -68,7 +68,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox nameof(Maximum), typeof(double), typeof(NumberBox), - new PropertyMetadata(Double.MaxValue) + new PropertyMetadata(double.MaxValue) ); /// Identifies the dependency property. @@ -76,7 +76,7 @@ public class NumberBox : Wpf.Ui.Controls.TextBox nameof(Minimum), typeof(double), typeof(NumberBox), - new PropertyMetadata(Double.MinValue) + new PropertyMetadata(double.MinValue) ); /// Identifies the dependency property. @@ -328,7 +328,7 @@ System.Windows.Controls.ControlTemplate newTemplate base.OnTemplateChanged(oldTemplate, newTemplate); // If Text has been set, but Value hasn't, update Value based on Text. - if (String.IsNullOrEmpty(Text) && Value != null) + if (string.IsNullOrEmpty(Text) && Value != null) { UpdateValueToText(); } @@ -415,7 +415,7 @@ private void UpdateTextToValue() _textUpdating = true; // text = value - var newText = String.Empty; + var newText = string.Empty; if (Value is not null) { @@ -436,7 +436,7 @@ private void ValidateInput() { var text = Text.Trim(); - if (String.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(text)) { SetCurrentValue(ValueProperty, null); diff --git a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs index 65a302a44..f32255e16 100644 --- a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs +++ b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs @@ -16,25 +16,25 @@ public class ValidateNumberFormatter : INumberFormatter, INumberParser /// public string FormatDouble(double? value) { - return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? String.Empty; + return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public string FormatInt(int? value) { - return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? String.Empty; + return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public string FormatUInt(uint? value) { - return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? String.Empty; + return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public double? ParseDouble(string? value) { - Double.TryParse(value, out double d); + double.TryParse(value, out double d); return d; } @@ -42,7 +42,7 @@ public string FormatUInt(uint? value) /// public int? ParseInt(string? value) { - Int32.TryParse(value, out int i); + int.TryParse(value, out int i); return i; } @@ -50,7 +50,7 @@ public string FormatUInt(uint? value) /// public uint? ParseUInt(string? value) { - UInt32.TryParse(value, out uint ui); + uint.TryParse(value, out uint ui); return ui; } diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index 4f2debc65..4109ac043 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -25,7 +25,7 @@ public class PasswordBox : Wpf.Ui.Controls.TextBox nameof(Password), typeof(string), typeof(PasswordBox), - new PropertyMetadata(String.Empty, OnPasswordChanged) + new PropertyMetadata(string.Empty, OnPasswordChanged) ); /// Identifies the dependency property. @@ -161,7 +161,7 @@ protected virtual void OnPasswordCharChanged() _lockUpdatingContents = true; - Text = new String(PasswordChar, Password.Length); + Text = new string(PasswordChar, Password.Length); _lockUpdatingContents = false; } @@ -170,7 +170,7 @@ protected virtual void OnPasswordRevealModeChanged() { _lockUpdatingContents = true; - Text = IsPasswordRevealed ? Password : new String(PasswordChar, Password.Length); + Text = IsPasswordRevealed ? Password : new string(PasswordChar, Password.Length); _lockUpdatingContents = false; } @@ -242,7 +242,7 @@ private void UpdateTextContents(bool isTriggeredByTextInput) if (isTriggeredByTextInput) { var currentText = Text; - var newCharacters = currentText.Replace(PasswordChar.ToString(), String.Empty); + var newCharacters = currentText.Replace(PasswordChar.ToString(), string.Empty); if (currentText.Length < currentPassword.Length) { @@ -280,7 +280,7 @@ private void UpdateTextContents(bool isTriggeredByTextInput) _lockUpdatingContents = true; - Text = new String(PasswordChar, newPasswordValue.Length); + Text = new string(PasswordChar, newPasswordValue.Length); Password = newPasswordValue; CaretIndex = caretIndex; diff --git a/src/Wpf.Ui/Controls/SymbolGlyph.cs b/src/Wpf.Ui/Controls/SymbolGlyph.cs index 5094a035a..bd04905a1 100644 --- a/src/Wpf.Ui/Controls/SymbolGlyph.cs +++ b/src/Wpf.Ui/Controls/SymbolGlyph.cs @@ -26,7 +26,7 @@ public static class SymbolGlyph /// Name of the icon. public static SymbolRegular Parse(string name) { - if (String.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { return DefaultIcon; } @@ -51,7 +51,7 @@ public static SymbolRegular Parse(string name) /// Name of the icon. public static SymbolFilled ParseFilled(string name) { - if (String.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { return DefaultFilledIcon; } diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index 972adbfc5..4dc6e1859 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -39,7 +39,7 @@ public class TextBox : System.Windows.Controls.TextBox nameof(PlaceholderText), typeof(string), typeof(TextBox), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// Identifies the dependency property. diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index cc459c37a..ed156249a 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -441,7 +441,7 @@ public override void OnApplyTemplate() parentWindow = VisualTreeHelper.GetParent(parentWindow); } - this.MouseRightButtonUp += TitleBar_MouseRightButtonUp; + MouseRightButtonUp += TitleBar_MouseRightButtonUp; _mainGrid = GetTemplateChild(ElementMainGrid); _icon = GetTemplateChild(ElementIcon); diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 65a3aac3d..efc657e22 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -183,7 +183,7 @@ ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem ChildSize = CalculateChildSize(availableSize); } - ItemsPerRowCount = Double.IsInfinity(GetWidth(availableSize)) + ItemsPerRowCount = double.IsInfinity(GetWidth(availableSize)) ? Items.Count : Math.Max(1, (int)Math.Floor(GetWidth(availableSize) / GetWidth(ChildSize))); diff --git a/src/Wpf.Ui/Converters/TextToAsteriskConverter.cs b/src/Wpf.Ui/Converters/TextToAsteriskConverter.cs index bee99a69b..591c23bbd 100644 --- a/src/Wpf.Ui/Converters/TextToAsteriskConverter.cs +++ b/src/Wpf.Ui/Converters/TextToAsteriskConverter.cs @@ -11,7 +11,7 @@ internal class TextToAsteriskConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - return new String('*', value?.ToString()?.Length ?? 0); + return new string('*', value?.ToString()?.Length ?? 0); } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) diff --git a/src/Wpf.Ui/Extensions/UriExtensions.cs b/src/Wpf.Ui/Extensions/UriExtensions.cs index b275f2425..dc2e4a747 100644 --- a/src/Wpf.Ui/Extensions/UriExtensions.cs +++ b/src/Wpf.Ui/Extensions/UriExtensions.cs @@ -55,7 +55,7 @@ public static Uri Append(this Uri uri, params string[] segments) segments.Aggregate( uri.AbsoluteUri, (current, path) => - String.Format( + string.Format( "{0}/{1}", current.TrimEnd('/').TrimEnd('\\'), path.TrimStart('/').TrimStart('\\') @@ -70,7 +70,7 @@ public static Uri Append(this Uri uri, params string[] segments) public static Uri Append(this Uri uri, Uri value) { return new Uri( - String.Format( + string.Format( "{0}/{1}", uri.ToString().TrimEnd('/').TrimEnd('\\'), value.ToString().TrimStart('/').TrimStart('\\') diff --git a/src/Wpf.Ui/Hardware/RenderingTier.cs b/src/Wpf.Ui/Hardware/RenderingTier.cs index 131067b2e..354227d42 100644 --- a/src/Wpf.Ui/Hardware/RenderingTier.cs +++ b/src/Wpf.Ui/Hardware/RenderingTier.cs @@ -6,7 +6,7 @@ namespace Wpf.Ui.Hardware; /// -/// An value whose high-order word corresponds to the rendering tier for the current thread. +/// An value whose high-order word corresponds to the rendering tier for the current thread. /// Starting in the .NET Framework 4, rendering tier 1 has been redefined to only include graphics hardware that supports DirectX 9.0 or greater. Graphics hardware that supports DirectX 7 or 8 is now defined as rendering tier 0. /// public enum RenderingTier diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index 3e3f34940..4091de2ee 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -147,7 +147,7 @@ out var version ) ) { - version ??= String.Empty; + version ??= string.Empty; var versionParts = ((string)version).Split('.'); @@ -170,7 +170,7 @@ out var minorObj ) ) { - minorObj ??= String.Empty; + minorObj ??= string.Empty; minor = (int)minorObj; } @@ -184,7 +184,7 @@ out var version ) ) { - version ??= String.Empty; + version ??= string.Empty; var versionParts = ((string)version).Split('.'); @@ -205,7 +205,7 @@ out var buildObj ) ) { - buildObj ??= String.Empty; + buildObj ??= string.Empty; build = int.TryParse((string)buildObj, out int buildAsInt) ? buildAsInt : 0; } From 87d68c520bd6a0f88e92a395970d1fc2ca58e629 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 18:50:58 -0700 Subject: [PATCH 09/33] Fix warnings where attributes are on a single line SA1133 --- src/Wpf.Ui/Controls/Button/Button.cs | 21 ++++++++++++------- src/Wpf.Ui/Controls/CardAction/CardAction.cs | 6 ++++-- .../Controls/CardControl/CardControl.cs | 6 ++++-- .../Controls/CardExpander/CardExpander.cs | 9 +++++--- src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 12 +++++++---- .../Controls/IconElement/IconElement.cs | 3 ++- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs | 3 ++- .../NavigationViewContentPresenter.cs | 3 ++- .../NavigationView/NavigationViewItem.cs | 12 +++++++---- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 9 +++++--- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 6 ++++-- src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs | 3 ++- 12 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index 63e799fcb..7b80f077a 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -104,7 +104,8 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); @@ -112,7 +113,8 @@ public IconElement? Icon } /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public ControlAppearance Appearance { get => (ControlAppearance)GetValue(AppearanceProperty); @@ -122,7 +124,8 @@ public ControlAppearance Appearance /// /// Gets or sets background . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush MouseOverBackground { get => (Brush)GetValue(MouseOverBackgroundProperty); @@ -132,7 +135,8 @@ public Brush MouseOverBackground /// /// Gets or sets border when the user mouses over the button. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush MouseOverBorderBrush { get => (Brush)GetValue(MouseOverBorderBrushProperty); @@ -142,7 +146,8 @@ public Brush MouseOverBorderBrush /// /// Gets or sets the foreground when the user clicks the button. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush PressedForeground { get => (Brush)GetValue(PressedForegroundProperty); @@ -152,7 +157,8 @@ public Brush PressedForeground /// /// Gets or sets background when the user clicks the button. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush PressedBackground { get => (Brush)GetValue(PressedBackgroundProperty); @@ -162,7 +168,8 @@ public Brush PressedBackground /// /// Gets or sets border when the user clicks the button. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush PressedBorderBrush { get => (Brush)GetValue(PressedBorderBrushProperty); diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index 8f54bf12d..7c6ae7dcc 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -32,7 +32,8 @@ public class CardAction : System.Windows.Controls.Primitives.ButtonBase /// /// Gets or sets a value indicating whether to display the chevron icon on the right side of the card. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public bool IsChevronVisible { get => (bool)GetValue(IsChevronVisibleProperty); @@ -42,7 +43,8 @@ public bool IsChevronVisible /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); diff --git a/src/Wpf.Ui/Controls/CardControl/CardControl.cs b/src/Wpf.Ui/Controls/CardControl/CardControl.cs index 976faf821..27cf026d5 100644 --- a/src/Wpf.Ui/Controls/CardControl/CardControl.cs +++ b/src/Wpf.Ui/Controls/CardControl/CardControl.cs @@ -52,7 +52,8 @@ public object? Header /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); @@ -62,7 +63,8 @@ public IconElement? Icon /// /// Gets or sets the corner radius of the control. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public CornerRadius CornerRadius { get => (CornerRadius)GetValue(CornerRadiusProperty); diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 819d7c935..0e4870b15 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -43,7 +43,8 @@ public class CardExpander : System.Windows.Controls.Expander /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); @@ -53,7 +54,8 @@ public IconElement? Icon /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public CornerRadius CornerRadius { get => (CornerRadius)GetValue(CornerRadiusProperty); @@ -63,7 +65,8 @@ public CornerRadius CornerRadius /// /// Gets or sets content padding Property /// - [Bindable(true), Category("Layout")] + [Bindable(true)] + [Category("Layout")] public Thickness ContentPadding { get { return (Thickness)GetValue(ContentPaddingProperty); } diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index 2ace9f6a2..7fd2a4bf8 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -66,7 +66,8 @@ public class FontIcon : IconElement #region Properties /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] [Localizability(LocalizationCategory.Font)] public FontFamily FontFamily { @@ -76,7 +77,8 @@ public FontFamily FontFamily /// [TypeConverter(typeof(FontSizeConverter))] - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] [Localizability(LocalizationCategory.None)] public double FontSize { @@ -85,7 +87,8 @@ public double FontSize } /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public FontStyle FontStyle { get => (FontStyle)GetValue(FontStyleProperty); @@ -93,7 +96,8 @@ public FontStyle FontStyle } /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public FontWeight FontWeight { get => (FontWeight)GetValue(FontWeightProperty); diff --git a/src/Wpf.Ui/Controls/IconElement/IconElement.cs b/src/Wpf.Ui/Controls/IconElement/IconElement.cs index 708047776..b084d22db 100644 --- a/src/Wpf.Ui/Controls/IconElement/IconElement.cs +++ b/src/Wpf.Ui/Controls/IconElement/IconElement.cs @@ -36,7 +36,8 @@ static IconElement() ); /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush Foreground { get => (Brush)GetValue(ForegroundProperty); diff --git a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs index 8c8f88e2f..62ebf7a7d 100644 --- a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs +++ b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs @@ -75,7 +75,8 @@ public CornerRadius CornerRadius /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index 08e127e46..d0111fd02 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -39,7 +39,8 @@ public class NavigationViewContentPresenter : Frame new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsMeasure) ); - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public int TransitionDuration { get => (int)GetValue(TransitionDurationProperty); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index e6d55b819..98c30a526 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -160,7 +160,8 @@ public bool HasMenuItems } /// - [Browsable(false), ReadOnly(true)] + [Browsable(false)] + [ReadOnly(true)] public bool IsActive { get => (bool)GetValue(IsActiveProperty); @@ -168,14 +169,16 @@ public bool IsActive } /// - [Browsable(false), ReadOnly(true)] + [Browsable(false)] + [ReadOnly(true)] public bool IsExpanded { get => (bool)GetValue(IsExpandedProperty); set => SetValue(IsExpandedProperty, value); } - [Browsable(false), ReadOnly(true)] + [Browsable(false)] + [ReadOnly(true)] public bool IsPaneOpen { get => (bool)GetValue(IsPaneOpenProperty); @@ -183,7 +186,8 @@ public bool IsPaneOpen } /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index eed2598c4..b869117d1 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -191,7 +191,8 @@ public DataTemplate? TitleTemplate /// /// Gets or sets the icon /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); @@ -199,7 +200,8 @@ public IconElement? Icon } /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public ControlAppearance Appearance { get => (ControlAppearance)GetValue(AppearanceProperty); @@ -209,7 +211,8 @@ public ControlAppearance Appearance /// /// Gets or sets the foreground of the . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush ContentForeground { get => (Brush)GetValue(ContentForegroundProperty); diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index ed156249a..0dd8f39e7 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -227,7 +227,8 @@ public object? Header /// /// Gets or sets the foreground of the navigation buttons. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush ButtonsForeground { get => (Brush)GetValue(ButtonsForegroundProperty); @@ -237,7 +238,8 @@ public Brush ButtonsForeground /// /// Gets or sets the background of the navigation buttons when hovered. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public Brush ButtonsBackground { get => (Brush)GetValue(ButtonsBackgroundProperty); diff --git a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs index 1a777ddcb..73c69863e 100644 --- a/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs +++ b/src/Wpf.Ui/Controls/TreeView/TreeViewItem.cs @@ -22,7 +22,8 @@ public class TreeViewItem : System.Windows.Controls.TreeViewItem /// /// Gets or sets displayed . /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); From 7247479310efc744293c4cf3e97cca1a0e6ea125 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 19:16:03 -0700 Subject: [PATCH 10/33] When setting DPs, favor SetCurrentValue over the CLR setter. WPF0041 --- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 2 +- .../Controls/BreadcrumbBar/BreadcrumbBar.cs | 5 +++-- src/Wpf.Ui/Controls/CardColor/CardColor.cs | 4 ++-- .../Controls/ContentDialog/ContentDialog.cs | 20 +++++++++---------- .../DynamicScrollBar/DynamicScrollBar.cs | 2 +- src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 14 ++++++------- src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs | 4 ++-- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 20 +++++++++---------- .../NavigationView/NavigationView.Base.cs | 8 ++++---- .../NavigationView.Navigation.cs | 2 +- .../NavigationView.TemplateParts.cs | 4 ++-- .../NavigationViewContentPresenter.cs | 2 +- .../NavigationView/NavigationViewItem.cs | 20 ++++++++++--------- .../Controls/PasswordBox/PasswordBox.cs | 18 ++++++++--------- .../Controls/ProgressRing/ProgressRing.cs | 2 +- .../Controls/RatingControl/RatingControl.cs | 6 +++--- .../Controls/Snackbar/SnackbarPresenter.cs | 8 ++++---- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 10 +++++----- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 16 +++++++-------- .../Controls/TitleBar/TitleBarButton.cs | 10 +++++----- .../VirtualizingGridView.cs | 2 +- 21 files changed, 91 insertions(+), 88 deletions(-) diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 0b68760c0..126ff6d4b 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -400,7 +400,7 @@ protected virtual void Dispose(bool disposing) protected virtual void OnMenuChanged(ContextMenu contextMenu) { internalNotifyIconManager.ContextMenu = contextMenu; - internalNotifyIconManager.ContextMenu.FontSize = MenuFontSize; + internalNotifyIconManager.ContextMenu.SetCurrentValue(Control.FontSizeProperty, MenuFontSize); } private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index b408bc6dd..3e6fc279d 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -143,7 +143,7 @@ private void ItemContainerGeneratorOnStatusChanged(object? sender, EventArgs e) return; } - InteractWithItemContainer(2, static item => item.IsLast = false); + InteractWithItemContainer(2, static item => item.SetCurrentValue(BreadcrumbBarItem.IsLastProperty, false)); UpdateLastContainer(); } @@ -181,5 +181,6 @@ private void InteractWithItemContainer(int offsetFromEnd, Action InteractWithItemContainer(1, static item => item.IsLast = true); + private void UpdateLastContainer() + => InteractWithItemContainer(1, static item => item.SetCurrentValue(BreadcrumbBarItem.IsLastProperty, true)); } diff --git a/src/Wpf.Ui/Controls/CardColor/CardColor.cs b/src/Wpf.Ui/Controls/CardColor/CardColor.cs index bbd21889f..0daab976b 100644 --- a/src/Wpf.Ui/Controls/CardColor/CardColor.cs +++ b/src/Wpf.Ui/Controls/CardColor/CardColor.cs @@ -126,7 +126,7 @@ protected virtual void OnSubtitlePropertyChanged() { } /// protected virtual void OnColorPropertyChanged() { - CardBrush = new SolidColorBrush(Color); + SetCurrentValue(CardBrushProperty, new SolidColorBrush(Color)); } /// @@ -134,7 +134,7 @@ protected virtual void OnColorPropertyChanged() /// protected virtual void OnBrushPropertyChanged() { - CardBrush = Brush; + SetCurrentValue(CardBrushProperty, Brush); } private static void OnSubtitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 9a8e701eb..708ca9978 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -531,7 +531,7 @@ public async Task ShowAsync(CancellationToken cancellationT try { - ContentPresenter.Content = this; + ContentPresenter.SetCurrentValue(ContentPresenter.ContentProperty, this); result = await Tcs.Task; return result; @@ -543,7 +543,7 @@ public async Task ShowAsync(CancellationToken cancellationT #else tokenRegistration.Dispose(); #endif - ContentPresenter.Content = null; + ContentPresenter.SetCurrentValue(ContentPresenter.ContentProperty, null); OnClosed(result); } } @@ -622,8 +622,8 @@ protected override Size MeasureOverride(Size availableSize) Size newSize = GetNewDialogSize(desiredSize); - DialogHeight = newSize.Height; - DialogWidth = newSize.Width; + SetCurrentValue(DialogHeightProperty, newSize.Height); + SetCurrentValue(DialogWidthProperty, newSize.Width); ResizeWidth(rootElement); ResizeHeight(rootElement); @@ -666,14 +666,14 @@ private void ResizeWidth(UIElement element) return; } - DialogWidth = DialogMaxWidth; + SetCurrentValue(DialogWidthProperty, DialogMaxWidth); element.UpdateLayout(); - DialogHeight = element.DesiredSize.Height; + SetCurrentValue(DialogHeightProperty, element.DesiredSize.Height); if (DialogHeight > DialogMaxHeight) { - DialogMaxHeight = DialogHeight; + SetCurrentValue(DialogMaxHeightProperty, DialogHeight); /*Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogHeight > DialogMaxHeight after resizing width!");*/ } } @@ -685,14 +685,14 @@ private void ResizeHeight(UIElement element) return; } - DialogHeight = DialogMaxHeight; + SetCurrentValue(DialogHeightProperty, DialogMaxHeight); element.UpdateLayout(); - DialogWidth = element.DesiredSize.Width; + SetCurrentValue(DialogWidthProperty, element.DesiredSize.Width); if (DialogWidth > DialogMaxWidth) { - DialogMaxWidth = DialogWidth; + SetCurrentValue(DialogMaxWidthProperty, DialogWidth); /*Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogWidth > DialogMaxWidth after resizing height!");*/ } } diff --git a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs index 2b425c7bd..9206fdcfb 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs @@ -116,7 +116,7 @@ private async Task UpdateScroll() return; } - IsInteracted = shouldScroll; + SetCurrentValue(IsInteractedProperty, shouldScroll); } private static void OnIsScrollingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index 7fd2a4bf8..3b0a0d473 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -122,7 +122,7 @@ protected override UIElement InitializeChildren() { if (VisualParent is not null) { - FontSize = TextElement.GetFontSize(VisualParent); + SetCurrentValue(FontSizeProperty, TextElement.GetFontSize(VisualParent)); } if (FontSize.Equals(SystemFonts.MessageFontSize)) @@ -145,7 +145,7 @@ protected override UIElement InitializeChildren() Focusable = false, }; - Focusable = false; + SetCurrentValue(FocusableProperty, false); return TextBlock; } @@ -160,7 +160,7 @@ private static void OnFontFamilyChanged(DependencyObject d, DependencyPropertyCh return; } - self.TextBlock.FontFamily = (FontFamily)e.NewValue; + self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.FontFamilyProperty, (FontFamily)e.NewValue); } private static void OnFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -171,7 +171,7 @@ private static void OnFontSizeChanged(DependencyObject d, DependencyPropertyChan return; } - self.TextBlock.FontSize = (double)e.NewValue; + self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.FontSizeProperty, (double)e.NewValue); } private static void OnFontStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -182,7 +182,7 @@ private static void OnFontStyleChanged(DependencyObject d, DependencyPropertyCha return; } - self.TextBlock.FontStyle = (FontStyle)e.NewValue; + self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.FontStyleProperty, (FontStyle)e.NewValue); } private static void OnFontWeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -193,7 +193,7 @@ private static void OnFontWeightChanged(DependencyObject d, DependencyPropertyCh return; } - self.TextBlock.FontWeight = (FontWeight)e.NewValue; + self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.FontWeightProperty, (FontWeight)e.NewValue); } private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -204,7 +204,7 @@ private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChanged return; } - self.TextBlock.Text = (string)e.NewValue; + self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.TextProperty, (string)e.NewValue); } #endregion diff --git a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs index 387adce2e..43f173f6e 100644 --- a/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/SymbolIcon.cs @@ -67,11 +67,11 @@ private void OnGlyphChanged() { if (Filled) { - Glyph = Symbol.Swap().GetString(); + SetCurrentValue(GlyphProperty, Symbol.Swap().GetString()); } else { - Glyph = Symbol.GetString(); + SetCurrentValue(GlyphProperty, Symbol.GetString()); } } diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 3db5aab79..348e7fea1 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -340,8 +340,8 @@ protected virtual void ResizeToContentSize(UIElement rootElement) // left and right margin const double margin = 12.0 * 2; - Width = desiredSize.Width + margin; - Height = desiredSize.Height; + SetCurrentValue(WidthProperty, desiredSize.Width + margin); + SetCurrentValue(HeightProperty, desiredSize.Height); ResizeWidth(rootElement); ResizeHeight(rootElement); @@ -365,8 +365,8 @@ protected virtual void CenterWindowOnScreen() double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; - Left = (screenWidth / 2) - (Width / 2); - Top = (screenHeight / 2) - (Height / 2); + SetCurrentValue(LeftProperty, (screenWidth / 2) - (Width / 2)); + SetCurrentValue(TopProperty, (screenHeight / 2) - (Height / 2)); } /// @@ -401,14 +401,14 @@ private void ResizeWidth(UIElement element) return; } - Width = MaxWidth; + SetCurrentValue(WidthProperty, MaxWidth); element.UpdateLayout(); - Height = element.DesiredSize.Height; + SetCurrentValue(HeightProperty, element.DesiredSize.Height); if (Height > MaxHeight) { - MaxHeight = Height; + SetCurrentValue(MaxHeightProperty, Height); } } @@ -419,14 +419,14 @@ private void ResizeHeight(UIElement element) return; } - Height = MaxHeight; + SetCurrentValue(HeightProperty, MaxHeight); element.UpdateLayout(); - Width = element.DesiredSize.Width; + SetCurrentValue(WidthProperty, element.DesiredSize.Width); if (Width > MaxWidth) { - MaxWidth = Width; + SetCurrentValue(MaxWidthProperty, Width); } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index 05e7c84b8..0b853223e 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -182,7 +182,7 @@ protected virtual void OnBackButtonClick(object sender, RoutedEventArgs e) /// protected virtual void OnToggleButtonClick(object sender, RoutedEventArgs e) { - IsPaneOpen = !IsPaneOpen; + SetCurrentValue(IsPaneOpenProperty, !IsPaneOpen); } /// @@ -190,7 +190,7 @@ protected virtual void OnToggleButtonClick(object sender, RoutedEventArgs e) /// protected virtual void AutoSuggestBoxSymbolButtonOnClick(object sender, RoutedEventArgs e) { - IsPaneOpen = !IsPaneOpen; + SetCurrentValue(IsPaneOpenProperty, !IsPaneOpen); AutoSuggestBox?.Focus(); } @@ -202,8 +202,8 @@ protected virtual void OnPaneDisplayModeChanged() switch (PaneDisplayMode) { case NavigationViewPaneDisplayMode.LeftFluent: - IsBackButtonVisible = NavigationViewBackButtonVisible.Collapsed; - IsPaneToggleVisible = false; + SetCurrentValue(IsBackButtonVisibleProperty, NavigationViewBackButtonVisible.Collapsed); + SetCurrentValue(IsPaneToggleVisibleProperty, false); break; } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 765544afb..c315f4e34 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -233,7 +233,7 @@ private void AddToJournal(INavigationViewItem viewItem, bool isBackwardsNavigate Journal.Add(viewItem.Id); _currentIndexInJournal++; - IsBackEnabled = CanGoBack; + SetCurrentValue(IsBackEnabledProperty, CanGoBack); #if DEBUG Debug.WriteLineIf(EnableDebugMessages, $"JOURNAL INDEX {_currentIndexInJournal}"); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs index ced7ead58..583ca3100 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs @@ -108,8 +108,8 @@ public override void OnApplyTemplate() TemplateElementFooterMenuItemsItemsControl ); - MenuItemsItemsControl.ItemsSource = MenuItems; - FooterMenuItemsItemsControl.ItemsSource = FooterMenuItems; + MenuItemsItemsControl.SetCurrentValue(System.Windows.Controls.ItemsControl.ItemsSourceProperty, MenuItems); + FooterMenuItemsItemsControl.SetCurrentValue(System.Windows.Controls.ItemsControl.ItemsSourceProperty, FooterMenuItems); if (NavigationViewContentPresenter is not null) { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index d0111fd02..d3e618e20 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -164,7 +164,7 @@ protected virtual void OnNavigated(NavigationEventArgs eventArgs) return; } - IsDynamicScrollViewerEnabled = ScrollViewer.GetCanContentScroll(dependencyObject); + SetCurrentValue(IsDynamicScrollViewerEnabledProperty, ScrollViewer.GetCanContentScroll(dependencyObject)); } private void ApplyTransitionEffectToNavigatedPage(object content) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index 98c30a526..c228570fd 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -289,7 +289,7 @@ public NavigationViewItem(string name, SymbolRegular icon, Type targetPageType, /// public virtual void Activate(INavigationView navigationView) { - IsActive = true; + SetCurrentValue(IsActiveProperty, true); if (!navigationView.IsPaneOpen && NavigationViewItemParent is not null) { @@ -325,12 +325,12 @@ Icon is SymbolIcon symbolIcon /// public virtual void Deactivate(INavigationView navigationView) { - IsActive = false; + SetCurrentValue(IsActiveProperty, false); NavigationViewItemParent?.Deactivate(navigationView); if (!navigationView.IsPaneOpen && HasMenuItems) { - IsExpanded = false; + SetCurrentValue(IsExpandedProperty, false); } if ( @@ -360,7 +360,9 @@ protected override void OnInitialized(EventArgs e) if (string.IsNullOrWhiteSpace(TargetPageTag) && Content is not null) { - TargetPageTag = Content as string ?? Content.ToString()?.ToLower().Trim() ?? string.Empty; + SetCurrentValue( + TargetPageTagProperty, + Content as string ?? Content.ToString()?.ToLower().Trim() ?? string.Empty); } } @@ -374,7 +376,7 @@ protected override void OnClick() if (HasMenuItems && navigationView.IsPaneOpen) { - IsExpanded = !IsExpanded; + SetCurrentValue(IsExpandedProperty, !IsExpanded); } if (TargetPageType is not null) @@ -418,7 +420,7 @@ protected override void OnMouseDown(MouseButtonEventArgs e) return; } - IsExpanded = !IsExpanded; + SetCurrentValue(IsExpandedProperty, !IsExpanded); for (int i = 0; i < MenuItems.Count; i++) { @@ -480,10 +482,10 @@ private void InitializeNavigationViewEvents() { if (NavigationView.GetNavigationParent(this) is { } navigationView) { - IsPaneOpen = navigationView.IsPaneOpen; + SetCurrentValue(IsPaneOpenProperty, navigationView.IsPaneOpen); - navigationView.PaneOpened += (_, _) => IsPaneOpen = true; - navigationView.PaneClosed += (_, _) => IsPaneOpen = false; + navigationView.PaneOpened += (_, _) => SetCurrentValue(IsPaneOpenProperty, true); + navigationView.PaneClosed += (_, _) => SetCurrentValue(IsPaneOpenProperty, false); } } } diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index 4109ac043..1c5f134fb 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -127,12 +127,12 @@ protected override void OnTextChanged(TextChangedEventArgs e) { if (PlaceholderEnabled && Text.Length > 0) { - PlaceholderEnabled = false; + SetCurrentValue(PlaceholderEnabledProperty, false); } if (!PlaceholderEnabled && Text.Length < 1) { - PlaceholderEnabled = true; + SetCurrentValue(PlaceholderEnabledProperty, true); } RevealClearButton(); @@ -161,7 +161,7 @@ protected virtual void OnPasswordCharChanged() _lockUpdatingContents = true; - Text = new string(PasswordChar, Password.Length); + SetCurrentValue(TextProperty, new string(PasswordChar, Password.Length)); _lockUpdatingContents = false; } @@ -170,7 +170,7 @@ protected virtual void OnPasswordRevealModeChanged() { _lockUpdatingContents = true; - Text = IsPasswordRevealed ? Password : new string(PasswordChar, Password.Length); + SetCurrentValue(TextProperty, IsPasswordRevealed ? Password : new string(PasswordChar, Password.Length)); _lockUpdatingContents = false; } @@ -191,7 +191,7 @@ protected override void OnTemplateButtonClick(string? parameter) switch (parameter) { case "reveal": - IsPasswordRevealed = !IsPasswordRevealed; + SetCurrentValue(IsPasswordRevealedProperty, !IsPasswordRevealed); Focus(); CaretIndex = Text.Length; break; @@ -219,11 +219,11 @@ private void UpdateTextContents(bool isTriggeredByTextInput) if (isTriggeredByTextInput) { - Password = Text; + SetCurrentValue(PasswordProperty, Text); } else { - Text = Password; + SetCurrentValue(TextProperty, Password); CaretIndex = Text.Length; } @@ -280,8 +280,8 @@ private void UpdateTextContents(bool isTriggeredByTextInput) _lockUpdatingContents = true; - Text = new string(PasswordChar, newPasswordValue.Length); - Password = newPasswordValue; + SetCurrentValue(TextProperty, new string(PasswordChar, newPasswordValue.Length)); + SetCurrentValue(PasswordProperty, newPasswordValue); CaretIndex = caretIndex; RaiseEvent(new RoutedEventArgs(PasswordChangedEvent)); diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index a29685001..ee1ffaf26 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -148,7 +148,7 @@ protected void UpdateProgressAngle() endAngle = 359; } - EngAngle = endAngle; + SetCurrentValue(EngAngleProperty, endAngle); } /// diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index 3dacc6d3e..e2fedfacf 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -111,14 +111,14 @@ protected virtual void OnValueChanged(double oldValue) { if (Value > MaxValue) { - Value = MaxValue; + SetCurrentValue(ValueProperty, MaxValue); return; } if (Value < MinValue) { - Value = MinValue; + SetCurrentValue(ValueProperty, MinValue); return; } @@ -236,7 +236,7 @@ private void UpdateStarsOnMouseClick(double offsetPercentage) { var currentValue = ExtractValueFromOffset(offsetPercentage); - Value = currentValue / 2D; + SetCurrentValue(ValueProperty, currentValue / 2.0); } private void UpdateStarsFromValue() diff --git a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs index 1e249d68b..efa3bfcac 100644 --- a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs +++ b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs @@ -82,9 +82,9 @@ private async Task ShowQueuedSnackbars() private async Task ShowSnackbar(Snackbar snackbar) { - Content = snackbar; + SetCurrentValue(ContentProperty, snackbar); - snackbar.IsShown = true; + snackbar.SetCurrentValue(Snackbar.IsShownProperty, true); try { @@ -100,10 +100,10 @@ private async Task ShowSnackbar(Snackbar snackbar) private async Task HidSnackbar(Snackbar snackbar) { - snackbar.IsShown = false; + snackbar.SetCurrentValue(Snackbar.IsShownProperty, false); await Task.Delay(300); - Content = null; + SetCurrentValue(ContentProperty, null); } } diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index 4dc6e1859..9c8642b18 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -171,12 +171,12 @@ protected override void OnTextChanged(TextChangedEventArgs e) if (PlaceholderEnabled && Text.Length > 0) { - PlaceholderEnabled = false; + SetCurrentValue(PlaceholderEnabledProperty, false); } if (!PlaceholderEnabled && Text.Length < 1) { - PlaceholderEnabled = true; + SetCurrentValue(PlaceholderEnabledProperty, true); } RevealClearButton(); @@ -207,7 +207,7 @@ protected void RevealClearButton() { if (ClearButtonEnabled && IsKeyboardFocusWithin) { - ShowClearButton = Text.Length > 0; + SetCurrentValue(ShowClearButtonProperty, Text.Length > 0); } } @@ -218,7 +218,7 @@ protected void HideClearButton() { if (ClearButtonEnabled && !IsKeyboardFocusWithin && ShowClearButton) { - ShowClearButton = false; + SetCurrentValue(ShowClearButtonProperty, false); } } @@ -229,7 +229,7 @@ protected virtual void OnClearButtonClick() { if (Text.Length > 0) { - Text = string.Empty; + SetCurrentValue(TextProperty, string.Empty); } } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 0dd8f39e7..86bb09e02 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -403,7 +403,7 @@ protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); - ApplicationTheme = Appearance.ApplicationThemeManager.GetAppTheme(); + SetCurrentValue(ApplicationThemeProperty, Appearance.ApplicationThemeManager.GetAppTheme()); Appearance.ApplicationThemeManager.Changed += OnThemeChanged; } @@ -472,7 +472,7 @@ Color systemAccent "Wpf.Ui.TitleBar" ); - ApplicationTheme = currentApplicationTheme; + SetCurrentValue(ApplicationThemeProperty, currentApplicationTheme); } private void CloseWindow() @@ -500,7 +500,7 @@ private void MinimizeWindow() return; } - _currentWindow.WindowState = WindowState.Minimized; + _currentWindow.SetCurrentValue(Window.WindowStateProperty, WindowState.Minimized); } private void MaximizeWindow() @@ -519,13 +519,13 @@ private void MaximizeWindow() if (_currentWindow.WindowState == WindowState.Normal) { - IsMaximized = true; - _currentWindow.WindowState = WindowState.Maximized; + SetCurrentValue(IsMaximizedProperty, true); + _currentWindow.SetCurrentValue(Window.WindowStateProperty, WindowState.Maximized); } else { - IsMaximized = false; - _currentWindow.WindowState = WindowState.Normal; + SetCurrentValue(IsMaximizedProperty, false); + _currentWindow.SetCurrentValue(Window.WindowStateProperty, WindowState.Normal); } } @@ -533,7 +533,7 @@ private void OnParentWindowStateChanged(object? sender, EventArgs e) { if (IsMaximized != (_currentWindow.WindowState == WindowState.Maximized)) { - IsMaximized = _currentWindow.WindowState == WindowState.Maximized; + SetCurrentValue(IsMaximizedProperty, _currentWindow.WindowState == WindowState.Maximized); } } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index 88e6e014a..af69868b2 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -107,7 +107,7 @@ private void TitleBarButton_Unloaded(object sender, RoutedEventArgs e) private void TitleBarButton_Loaded(object sender, RoutedEventArgs e) { - RenderButtonsForeground = ButtonsForeground; + SetCurrentValue(RenderButtonsForegroundProperty, ButtonsForeground); DependencyPropertyDescriptor .FromProperty(ButtonsForegroundProperty, typeof(Brush)) .AddValueChanged(this, OnButtonsForegroundChanged); @@ -131,10 +131,10 @@ public void Hover() return; } - Background = MouseOverBackground; + SetCurrentValue(BackgroundProperty, MouseOverBackground); if (MouseOverButtonsForeground != null) { - RenderButtonsForeground = MouseOverButtonsForeground; + SetCurrentValue(RenderButtonsForegroundProperty, MouseOverButtonsForeground); } IsHovered = true; @@ -150,8 +150,8 @@ public void RemoveHover() return; } - Background = _defaultBackgroundBrush; - RenderButtonsForeground = ButtonsForeground; + SetCurrentValue(BackgroundProperty, _defaultBackgroundBrush); + SetCurrentValue(RenderButtonsForegroundProperty, ButtonsForeground); IsHovered = false; _isClickedDown = false; diff --git a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs index 36c23aed2..97d275f6b 100644 --- a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs +++ b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs @@ -126,6 +126,6 @@ protected virtual void InitializeItemsPanel() } ); - ItemsPanel = new ItemsPanelTemplate(factory); + SetCurrentValue(ItemsPanelProperty, new ItemsPanelTemplate(factory)); } } From 7f714f204f46fa1e30a59d4b064ce1f64e7df304 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 19:30:18 -0700 Subject: [PATCH 11/33] Remove unnecessary things (parenthesis, assignments, etc). SA1119, IDE0059 --- src/Wpf.Ui.Gallery/Controllers/MonacoController.cs | 3 +-- .../ViewModels/Pages/Collections/DataGridViewModel.cs | 2 +- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 1 - src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs | 2 ++ .../Controls/NavigationView/NavigationView.Properties.cs | 2 +- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 1 - src/Wpf.Ui/Controls/SplitButton/SplitButton.cs | 7 +------ src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 3 +-- src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs | 2 ++ .../VirtualizingWrapPanel/VirtualizingWrapPanel.cs | 4 ++-- src/Wpf.Ui/Interop/Dwmapi.cs | 6 +++--- 11 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs index a4eb20a29..f42b9506e 100644 --- a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs +++ b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs @@ -35,11 +35,10 @@ await _webView.ExecuteScriptAsync( public async Task SetThemeAsync(ApplicationTheme appApplicationTheme) { + // TODO: Parse theme from object const string uiThemeName = "wpf-ui-app-theme"; var baseMonacoTheme = appApplicationTheme == ApplicationTheme.Light ? "vs" : "vs-dark"; - // TODO: Parse theme from object - await _webView.ExecuteScriptAsync( $$$""" monaco.editor.defineTheme('{{{uiThemeName}}}', { diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs index 70a4e4156..f1c1b8223 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs @@ -24,7 +24,7 @@ private ObservableCollection GenerateProducts() var adjectives = new[] { "Red", "Blueberry" }; var names = new[] { "Marmalade", "Dumplings", "Soup" }; - var units = new[] { "grams", "kilograms", "milliliters" }; + /*var units = new[] { "grams", "kilograms", "milliliters" };*/ for (int i = 0; i < 50; i++) { diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 126ff6d4b..fd29754d1 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -279,7 +279,6 @@ public NotifyIcon() /// public void Unregister() => internalNotifyIconManager.Unregister(); - /// public void Dispose() { Dispose(true); diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index 3e6fc279d..8de2c32d3 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -173,7 +173,9 @@ private void OnTemplateButtonClick(object? obj) private void InteractWithItemContainer(int offsetFromEnd, Action action) { if (ItemContainerGenerator.Items.Count <= 0) + { return; + } var item = ItemContainerGenerator.Items[^offsetFromEnd]; var container = (BreadcrumbBarItem)ItemContainerGenerator.ContainerFromItem(item); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index be8ccafce..849e3fdef 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -240,7 +240,7 @@ public partial class NavigationView nameof(FrameMargin), typeof(Thickness), typeof(NavigationView), - new FrameworkPropertyMetadata(new Thickness()) + new FrameworkPropertyMetadata(default(Thickness)) ); /// diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index 5e3418c8d..a0194b431 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -225,7 +225,6 @@ static NumberBox() MinLinesProperty.OverrideMetadata(typeof(NumberBox), new FrameworkPropertyMetadata(1)); } - /// public NumberBox() : base() { diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index 8e458e5d6..8a9a32f82 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -147,12 +147,7 @@ protected virtual void ReleaseTemplateResources() private void OnSplitButtonToggleButtonOnClick(object sender, RoutedEventArgs e) { - if (sender is not ToggleButton toggleButton) - { - return; - } - - if (_contextMenu is null) + if (sender is not ToggleButton || _contextMenu is null) { return; } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 86bb09e02..41e07a59f 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -633,8 +633,7 @@ or User32.WM.NCLBUTTONUP switch (message) { case User32.WM.NCHITTEST - when (CloseWindowByDoubleClickOnIcon && _icon.IsMouseOverElement(lParam)): - + when CloseWindowByDoubleClickOnIcon && _icon.IsMouseOverElement(lParam): // Ideally, clicking on the icon should open the system menu, but when the system menu is opened manually, double-clicking on the icon does not close the window handled = true; return (IntPtr)User32.WM_NCHITTEST.HTSYSMENU; diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs index 38b05aefb..2e44526e1 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs @@ -51,9 +51,11 @@ public object Content public TreeGrid() { + /* var x = new System.Windows.Controls.ContentControl(); var y = new System.Windows.Controls.ItemsControl(); var z = new System.Windows.Controls.ListBox(); + */ } /*/// diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index efc657e22..8efb578e2 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -224,7 +224,7 @@ protected override Size CalculateExtent(Size availableSize) ? GetWidth(availableSize) : GetWidth(ChildSize) * ItemsPerRowCount; - if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) + if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo) { extentWidth = Orientation == Orientation.Vertical @@ -282,7 +282,7 @@ protected override Size ArrangeOverride(Size finalSize) var offsetY = GetY(Offset); /* When the items owner is a group item offset is handled by the parent panel. */ - if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) + if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo) { offsetY = 0; } diff --git a/src/Wpf.Ui/Interop/Dwmapi.cs b/src/Wpf.Ui/Interop/Dwmapi.cs index 14eca2a32..21fe81655 100644 --- a/src/Wpf.Ui/Interop/Dwmapi.cs +++ b/src/Wpf.Ui/Interop/Dwmapi.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - -// NOTE +// - +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods From 1f4ad8984f2fcb7595443caa2db51a735fe91d1c Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 19:47:14 -0700 Subject: [PATCH 12/33] Fix order of operation warnings --- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 2 +- src/Wpf.Ui/Controls/SymbolGlyph.cs | 4 ++-- .../VirtualizingWrapPanel.cs | 22 ++++++++----------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index a0194b431..d85c2bde6 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -416,7 +416,7 @@ private void UpdateTextToValue() // text = value var newText = string.Empty; - if (Value is not null) + if (Value is not null && NumberFormatter is not null) { newText = NumberFormatter.FormatDouble(Math.Round((double)Value, MaxDecimalPlaces)); } diff --git a/src/Wpf.Ui/Controls/SymbolGlyph.cs b/src/Wpf.Ui/Controls/SymbolGlyph.cs index bd04905a1..227cd2bae 100644 --- a/src/Wpf.Ui/Controls/SymbolGlyph.cs +++ b/src/Wpf.Ui/Controls/SymbolGlyph.cs @@ -35,7 +35,7 @@ public static SymbolRegular Parse(string name) { return (SymbolRegular)Enum.Parse(typeof(SymbolRegular), name); } - catch (Exception _) + catch (Exception) { #if DEBUG throw; @@ -60,7 +60,7 @@ public static SymbolFilled ParseFilled(string name) { return (SymbolFilled)Enum.Parse(typeof(SymbolFilled), name); } - catch (Exception e) + catch (Exception) { #if DEBUG throw; diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 8efb578e2..535dbdbc8 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -300,7 +300,7 @@ protected override Size ArrangeOverride(Size finalSize) int columnIndex = itemIndex % ItemsPerRowCount; int rowIndex = itemIndex / ItemsPerRowCount; - double x = outerSpacing + columnIndex * (GetWidth(childSize) + innerSpacing); + double x = outerSpacing + (columnIndex * (GetWidth(childSize) + innerSpacing)); double y = rowIndex * GetHeight(childSize); if (GetHeight(finalSize) == 0.0) @@ -427,15 +427,11 @@ protected override ItemRange UpdateItemRange() int rowCountInCacheBefore = (int)(cacheBeforeInPixel / GetHeight(ChildSize)); int rowCountInCacheAfter = - ( - (int) - Math.Ceiling( - (offsetInPixel + viewportHeight + cacheAfterInPixel) / GetHeight(ChildSize) - ) - ) - (int)Math.Ceiling((offsetInPixel + viewportHeight) / GetHeight(ChildSize)); - - startIndex = Math.Max(startIndex - rowCountInCacheBefore * ItemsPerRowCount, 0); - endIndex = Math.Min(endIndex + rowCountInCacheAfter * ItemsPerRowCount, Items.Count - 1); + ((int)Math.Ceiling((offsetInPixel + viewportHeight + cacheAfterInPixel) / GetHeight(ChildSize))) + - (int)Math.Ceiling((offsetInPixel + viewportHeight) / GetHeight(ChildSize)); + + startIndex = Math.Max(startIndex - (rowCountInCacheBefore * ItemsPerRowCount), 0); + endIndex = Math.Min(endIndex + (rowCountInCacheAfter * ItemsPerRowCount), Items.Count - 1); } else if (CacheLengthUnit == VirtualizationCacheLengthUnit.Item) { @@ -458,14 +454,14 @@ protected override ItemRange UpdateItemRange() startIndex = startRowIndex * ItemsPerRowCount; int endRowIndex = GetRowIndex(viewportEndPos); - endIndex = Math.Min(endRowIndex * ItemsPerRowCount + (ItemsPerRowCount - 1), Items.Count - 1); + endIndex = Math.Min((endRowIndex * ItemsPerRowCount) + (ItemsPerRowCount - 1), Items.Count - 1); if (CacheLengthUnit == VirtualizationCacheLengthUnit.Page) { int itemsPerPage = endIndex - startIndex + 1; - startIndex = Math.Max(startIndex - (int)CacheLength.CacheBeforeViewport * itemsPerPage, 0); + startIndex = Math.Max(startIndex - ((int)CacheLength.CacheBeforeViewport * itemsPerPage), 0); endIndex = Math.Min( - endIndex + (int)CacheLength.CacheAfterViewport * itemsPerPage, + endIndex + ((int)CacheLength.CacheAfterViewport * itemsPerPage), Items.Count - 1 ); } From ef554283c808e31ba7f195a8db90dd758f184d31 Mon Sep 17 00:00:00 2001 From: koal44 Date: Fri, 29 Mar 2024 20:07:11 -0700 Subject: [PATCH 13/33] Do not use regions SA1124. Clean VirtualizingPanelBase of warnings --- src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs | 4 - src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 20 ---- src/Wpf.Ui.Tray/Interop/User32.cs | 5 +- .../Controls/ContentDialog/ContentDialog.cs | 24 ---- .../DynamicScrollViewer.cs | 2 - src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 12 -- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 12 -- .../NavigationView.Navigation.cs | 4 - .../NavigationView/NavigationViewItem.cs | 8 -- .../NavigationViewItemHeader.cs | 2 - .../NavigationViewItemSeparator.cs | 2 - src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 8 -- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 8 -- src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs | 2 - src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 8 -- .../VirtualizingPanelBase.cs | 111 ++++++++++-------- .../VirtualizingWrapPanel.cs | 7 +- 17 files changed, 65 insertions(+), 174 deletions(-) diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs b/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs index a6dd4a9a0..b2280e8e4 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs @@ -31,8 +31,6 @@ INavigationService navigationService navigationService.SetNavigationControl(RootNavigation); } - #region INavigationWindow methods - public INavigationView GetNavigation() => RootNavigation; public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType); @@ -43,8 +41,6 @@ INavigationService navigationService public void CloseWindow() => Close(); - #endregion INavigationWindow methods - /// /// Raises the closed event. /// diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index fd29754d1..486633130 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -37,8 +37,6 @@ public class NotifyIcon : System.Windows.FrameworkElement /// protected bool Disposed = false; - #region Public variables - public int Id => internalNotifyIconManager.Id; /// @@ -50,10 +48,6 @@ public class NotifyIcon : System.Windows.FrameworkElement public IntPtr ParentHandle { get; set; } - #endregion - - #region Properties - /// Identifies the dependency property. public static readonly DependencyProperty TooltipTextProperty = DependencyProperty.Register( nameof(TooltipText), @@ -147,10 +141,6 @@ public double MenuFontSize set => SetValue(MenuFontSizeProperty, value); } - #endregion - - #region Events - /// Identifies the routed event. public static readonly RoutedEvent LeftClickEvent = EventManager.RegisterRoutedEvent( nameof(LeftClick), @@ -253,10 +243,6 @@ public event RoutedNotifyIconEvent MiddleDoubleClick remove => RemoveHandler(MiddleDoubleClickEvent, value); } - #endregion - - #region General methods - public NotifyIcon() { internalNotifyIconManager = new Wpf.Ui.Tray.Internal.InternalNotifyIconManager(); @@ -286,10 +272,6 @@ public void Dispose() GC.SuppressFinalize(this); } - #endregion - - #region Protected methods - /// protected override void OnRender(DrawingContext drawingContext) { @@ -390,8 +372,6 @@ protected virtual void Dispose(bool disposing) internalNotifyIconManager.Dispose(); } - #endregion - /// /// This virtual method is called when of is changed. /// diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs index a632c6331..d38a22a70 100644 --- a/src/Wpf.Ui.Tray/Interop/User32.cs +++ b/src/Wpf.Ui.Tray/Interop/User32.cs @@ -549,13 +549,10 @@ public enum WM GETTITLEBARINFOEX = 0x033F, - #region Windows 7 - + // Windows 7 DWMSENDICONICTHUMBNAIL = 0x0323, DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326, - #endregion - USER = 0x0400, /// diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 708ca9978..1b7aec739 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -43,8 +43,6 @@ namespace Wpf.Ui.Controls; /// public class ContentDialog : ContentControl { - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), @@ -244,10 +242,6 @@ public class ContentDialog : ContentControl typeof(ContentDialog) ); - #endregion - - #region Properties - /// /// Gets or sets the title of the . /// @@ -469,8 +463,6 @@ public event TypedEventHandler remove => RemoveHandler(ButtonClickedEvent, value); } - #endregion - /// /// Initializes a new instance of the class. /// @@ -509,8 +501,6 @@ public ContentDialog(ContentPresenter contentPresenter) protected TaskCompletionSource? Tcs; - #region Public methods - /// /// Shows the dialog /// @@ -566,10 +556,6 @@ public virtual void Hide(ContentDialogResult result = ContentDialogResult.None) } } - #endregion - - #region Protected methods - /// /// Occurs after ContentPresenter.Content = null /// @@ -609,10 +595,6 @@ protected virtual void OnButtonClick(ContentDialogButton button) Hide(result); } - #endregion - - #region Base methods - protected override Size MeasureOverride(Size availableSize) { var rootElement = (UIElement)GetVisualChild(0)!; @@ -641,10 +623,6 @@ protected virtual void OnLoaded() RaiseEvent(new RoutedEventArgs(OpenedEvent)); } - #endregion - - #region Resize private methods - private Size GetNewDialogSize(Size desiredSize) { var paddingWidth = Padding.Left + Padding.Right; @@ -696,6 +674,4 @@ private void ResizeHeight(UIElement element) /*Debug.WriteLine($"DEBUG | {GetType()} | WARNING | DialogWidth > DialogMaxWidth after resizing height!");*/ } } - - #endregion } diff --git a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs index fd3f29074..b258adf97 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Custom with events depending on actions taken by the user. /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(DynamicScrollViewer), "DynamicScrollViewer.bmp")] [DefaultEvent("ScrollChangedEvent")] public class DynamicScrollViewer : PassiveScrollViewer { diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index 3b0a0d473..d10ce2003 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -17,8 +17,6 @@ namespace Wpf.Ui.Controls; /// public class FontIcon : IconElement { - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register( nameof(FontFamily), @@ -61,10 +59,6 @@ public class FontIcon : IconElement new FrameworkPropertyMetadata(string.Empty, OnGlyphChanged) ); - #endregion - - #region Properties - /// [Bindable(true)] [Category("Appearance")] @@ -114,8 +108,6 @@ public string Glyph set => SetValue(GlyphProperty, value); } - #endregion - protected TextBlock? TextBlock; protected override UIElement InitializeChildren() @@ -150,8 +142,6 @@ protected override UIElement InitializeChildren() return TextBlock; } - #region Static methods - private static void OnFontFamilyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var self = (FontIcon)d; @@ -206,6 +196,4 @@ private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChanged self.TextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.TextProperty, (string)e.NewValue); } - - #endregion } diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 348e7fea1..0b5582890 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -15,8 +15,6 @@ namespace Wpf.Ui.Controls; /// public class MessageBox : System.Windows.Window { - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register( nameof(ShowTitle), @@ -121,10 +119,6 @@ public class MessageBox : System.Windows.Window new PropertyMetadata(null) ); - #endregion - - #region Properties - /// /// Gets or sets a value indicating whether to show the in . /// @@ -238,8 +232,6 @@ public bool IsPrimaryButtonEnabled /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); - #endregion - /// /// Initializes a new instance of the class. /// @@ -392,8 +384,6 @@ private void RemoveTitleBarAndApplyMica() WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Mica); } - #region Resize private methods - private void ResizeWidth(UIElement element) { if (Width <= MaxWidth) @@ -429,6 +419,4 @@ private void ResizeHeight(UIElement element) SetCurrentValue(MaxWidthProperty, Width); } } - - #endregion } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index c315f4e34..6e1c8db8c 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -350,8 +350,6 @@ System.Windows.Navigation.NavigationEventArgs e ((NavigationViewContentPresenter)sender).JournalOwnership =*/ } - #region Navigation stack methods - private void AddToNavigationStack( INavigationViewItem viewItem, bool addToNavigationStack, @@ -518,6 +516,4 @@ private void ReplaceThirstElementInNavigationStack(INavigationViewItem newItem) NavigationStack[0] = newItem; NavigationStack[0].Activate(this); } - - #endregion } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index c228570fd..c930b13bb 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -27,8 +27,6 @@ public class NavigationViewItem { protected const string TemplateElementChevronGrid = "PART_ChevronGrid"; - #region Static properties - private static readonly DependencyPropertyKey MenuItemsPropertyKey = DependencyProperty.RegisterReadOnly( nameof(MenuItems), typeof(ObservableCollection), @@ -124,10 +122,6 @@ public class NavigationViewItem new FrameworkPropertyMetadata(NavigationCacheMode.Disabled) ); - #endregion - - #region Properties - /// public IList MenuItems => (ObservableCollection)GetValue(MenuItemsProperty); @@ -221,8 +215,6 @@ public NavigationCacheMode NavigationCacheMode set => SetValue(NavigationCacheModeProperty, value); } - #endregion - /// public INavigationViewItem? NavigationViewItemParent { get; set; } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs index 8bc709c4b..cc6993a1f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs @@ -14,8 +14,6 @@ namespace Wpf.Ui.Controls; /// /// Represents a header for a group of menu items in a NavigationMenu. /// -//[ToolboxItem(true)] -//[System.Drawing.ToolboxBitmap(typeof(NavigationViewItemHeader), "NavigationViewItemHeader.bmp")] public class NavigationViewItemHeader : System.Windows.Controls.Control { /// diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs index 9b6becac3..ce89f6513 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs @@ -14,6 +14,4 @@ namespace Wpf.Ui.Controls; /// /// Represents a line that separates menu items in a NavigationMenu. /// -//[ToolboxItem(true)] -//[System.Drawing.ToolboxBitmap(typeof(NavigationViewItemSeparator), "NavigationViewItemSeparator.bmp")] public class NavigationViewItemSeparator : System.Windows.Controls.Separator { } diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index b869117d1..1ece705ea 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -17,8 +17,6 @@ namespace Wpf.Ui.Controls; /// public class Snackbar : ContentControl, IAppearanceControl, IIconControl { - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty IsCloseButtonEnabledProperty = DependencyProperty.Register( nameof(IsCloseButtonEnabled), @@ -118,10 +116,6 @@ public class Snackbar : ContentControl, IAppearanceControl, IIconControl typeof(Snackbar) ); - #endregion - - #region Properties - /// /// Gets or sets a value indicating whether the close button should be visible. /// @@ -242,8 +236,6 @@ public event TypedEventHandler Closed remove => RemoveHandler(ClosedEvent, value); } - #endregion - /// /// Initializes a new instance of the class with a specified presenter. /// diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index 9c8642b18..e33781008 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -16,8 +16,6 @@ namespace Wpf.Ui.Controls; /// public class TextBox : System.Windows.Controls.TextBox { - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), @@ -82,10 +80,6 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(null) ); - #endregion - - #region Properties - /// /// Gets or sets displayed . /// @@ -154,8 +148,6 @@ public bool IsTextSelectionEnabled /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); - #endregion - /// /// Initializes a new instance of the class. /// diff --git a/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs b/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs index 9475b5315..2975b373b 100644 --- a/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs +++ b/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs @@ -11,8 +11,6 @@ namespace Wpf.Ui.Controls; /// /// Allows to rate positively or negatively by clicking on one of the thumbs. /// -//[ToolboxItem(true)] -//[ToolboxBitmap(typeof(ThumbRate), "ThumbRate.bmp")] public class ThumbRate : System.Windows.Controls.Control { /// diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 41e07a59f..8d1de86bd 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -37,8 +37,6 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl private DependencyObject? parentWindow; - #region Static properties - /// Identifies the dependency property. public static readonly DependencyProperty ApplicationThemeProperty = DependencyProperty.Register( nameof(ApplicationTheme), @@ -195,10 +193,6 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl new PropertyMetadata(null) ); - #endregion - - #region Properties - /// public Appearance.ApplicationTheme ApplicationTheme { @@ -378,8 +372,6 @@ public event TypedEventHandler HelpClicked /// public Action? MinimizeActionOverride { get; set; } - #endregion - private System.Windows.Window _currentWindow = null!; private System.Windows.Controls.Grid _mainGrid = null!; private System.Windows.Controls.ContentPresenter _icon = null!; diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs index bab82c513..20e5ee3b6 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs @@ -1,12 +1,15 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger // All Rights Reserved. +// - +// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. +// https://github.com/sbaeumlisberger/VirtualizingWrapPanel using System.Collections.ObjectModel; using System.Collections.Specialized; @@ -21,12 +24,8 @@ namespace Wpf.Ui.Controls; /// Base abstract class for creating virtualized panels. /// Based on . /// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel public abstract class VirtualizingPanelBase : VirtualizingPanel, IScrollInfo { - #region Private properties - /// /// Owner of the displayed items. /// @@ -47,10 +46,6 @@ public abstract class VirtualizingPanelBase : VirtualizingPanel, IScrollInfo /// private Visibility _previousHorizontalScrollBarVisibility = Visibility.Collapsed; - #endregion Private properties - - #region Protected properties - /// protected override bool CanHierarchicallyScrollAndVirtualizeCore => true; @@ -60,12 +55,12 @@ public abstract class VirtualizingPanelBase : VirtualizingPanel, IScrollInfo protected ScrollUnit ScrollUnit => GetScrollUnit(ItemsControl); /// - /// The direction in which the panel scrolls when user turns the mouse wheel. + /// Gets or sets the direction in which the panel scrolls when user turns the mouse wheel. /// protected ScrollDirection MouseWheelScrollDirection { get; set; } = ScrollDirection.Vertical; /// - /// Gets a value that inidicates whether the virtualizing is enabled. + /// Gets a value indicating whether the virtualizing is enabled. /// protected bool IsVirtualizing => GetIsVirtualizing(ItemsControl); @@ -75,35 +70,37 @@ public abstract class VirtualizingPanelBase : VirtualizingPanel, IScrollInfo protected VirtualizationMode VirtualizationMode => GetVirtualizationMode(ItemsControl); /// - /// Returns true if the panel is in VirtualizationMode.Recycling, otherwise false. + /// Gets a value indicating whether the panel is in VirtualizationMode.Recycling. /// protected bool IsRecycling => VirtualizationMode == VirtualizationMode.Recycling; /// - /// The cache length before and after the viewport. + /// Gets the cache length before and after the viewport. /// protected VirtualizationCacheLength CacheLength { get; private set; } /// - /// The Unit of the cache length. Can be Pixel, Item or Page. + /// Gets the Unit of the cache length. Can be Pixel, Item or Page. /// When the ItemsOwner is a group item it can only be pixel or item. /// protected VirtualizationCacheLengthUnit CacheLengthUnit { get; private set; } /// - /// The ItemsControl (e.g. ListView). + /// Gets the ItemsControl (e.g. ListView). /// protected ItemsControl ItemsControl => ItemsControl.GetItemsOwner(this); /// - /// The ItemsControl (e.g. ListView) or if the ItemsControl is grouping a GroupItem. + /// Gets the ItemsControl (e.g. ListView) or if the ItemsControl is grouping a GroupItem. /// protected DependencyObject ItemsOwner { get { if (_itemsOwner is not null) + { return _itemsOwner; + } /* Use reflection to access internal method because the public * GetItemsOwner method does always return the itmes control instead @@ -123,7 +120,7 @@ protected DependencyObject ItemsOwner } /// - /// Items collection. + /// Gets items collection. /// protected ReadOnlyCollection Items => ((ItemContainerGenerator)ItemContainerGenerator).Items; @@ -133,18 +130,20 @@ protected DependencyObject ItemsOwner protected Point Offset { get; private set; } = new(0, 0); /// - /// Items container. + /// Gets items container. /// protected new IRecyclingItemContainerGenerator ItemContainerGenerator { get { if (_itemContainerGenerator is not null) + { return _itemContainerGenerator; + } /* Because of a bug in the framework the ItemContainerGenerator * is null until InternalChildren accessed at least one time. */ - var children = InternalChildren; + _ = InternalChildren; _itemContainerGenerator = (IRecyclingItemContainerGenerator)base.ItemContainerGenerator; return _itemContainerGenerator; @@ -166,10 +165,6 @@ protected DependencyObject ItemsOwner /// protected Size Viewport { get; private set; } = new Size(0, 0); - #endregion Protected properties - - #region Public properties - /// /// Property for . /// @@ -216,17 +211,17 @@ protected DependencyObject ItemsOwner public ScrollViewer? ScrollOwner { get; set; } /// - /// Gets or sets a value that indicates whether the content can be vertically scrolled. + /// Gets or sets a value indicating whether the content can be vertically scrolled. /// public bool CanVerticallyScroll { get; set; } /// - /// Gets or sets a value that indicates whether the content can be horizontally scrolled. + /// Gets or sets a value indicating whether the content can be horizontally scrolled. /// public bool CanHorizontallyScroll { get; set; } /// - /// Scroll line delta for pixel based scrolling. The default value is 16 dp. + /// Gets or sets the scroll line delta for pixel based scrolling. The default value is 16 dp. /// public double ScrollLineDelta { @@ -235,7 +230,7 @@ public double ScrollLineDelta } /// - /// Mouse wheel delta for pixel based scrolling. The default value is 48 dp. + /// Gets or sets the mouse wheel delta for pixel based scrolling. The default value is 48 dp. /// public double MouseWheelDelta { @@ -244,16 +239,16 @@ public double MouseWheelDelta } /// - /// Scroll line delta for item based scrolling. The default value is 1 item. + /// Gets or sets the scroll line delta for item based scrolling. The default value is 1 item. /// - public double ScrollLineDeltaItem + public int ScrollLineDeltaItem { get => (int)GetValue(ScrollLineDeltaItemProperty); set => SetValue(ScrollLineDeltaItemProperty, value); } /// - /// Mouse wheel delta for item based scrolling. The default value is 3 items. + /// Gets or sets the mouse wheel delta for item based scrolling. The default value is 3 items. /// public int MouseWheelDeltaItem { @@ -291,10 +286,6 @@ public int MouseWheelDeltaItem /// public double ViewportHeight => Viewport.Height; - #endregion Public properties - - #region Public methods - /// public virtual Rect MakeVisible(Visual visual, Rect rectangle) { @@ -340,9 +331,13 @@ public virtual Rect MakeVisible(Visual visual, Rect rectangle) public void SetVerticalOffset(double offset) { if (offset < 0 || Viewport.Height >= Extent.Height) + { offset = 0; + } else if (offset + Viewport.Height >= Extent.Height) + { offset = Extent.Height - Viewport.Height; + } Offset = new Point(Offset.X, offset); ScrollOwner?.InvalidateScrollInfo(); @@ -356,9 +351,13 @@ public void SetVerticalOffset(double offset) public void SetHorizontalOffset(double offset) { if (offset < 0 || Viewport.Width >= Extent.Width) + { offset = 0; + } else if (offset + Viewport.Width >= Extent.Width) + { offset = Extent.Width - Viewport.Width; + } Offset = new Point(offset, Offset.Y); ScrollOwner?.InvalidateScrollInfo(); @@ -385,20 +384,28 @@ public void LineRight() => public void MouseWheelUp() { if (MouseWheelScrollDirection == ScrollDirection.Vertical) + { ScrollVertical(ScrollUnit == ScrollUnit.Pixel ? -MouseWheelDelta : GetMouseWheelUpScrollAmount()); + } else + { MouseWheelLeft(); + } } /// public void MouseWheelDown() { if (MouseWheelScrollDirection == ScrollDirection.Vertical) + { ScrollVertical( ScrollUnit == ScrollUnit.Pixel ? MouseWheelDelta : GetMouseWheelDownScrollAmount() ); + } else + { MouseWheelRight(); + } } /// @@ -425,10 +432,6 @@ public void PageLeft() => public void PageRight() => ScrollHorizontal(ScrollUnit == ScrollUnit.Pixel ? ViewportHeight : GetPageRightScrollAmount()); - #endregion Public methods - - #region Protected methods - /// protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args) { @@ -480,7 +483,9 @@ protected virtual void UpdateScrollInfo(Size availableSize, Size extent) } if (invalidateScrollInfo) + { ScrollOwner?.InvalidateScrollInfo(); + } } /// @@ -521,8 +526,10 @@ protected override Size MeasureOverride(Size availableSize) _previousVerticalScrollBarVisibility = ScrollOwner.ComputedVerticalScrollBarVisibility; _previousHorizontalScrollBarVisibility = ScrollOwner.ComputedHorizontalScrollBarVisibility; - if (!ScrollOwner.IsMeasureValid && verticalScrollBarGotHidden || horizontalScrollBarGotHidden) + if ((!ScrollOwner.IsMeasureValid && verticalScrollBarGotHidden) || horizontalScrollBarGotHidden) + { return availableSize; + } } var groupItem = ItemsOwner as IHierarchicalVirtualizationAndScrollInfo; @@ -588,16 +595,18 @@ protected virtual void RealizeItems() { var child = (UIElement)ItemContainerGenerator.GenerateNext(out bool isNewlyRealized); - if ( - isNewlyRealized - || /*recycled*/ - !InternalChildren.Contains(child) + if (isNewlyRealized + || !InternalChildren.Contains(child) /*recycled*/ ) { if (childIndex >= InternalChildren.Count) + { AddInternalChild(child); + } else + { InsertInternalChild(childIndex, child); + } ItemContainerGenerator.PrepareItemContainer(child); @@ -605,7 +614,9 @@ protected virtual void RealizeItems() } if (child is not IHierarchicalVirtualizationAndScrollInfo groupItem) + { continue; + } groupItem.Constraints = new HierarchicalVirtualizationConstraints( new VirtualizationCacheLength(0), @@ -629,12 +640,18 @@ protected virtual void VirtualizeItems() var itemIndex = ItemContainerGenerator.IndexFromGeneratorPosition(generatorPosition); if (itemIndex == -1 || ItemRange.Contains(itemIndex)) + { continue; + } if (VirtualizationMode == VirtualizationMode.Recycling) + { ItemContainerGenerator.Recycle(generatorPosition, 1); + } else + { ItemContainerGenerator.Remove(generatorPosition, 1); + } RemoveInternalChildRange(childIndex, 1); } @@ -658,10 +675,6 @@ protected void ScrollHorizontal(double amount) SetHorizontalOffset(HorizontalOffset + amount); } - #endregion Protected methods - - #region Protected abstract methods - /// /// Calculates the extent that would be needed to show all items. /// @@ -731,6 +744,4 @@ protected void ScrollHorizontal(double amount) /// Gets page right scroll amount. /// protected abstract double GetPageRightScrollAmount(); - - #endregion Protected abstract methods } diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 535dbdbc8..ddb2724fd 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -7,6 +7,9 @@ // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger // All Rights Reserved. +// - +// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. +// https://github.com/sbaeumlisberger/VirtualizingWrapPanel using System.Windows.Controls; using System.Windows.Controls.Primitives; @@ -20,10 +23,6 @@ namespace Wpf.Ui.Controls; /// Extended base class for . /// Based on . /// -// [ToolboxItem(true)] -// [ToolboxBitmap(typeof(VirtualizingWrapPanel), "VirtualizingWrapPanel.bmp")] -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel public class VirtualizingWrapPanel : VirtualizingPanelBase { /// From d50f6aa6e83053ad87a9a2b640e96c265829b824 Mon Sep 17 00:00:00 2001 From: koal44 Date: Sat, 30 Mar 2024 09:48:12 -0700 Subject: [PATCH 14/33] Turn protected control fields into protected properties. fix some documentation warnings --- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 4 ++-- src/Wpf.Ui.Tray/Interop/Shell32.cs | 2 +- .../Controls/ContentDialog/ContentDialog.cs | 2 +- src/Wpf.Ui/Controls/IconElement/FontIcon.cs | 2 +- .../NavigationViewItemHeader.cs | 21 ++++++++---------- .../Controls/RatingControl/RatingControl.cs | 16 +++++++------- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 1 - .../Controls/SplitButton/SplitButton.cs | 4 ++-- src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs | 22 ++++++++----------- .../VirtualizingPanelBase.cs | 16 ++++---------- .../VirtualizingWrapPanel.cs | 12 +++++----- 11 files changed, 43 insertions(+), 59 deletions(-) diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 486633130..90f4db9d9 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -33,9 +33,9 @@ public class NotifyIcon : System.Windows.FrameworkElement private readonly Wpf.Ui.Tray.Internal.InternalNotifyIconManager internalNotifyIconManager; /// - /// Whether the control is disposed. + /// Gets or sets a value indicating whether the control is disposed. /// - protected bool Disposed = false; + protected bool Disposed { get; set; } = false; public int Id => internalNotifyIconManager.Id; diff --git a/src/Wpf.Ui.Tray/Interop/Shell32.cs b/src/Wpf.Ui.Tray/Interop/Shell32.cs index d91eeb8c0..741ca1c8f 100644 --- a/src/Wpf.Ui.Tray/Interop/Shell32.cs +++ b/src/Wpf.Ui.Tray/Interop/Shell32.cs @@ -132,7 +132,7 @@ public class NOTIFYICONDATA public Guid guidItem; // Vista only - IntPtr hBalloonIcon; + public IntPtr hBalloonIcon; } [DllImport(Libraries.Shell32, PreserveSig = false)] diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 1b7aec739..3758aa8b7 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -499,7 +499,7 @@ public ContentDialog(ContentPresenter contentPresenter) /// public ContentPresenter? ContentPresenter { get; set; } = default; - protected TaskCompletionSource? Tcs; + protected TaskCompletionSource? Tcs { get; set; } /// /// Shows the dialog diff --git a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs index d10ce2003..5df83e1bd 100644 --- a/src/Wpf.Ui/Controls/IconElement/FontIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/FontIcon.cs @@ -108,7 +108,7 @@ public string Glyph set => SetValue(GlyphProperty, value); } - protected TextBlock? TextBlock; + protected TextBlock? TextBlock { get; set; } protected override UIElement InitializeChildren() { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs index cc6993a1f..0eb08fa0a 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs @@ -5,20 +5,18 @@ // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. +// - +// https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationviewitemheader?view=winrt-22621 // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -// https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationviewitemheader?view=winrt-22621 - /// /// Represents a header for a group of menu items in a NavigationMenu. /// public class NavigationViewItemHeader : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TextProperty = DependencyProperty.Register( nameof(Text), typeof(string), @@ -26,9 +24,7 @@ public class NavigationViewItemHeader : System.Windows.Controls.Control new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IconProperty = DependencyProperty.Register( nameof(Icon), typeof(IconElement), @@ -37,7 +33,7 @@ public class NavigationViewItemHeader : System.Windows.Controls.Control ); /// - /// Text presented in the header element. + /// Gets or sets the text presented in the header element. /// [Bindable(true)] public string Text @@ -47,12 +43,13 @@ public string Text } /// - /// + /// Gets or sets the icon. /// - [Bindable(true), Category("Appearance")] + [Bindable(true)] + [Category("Appearance")] public IconElement? Icon { - get => (IconElement)GetValue(IconProperty); + get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); } } diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index e2fedfacf..255ccb2ef 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -340,7 +340,7 @@ private void SetStarsPresence(int index) private void UpdateStar(int starIndex, StarValue starValue) { - var _selectedIcon = starIndex switch + var selectedIcon = starIndex switch { 1 => _symbolIconStarTwo, 2 => _symbolIconStarThree, @@ -349,7 +349,7 @@ private void UpdateStar(int starIndex, StarValue starValue) _ => _symbolIconStarOne, }; - if (_selectedIcon is null) + if (selectedIcon is null) { return; } @@ -357,18 +357,18 @@ private void UpdateStar(int starIndex, StarValue starValue) switch (starValue) { case StarValue.HalfFilled: - _selectedIcon.Filled = false; - _selectedIcon.Symbol = StarHalfSymbol; + selectedIcon.Filled = false; + selectedIcon.Symbol = StarHalfSymbol; break; case StarValue.Filled: - _selectedIcon.Filled = true; - _selectedIcon.Symbol = StarSymbol; + selectedIcon.Filled = true; + selectedIcon.Symbol = StarSymbol; break; default: - _selectedIcon.Filled = false; - _selectedIcon.Symbol = StarSymbol; + selectedIcon.Filled = false; + selectedIcon.Symbol = StarSymbol; break; } } diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index 1ece705ea..b95bb3511 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -4,7 +4,6 @@ // All Rights Reserved. using System.Windows.Controls; -using Wpf.Ui.Converters; using Wpf.Ui.Input; // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index 8a9a32f82..d77fdc9a8 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -23,9 +23,9 @@ public class SplitButton : Wpf.Ui.Controls.Button private const string TemplateElementToggleButton = "ToggleButton"; /// - /// Control responsible for toggling the drop-down button. + /// Gets or sets control responsible for toggling the drop-down button. /// - protected ToggleButton SplitButtonToggleButton = null!; + protected ToggleButton SplitButtonToggleButton { get; set; } = null!; /// Identifies the dependency property. public static readonly DependencyProperty FlyoutProperty = DependencyProperty.Register( diff --git a/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs b/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs index 2975b373b..478b08e6a 100644 --- a/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs +++ b/src/Wpf.Ui/Controls/ThumbRate/ThumbRate.cs @@ -13,9 +13,7 @@ namespace Wpf.Ui.Controls; /// public class ThumbRate : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty StateProperty = DependencyProperty.Register( nameof(State), typeof(ThumbRateState), @@ -23,9 +21,7 @@ public class ThumbRate : System.Windows.Controls.Control new PropertyMetadata(ThumbRateState.None, OnStateChanged) ); - /// - /// Event property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent StateChangedEvent = EventManager.RegisterRoutedEvent( nameof(StateChanged), RoutingStrategy.Bubble, @@ -42,9 +38,7 @@ public event TypedEventHandler StateChanged remove => RemoveHandler(StateChangedEvent, value); } - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -62,12 +56,12 @@ public ThumbRateState State } /// - /// Command triggered after clicking the button. + /// Gets the command triggered when clicking the button. /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); /// - /// Creates new instance and attaches . + /// Initializes a new instance of the class and attaches . /// public ThumbRate() { @@ -81,11 +75,11 @@ protected virtual void OnTemplateButtonClick(ThumbRateState parameter) { if (State == parameter) { - State = ThumbRateState.None; + SetCurrentValue(StateProperty, ThumbRateState.None); return; } - State = parameter; + SetCurrentValue(StateProperty, parameter); } /// @@ -99,7 +93,9 @@ protected virtual void OnStateChanged(ThumbRateState previousState, ThumbRateSta private static void OnStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not ThumbRate thumbRate) + { return; + } thumbRate.OnStateChanged((ThumbRateState)e.OldValue, (ThumbRateState)e.NewValue); } diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs index 20e5ee3b6..227b5fb04 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs @@ -165,9 +165,7 @@ protected DependencyObject ItemsOwner /// protected Size Viewport { get; private set; } = new Size(0, 0); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ScrollLineDeltaProperty = DependencyProperty.Register( nameof(ScrollLineDelta), typeof(double), @@ -175,9 +173,7 @@ protected DependencyObject ItemsOwner new FrameworkPropertyMetadata(16.0) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MouseWheelDeltaProperty = DependencyProperty.Register( nameof(MouseWheelDelta), typeof(double), @@ -185,9 +181,7 @@ protected DependencyObject ItemsOwner new FrameworkPropertyMetadata(48.0) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ScrollLineDeltaItemProperty = DependencyProperty.Register( nameof(ScrollLineDeltaItem), typeof(int), @@ -195,9 +189,7 @@ protected DependencyObject ItemsOwner new FrameworkPropertyMetadata(1) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MouseWheelDeltaItemProperty = DependencyProperty.Register( nameof(MouseWheelDeltaItem), typeof(int), diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index ddb2724fd..75af8ac59 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -26,19 +26,19 @@ namespace Wpf.Ui.Controls; public class VirtualizingWrapPanel : VirtualizingPanelBase { /// - /// Size of the single child element. + /// Gets or sets the size of the single child element. /// - protected Size ChildSize; + protected Size ChildSize { get; set; } /// - /// Amount of the displayed rows. + /// Gets or sets the amount of the displayed rows. /// - protected int RowCount; + protected int RowCount { get; set; } /// - /// Amount of displayed items per row. + /// Gets or sets the amount of displayed items per row. /// - protected int ItemsPerRowCount; + protected int ItemsPerRowCount { get; set; } /// Identifies the dependency property. public static readonly DependencyProperty SpacingModeProperty = DependencyProperty.Register( From b4d9616d698b4cbb3601e6f92fed50aa07ae0554 Mon Sep 17 00:00:00 2001 From: koal44 Date: Sat, 30 Mar 2024 11:11:58 -0700 Subject: [PATCH 15/33] Cleanup warnings in Interop classes and suppress warnings related to uper-casing and private fields --- src/Wpf.Ui/Interop/Dwmapi.cs | 10 +++-- src/Wpf.Ui/Interop/HRESULT.cs | 18 +++++---- src/Wpf.Ui/Interop/Kernel32.cs | 11 ++--- src/Wpf.Ui/Interop/ShObjIdl.cs | 32 ++++++++------- src/Wpf.Ui/Interop/Shell32.cs | 12 ++++-- src/Wpf.Ui/Interop/UnsafeNativeMethods.cs | 49 ++++++++++++----------- src/Wpf.Ui/Interop/UnsafeReflection.cs | 2 +- src/Wpf.Ui/Interop/User32.cs | 38 +++++++++--------- src/Wpf.Ui/Interop/UxTheme.cs | 4 ++ src/Wpf.Ui/Interop/WinDef/POINT.cs | 8 +++- src/Wpf.Ui/Interop/WinDef/POINTL.cs | 8 +++- src/Wpf.Ui/Interop/WinDef/RECT.cs | 37 +++++++++-------- src/Wpf.Ui/Interop/WinDef/RECTL.cs | 37 +++++++++-------- src/Wpf.Ui/Interop/WinDef/SIZE.cs | 8 +++- 14 files changed, 158 insertions(+), 116 deletions(-) diff --git a/src/Wpf.Ui/Interop/Dwmapi.cs b/src/Wpf.Ui/Interop/Dwmapi.cs index 21fe81655..2cb8200df 100644 --- a/src/Wpf.Ui/Interop/Dwmapi.cs +++ b/src/Wpf.Ui/Interop/Dwmapi.cs @@ -11,18 +11,20 @@ // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods +// - +// Windows Kits\10\Include\10.0.22000.0\um\dwmapi.h using System.Runtime.InteropServices; namespace Wpf.Ui.Interop; -// Windows Kits\10\Include\10.0.22000.0\um\dwmapi.h +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter /// /// Desktop Window Manager (DWM). /// -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming internal static class Dwmapi { /// @@ -656,3 +658,5 @@ [In] int cbAttribute [DllImport(Libraries.Dwmapi, EntryPoint = "#127", PreserveSig = false, CharSet = CharSet.Unicode)] public static extern void DwmGetColorizationParameters([Out] out DWMCOLORIZATIONPARAMS dwParameters); } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter diff --git a/src/Wpf.Ui/Interop/HRESULT.cs b/src/Wpf.Ui/Interop/HRESULT.cs index 80e5c662e..3d829dab2 100644 --- a/src/Wpf.Ui/Interop/HRESULT.cs +++ b/src/Wpf.Ui/Interop/HRESULT.cs @@ -12,30 +12,32 @@ namespace Wpf.Ui.Interop; /// internal struct HRESULT { - /// + /// /// Operation successful. - /// + /// public const int S_OK = unchecked((int)0x00000000); - /// + /// /// Operation successful. - /// + /// public const int NO_ERROR = unchecked((int)0x00000000); - /// + /// /// Operation successful. - /// + /// public const int NOERROR = unchecked((int)0x00000000); - /// + /// /// Unspecified failure. - /// + /// public const int S_FALSE = unchecked((int)0x00000001); public static void Check(int hr) { if (hr >= S_OK) + { return; + } Marshal.ThrowExceptionForHR(hr, (IntPtr)(-1)); } diff --git a/src/Wpf.Ui/Interop/Kernel32.cs b/src/Wpf.Ui/Interop/Kernel32.cs index e6d6a9a45..2a41ebfcf 100644 --- a/src/Wpf.Ui/Interop/Kernel32.cs +++ b/src/Wpf.Ui/Interop/Kernel32.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - -// NOTE +// - +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods @@ -16,11 +16,12 @@ namespace Wpf.Ui.Interop; +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming + /// /// Used by multiple technologies. /// -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming internal class Kernel32 { /// diff --git a/src/Wpf.Ui/Interop/ShObjIdl.cs b/src/Wpf.Ui/Interop/ShObjIdl.cs index d4de49f7b..f909410b4 100644 --- a/src/Wpf.Ui/Interop/ShObjIdl.cs +++ b/src/Wpf.Ui/Interop/ShObjIdl.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - -// NOTE +// - +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods @@ -16,11 +16,13 @@ namespace Wpf.Ui.Interop; +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + /// /// Exposes methods that enumerate the contents of a view and receive notification from callback upon enumeration completion. /// -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming internal static class ShObjIdl { /// @@ -170,7 +172,7 @@ public interface ITaskbarList4 // ITaskbarList3 [PreserveSig] - void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal); + void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal); [PreserveSig] void SetProgressState(IntPtr hwnd, TBPFLAG tbpFlags); @@ -188,11 +190,11 @@ public interface ITaskbarList4 void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved); /// - /// + /// Adds thumbnail toolbar buttons to the specified window. /// - /// - /// - /// + /// Window handle. + /// Number of buttons. + /// Array of buttons. /// HRESULT [PreserveSig] int ThumbBarAddButtons( @@ -202,11 +204,11 @@ int ThumbBarAddButtons( ); /// - /// + /// Updates thumbnail toolbar buttons for the specified window. /// - /// - /// - /// + /// Window handle. + /// Number of buttons. + /// Array of buttons to update. /// HRESULT [PreserveSig] int ThumbBarUpdateButtons( @@ -235,3 +237,5 @@ void SetOverlayIcon( void SetTabProperties(IntPtr hwndTab, STPFLAG stpFlags); } } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index 3c0339734..cad8717d4 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -17,11 +17,14 @@ namespace Wpf.Ui.Interop; +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter +#pragma warning disable SA1401 // Fields should be private + /// /// The Windows UI provides users with access to a wide variety of objects necessary to run applications and manage the operating system. /// -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming internal static class Shell32 { /// @@ -140,7 +143,7 @@ public class NOTIFYICONDATA public Guid guidItem; // Vista only - IntPtr hBalloonIcon; + public IntPtr hBalloonIcon; } [DllImport(Libraries.Shell32, PreserveSig = false)] @@ -182,3 +185,6 @@ public static extern int GetCurrentProcessExplicitAppUserModelID( [Out, MarshalAs(UnmanagedType.LPWStr)] out string AppID ); } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter +#pragma warning restore SA1401 // Fields should be private diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index 935a8796f..3db8bb8a0 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -155,10 +155,10 @@ public static bool RemoveWindowTitlebarContents(Window? window) return GetHandle(window, out IntPtr windowHandle) && RemoveWindowTitlebarContents(windowHandle); } - window.Loaded += (sender, _) => + window.Loaded += (sender, _1) => { - GetHandle(sender as Window, out IntPtr windowHandle); - RemoveWindowTitlebarContents(windowHandle); + _ = GetHandle(sender as Window, out IntPtr windowHandle); + _ = RemoveWindowTitlebarContents(windowHandle); }; return true; @@ -294,7 +294,7 @@ public static bool ApplyWindowLegacyMicaEffect(Window? window) => /// if invocation of native Windows function succeeds. public static bool ApplyWindowLegacyMicaEffect(IntPtr handle) { - var backdropPvAttribute = 0x1; //Enable + var backdropPvAttribute = 0x1; // Enable // TODO: Validate HRESULT _ = Dwmapi.DwmSetWindowAttribute( @@ -376,7 +376,9 @@ public static Color GetDwmColor() return Color.FromArgb(255, values[2], values[1], values[0]); } - catch { } + catch + { + } } } @@ -400,9 +402,7 @@ internal static bool SetTaskbarState(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag) return false; } - var taskbarList = new ShObjIdl.CTaskbarList() as ShObjIdl.ITaskbarList4; - - if (taskbarList == null) + if (new ShObjIdl.CTaskbarList() is not ShObjIdl.ITaskbarList4 taskbarList) { return false; } @@ -414,11 +414,13 @@ internal static bool SetTaskbarState(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag) } /// - /// Tries to set taskbar value for the selected window handle. + /// Updates the taskbar progress bar value for a window. /// - /// Window handle. - /// Current value. - /// Total value to divide. + /// The handle to the window. + /// Progress state flag (paused, etc). + /// Current progress value. + /// Maximum progress value. + /// True if successful updated, otherwise false. internal static bool SetTaskbarValue(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag, int current, int total) { if (hWnd == IntPtr.Zero) @@ -431,10 +433,9 @@ internal static bool SetTaskbarValue(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag, return false; } - // TODO: Get existing taskbar class - var taskbarList = new ShObjIdl.CTaskbarList() as ShObjIdl.ITaskbarList4; + /* TODO: Get existing taskbar class */ - if (taskbarList is null) + if (new ShObjIdl.CTaskbarList() is not ShObjIdl.ITaskbarList4 taskbarList) { return false; } @@ -442,9 +443,9 @@ internal static bool SetTaskbarValue(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag, taskbarList.HrInit(); taskbarList.SetProgressState(hWnd, taskbarFlag); - if ( - taskbarFlag != ShObjIdl.TBPFLAG.TBPF_INDETERMINATE - && taskbarFlag != ShObjIdl.TBPFLAG.TBPF_NOPROGRESS + if (taskbarFlag is + not ShObjIdl.TBPFLAG.TBPF_INDETERMINATE + and not ShObjIdl.TBPFLAG.TBPF_NOPROGRESS ) { taskbarList.SetProgressValue(hWnd, Convert.ToUInt64(current), Convert.ToUInt64(total)); @@ -507,10 +508,10 @@ public static bool ExtendClientAreaIntoTitleBar(Window window) public static bool ExtendClientAreaIntoTitleBar(IntPtr hWnd) { - // !! EXPERIMENTAl - - // NOTE: - // WinRt has ExtendContentIntoTitlebar, but it needs some digging + /* + * !! EXPERIMENTAl !! + * NOTE: WinRt has ExtendContentIntoTitlebar, but it needs some digging + */ if (hWnd == IntPtr.Zero) { @@ -525,7 +526,7 @@ public static bool ExtendClientAreaIntoTitleBar(IntPtr hWnd) // #1 Remove titlebar elements var wtaOptions = new UxTheme.WTA_OPTIONS() { - dwFlags = (UxTheme.WTNCA.NODRAWCAPTION | UxTheme.WTNCA.NODRAWICON | UxTheme.WTNCA.NOSYSMENU), + dwFlags = UxTheme.WTNCA.NODRAWCAPTION | UxTheme.WTNCA.NODRAWICON | UxTheme.WTNCA.NOSYSMENU, dwMask = UxTheme.WTNCA.VALIDBITS }; diff --git a/src/Wpf.Ui/Interop/UnsafeReflection.cs b/src/Wpf.Ui/Interop/UnsafeReflection.cs index 738f444ea..e1fd4b64c 100644 --- a/src/Wpf.Ui/Interop/UnsafeReflection.cs +++ b/src/Wpf.Ui/Interop/UnsafeReflection.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/User32.cs b/src/Wpf.Ui/Interop/User32.cs index 41b7ad651..e6b604363 100644 --- a/src/Wpf.Ui/Interop/User32.cs +++ b/src/Wpf.Ui/Interop/User32.cs @@ -2,28 +2,29 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. - +// - // NOTE // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods + using System.Runtime.InteropServices; -// ReSharper disable InconsistentNaming namespace Wpf.Ui.Interop; -/// -/// USER procedure declarations, constant definitions and macros. -/// // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter #pragma warning disable SA1401 // Fields should be private + +/// +/// USER procedure declarations, constant definitions and macros. +/// internal static class User32 { /// @@ -563,7 +564,7 @@ public enum WM /// This is the hard-coded message value used by WinForms for Shell_NotifyIcon. /// It's relatively safe to reuse. /// - TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024 + TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024 APP = 0x8000, } @@ -636,8 +637,8 @@ public enum WS_EX : long LAYOUTRTL = 0x00400000, // Right to left mirroring COMPOSITED = 0x02000000, NOACTIVATE = 0x08000000, - OVERLAPPEDWINDOW = (WINDOWEDGE | CLIENTEDGE), - PALETTEWINDOW = (WINDOWEDGE | TOOLWINDOW | TOPMOST), + OVERLAPPEDWINDOW = WINDOWEDGE | CLIENTEDGE, + PALETTEWINDOW = WINDOWEDGE | TOOLWINDOW | TOPMOST, } /// @@ -911,7 +912,7 @@ public static extern bool ChangeWindowMessageFilterEx( /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -929,7 +930,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -946,7 +947,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure is to receive the message. /// The message to be posted. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// If the function succeeds, the return value is nonzero. [DllImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] @@ -963,7 +964,7 @@ [In] IntPtr lParam /// A handle to the window whose window procedure will receive the message. /// The message to be sent. /// Additional message-specific information. - /// Additional message-specific information. + /// Additional message-specific information.~ /// The return value specifies the result of the message processing; it depends on the message sent. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern int SendMessage( @@ -1098,7 +1099,7 @@ public static IntPtr CreateWindowEx( /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Unicode)] public static extern IntPtr DefWindowProcW( @@ -1116,7 +1117,7 @@ [In] IntPtr lParam /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern IntPtr DefWindowProcA( @@ -1133,7 +1134,7 @@ [In] IntPtr lParam /// A handle to the window procedure that received the message. /// The message. /// Additional message information. The content of this parameter depends on the value of the Msg parameter. - /// Additional message information. The content of this parameter depends on the value of the Msg parameter. + /// Additional message information. The content of this parameter depends on the value of the Msg parameter.~ /// The return value is the result of the message processing and depends on the message. [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern IntPtr DefWindowProc( @@ -1146,7 +1147,7 @@ [In] IntPtr lParam /// /// Retrieves information about the specified window. The function also retrieves the 32-bit (DWORD) value at the specified offset into the extra window memory. /// If you are retrieving a pointer or a handle, this function has been superseded by the function. - /// Unicode declaration for + /// Unicode declaration for /// /// A handle to the window and, indirectly, the class to which the window belongs. /// The zero-based offset to the value to be retrieved. @@ -1157,7 +1158,7 @@ [In] IntPtr lParam /// /// Retrieves information about the specified window. The function also retrieves the 32-bit (DWORD) value at the specified offset into the extra window memory. /// If you are retrieving a pointer or a handle, this function has been superseded by the function. - /// ANSI declaration for + /// ANSI declaration for /// /// A handle to the window and, indirectly, the class to which the window belongs. /// The zero-based offset to the value to be retrieved. @@ -1592,6 +1593,7 @@ public static extern int GetWindowCompositionAttribute( [DllImport(Libraries.User32, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)] public static extern uint GetDpiForWindow([In] HandleRef hwnd); } + #pragma warning restore SA1300 // Element should begin with upper-case letter #pragma warning restore SA1307 // Accessible fields should begin with upper-case letter #pragma warning restore SA1401 // Fields should be private diff --git a/src/Wpf.Ui/Interop/UxTheme.cs b/src/Wpf.Ui/Interop/UxTheme.cs index f554a3318..6b91f294b 100644 --- a/src/Wpf.Ui/Interop/UxTheme.cs +++ b/src/Wpf.Ui/Interop/UxTheme.cs @@ -19,6 +19,8 @@ namespace Wpf.Ui.Interop; // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + internal static class UxTheme { /// @@ -170,3 +172,5 @@ public static extern int GetCurrentThemeName( [In] int cchMaxSizeChars ); } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter diff --git a/src/Wpf.Ui/Interop/WinDef/POINT.cs b/src/Wpf.Ui/Interop/WinDef/POINT.cs index 5fee3ab03..332d209e1 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINT.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINT.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -11,11 +11,13 @@ namespace Wpf.Ui.Interop.WinDef; +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + /// /// The POINT structure defines the x- and y-coordinates of a point. /// [StructLayout(LayoutKind.Sequential)] -// ReSharper disable InconsistentNaming public struct POINT { /// @@ -28,3 +30,5 @@ public struct POINT /// public int y; } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter diff --git a/src/Wpf.Ui/Interop/WinDef/POINTL.cs b/src/Wpf.Ui/Interop/WinDef/POINTL.cs index 191e2e7ca..48dd894df 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINTL.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -11,11 +11,13 @@ namespace Wpf.Ui.Interop.WinDef; +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + /// /// The structure defines the x- and y-coordinates of a point. /// [StructLayout(LayoutKind.Sequential)] -// ReSharper disable InconsistentNaming public struct POINTL { /// @@ -28,3 +30,5 @@ public struct POINTL /// public long y; } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter \ No newline at end of file diff --git a/src/Wpf.Ui/Interop/WinDef/RECT.cs b/src/Wpf.Ui/Interop/WinDef/RECT.cs index 616c4acf9..6b0f0392c 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECT.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECT.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -11,11 +11,12 @@ namespace Wpf.Ui.Interop.WinDef; +// ReSharper disable InconsistentNaming + /// /// The RECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners. /// [StructLayout(LayoutKind.Sequential)] -// ReSharper disable InconsistentNaming public struct RECT { private int _left; @@ -24,59 +25,59 @@ public struct RECT private int _bottom; /// - /// Specifies the x-coordinate of the upper-left corner of the rectangle. + /// Gets or sets the x-coordinate of the upper-left corner of the rectangle. /// public int Left { - get { return _left; } + readonly get { return _left; } set { _left = value; } } /// - /// Specifies the x-coordinate of the lower-right corner of the rectangle. + /// Gets or sets the x-coordinate of the lower-right corner of the rectangle. /// public int Right { - get { return _right; } + readonly get { return _right; } set { _right = value; } } /// - /// Specifies the y-coordinate of the upper-left corner of the rectangle. + /// Gets or sets the y-coordinate of the upper-left corner of the rectangle. /// public int Top { - get { return _top; } + readonly get { return _top; } set { _top = value; } } /// - /// Specifies the y-coordinate of the lower-right corner of the rectangle. + /// Gets or sets the y-coordinate of the lower-right corner of the rectangle. /// public int Bottom { - get { return _bottom; } + readonly get { return _bottom; } set { _bottom = value; } } /// - /// Specifies the width of the rectangle. + /// Gets the width of the rectangle. /// - public int Width + public readonly int Width { get { return _right - _left; } } /// - /// Specifies the height of the rectangle. + /// Gets the height of the rectangle. /// - public int Height + public readonly int Height { get { return _bottom - _top; } } /// - /// Specifies the position of the rectangle. + /// Gets the position of the rectangle. /// public POINT Position { @@ -84,7 +85,7 @@ public POINT Position } /// - /// Specifies the size of the rectangle. + /// Gets the size of the rectangle. /// public SIZE Size { @@ -117,10 +118,12 @@ public static RECT Union(RECT rect1, RECT rect2) } /// - public override bool Equals(object? obj) + public override readonly bool Equals(object? obj) { if (obj is not RECT) + { return false; + } try { diff --git a/src/Wpf.Ui/Interop/WinDef/RECTL.cs b/src/Wpf.Ui/Interop/WinDef/RECTL.cs index 814d685d2..0f0bf29c7 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECTL.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -11,11 +11,12 @@ namespace Wpf.Ui.Interop.WinDef; +// ReSharper disable InconsistentNaming + /// /// The RECTL structure defines a rectangle by the coordinates of its upper-left and lower-right corners. /// [StructLayout(LayoutKind.Sequential)] -// ReSharper disable InconsistentNaming public struct RECTL { private long _left; @@ -24,59 +25,59 @@ public struct RECTL private long _bottom; /// - /// Specifies the x-coordinate of the upper-left corner of the rectangle. + /// Gets or sets the x-coordinate of the upper-left corner of the rectangle. /// public long Left { - get { return _left; } + readonly get { return _left; } set { _left = value; } } /// - /// Specifies the x-coordinate of the lower-right corner of the rectangle. + /// Gets or sets the x-coordinate of the lower-right corner of the rectangle. /// public long Right { - get { return _right; } + readonly get { return _right; } set { _right = value; } } /// - /// Specifies the y-coordinate of the upper-left corner of the rectangle. + /// Gets or sets the y-coordinate of the upper-left corner of the rectangle. /// public long Top { - get { return _top; } + readonly get { return _top; } set { _top = value; } } /// - /// Specifies the y-coordinate of the lower-right corner of the rectangle. + /// Gets or sets the y-coordinate of the lower-right corner of the rectangle. /// public long Bottom { - get { return _bottom; } + readonly get { return _bottom; } set { _bottom = value; } } /// - /// Specifies the width of the rectangle. + /// Gets the width of the rectangle. /// - public long Width + public readonly long Width { get { return _right - _left; } } /// - /// Specifies the height of the rectangle. + /// Gets the height of the rectangle. /// - public long Height + public readonly long Height { get { return _bottom - _top; } } /// - /// Specifies the position of the rectangle. + /// Gets the position of the rectangle. /// public POINTL Position { @@ -84,7 +85,7 @@ public POINTL Position } /// - /// Specifies the size of the rectangle. + /// Gets the size of the rectangle. /// public SIZE Size { @@ -117,10 +118,12 @@ public static RECTL Union(RECTL rect1, RECTL rect2) } /// - public override bool Equals(object? obj) + public override readonly bool Equals(object? obj) { if (obj is not RECTL) + { return false; + } try { diff --git a/src/Wpf.Ui/Interop/WinDef/SIZE.cs b/src/Wpf.Ui/Interop/WinDef/SIZE.cs index 1e3690757..a3e8f5bc0 100644 --- a/src/Wpf.Ui/Interop/WinDef/SIZE.cs +++ b/src/Wpf.Ui/Interop/WinDef/SIZE.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// - // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -11,11 +11,13 @@ namespace Wpf.Ui.Interop.WinDef; +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + /// /// The SIZE structure defines the width and height of a rectangle. /// [StructLayout(LayoutKind.Sequential)] -// ReSharper disable InconsistentNaming public struct SIZE { /// @@ -28,3 +30,5 @@ public struct SIZE /// public long cy; } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter From 569bd709ba4f303ad207ff0073b45f62286db9fb Mon Sep 17 00:00:00 2001 From: koal44 Date: Sat, 30 Mar 2024 23:10:02 -0700 Subject: [PATCH 16/33] Continue cleaning up warnings in Wpf.Ui --- .../Animations/TransitionAnimationProvider.cs | 26 ++----- .../Appearance/ApplicationThemeManager.cs | 23 ++---- src/Wpf.Ui/Controls/Anchor/Anchor.cs | 2 +- .../Controls/AutoSuggestBox/AutoSuggestBox.cs | 9 ++- .../AutoSuggestBoxTextChangedEventArgs.cs | 1 + src/Wpf.Ui/Controls/Badge/Badge.cs | 2 +- .../Controls/BreadcrumbBar/BreadcrumbBar.cs | 2 +- .../BreadcrumbBar/BreadcrumbBarItem.cs | 3 +- .../BreadcrumbBarItemClickedEventArgs.cs | 2 +- src/Wpf.Ui/Controls/Button/Button.cs | 1 - src/Wpf.Ui/Controls/CardAction/CardAction.cs | 2 - .../Controls/CardControl/CardControl.cs | 2 - .../Controls/CardExpander/CardExpander.cs | 2 - .../ClientAreaBorder/ClientAreaBorder.cs | 44 +++++------- .../Controls/ContentDialog/ContentDialog.cs | 6 +- .../ContentDialog/ContentDialogEventArgs.cs | 32 --------- .../ContentDialogButtonClickEventArgs.cs | 15 ++++ .../EventArgs/ContentDialogClosedEventArgs.cs | 15 ++++ .../ContentDialogClosingEventArgs.cs | 17 +++++ .../Controls/ContextMenu/ContextMenu.xaml.cs | 70 +++++++++---------- src/Wpf.Ui/Controls/DataGrid/DataGrid.cs | 2 + src/Wpf.Ui/Controls/DateTimeHelper.cs | 22 +++--- .../DynamicScrollBar/DynamicScrollBar.cs | 4 +- src/Wpf.Ui/Controls/EventIdentifier.cs | 2 +- .../{IThemeElement.cs => IThemeControl.cs} | 2 +- src/Wpf.Ui/Controls/IconElement/ImageIcon.cs | 2 +- .../Controls/IconSource/FontIconSource.cs | 2 +- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs | 2 - src/Wpf.Ui/Controls/InfoBar/InfoBar.cs | 38 ++++------ src/Wpf.Ui/Controls/ItemRange.cs | 12 ++-- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 2 +- .../Controls/NavigationView/INavigableView.cs | 3 +- .../NavigationView/INavigationView.cs | 21 +++--- .../NavigationView/INavigationViewItem.cs | 20 +++--- .../NavigationView/NavigatedEventArgs.cs | 18 +++++ ...ntArgs.cs => NavigatingCancelEventArgs.cs} | 11 +-- .../NavigationView/NavigationCache.cs | 4 +- .../NavigationView/NavigationCacheMode.cs | 2 +- .../NavigationView.AttachedProperties.cs | 14 +++- .../NavigationView/NavigationView.Base.cs | 17 ++--- .../NavigationView/NavigationView.Events.cs | 37 +++------- .../NavigationView.Navigation.cs | 5 +- .../NavigationView/NavigationView.Parent.cs | 25 +++---- .../NavigationView.Properties.cs | 14 ++-- .../NavigationView.TemplateParts.cs | 26 +++---- .../NavigationViewBackButtonVisible.cs | 2 +- .../NavigationViewBreadcrumbItem.cs | 3 +- .../NavigationViewContentPresenter.cs | 1 + .../NavigationView/NavigationViewItem.cs | 2 +- .../NavigationViewItemHeader.cs | 4 +- .../NavigationViewItemSeparator.cs | 2 +- .../NavigationViewPaneDisplayMode.cs | 2 +- .../Controls/NumberBox/INumberFormatter.cs | 8 +-- .../Controls/NumberBox/INumberParser.cs | 2 +- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 11 +-- .../NumberBoxSpinButtonPlacementMode.cs | 2 +- .../NumberBox/NumberBoxValidationMode.cs | 2 +- .../NumberBox/ValidateNumberFormatter.cs | 2 +- .../Controls/PasswordBox/PasswordBox.cs | 10 +-- .../Controls/ProgressRing/ProgressRing.cs | 1 + .../Controls/RichTextBox/RichTextBox.cs | 2 +- src/Wpf.Ui/Controls/ScrollDirection.cs | 3 +- src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 6 +- .../Controls/Snackbar/SnackbarPresenter.cs | 4 +- src/Wpf.Ui/Controls/SpacingMode.cs | 2 +- .../Controls/SplitButton/SplitButton.cs | 8 ++- src/Wpf.Ui/Controls/TextBlock/TextBlock.cs | 13 ++-- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 16 ++--- .../Controls/TitleBar/TitleBarButton.cs | 25 ++++--- .../Controls/ToggleSwitch/ToggleSwitch.cs | 4 -- src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs | 12 ++-- .../Controls/TreeGrid/TreeGridHeader.cs | 26 +++---- src/Wpf.Ui/Controls/TypedEventHandler.cs | 1 + .../VirtualizingGridView.cs | 3 +- .../VirtualizingItemsControl.cs | 2 +- .../VirtualizingUniformGrid.cs | 3 +- .../VirtualizingPanelBase.cs | 8 +-- .../VirtualizingWrapPanel.cs | 7 +- src/Wpf.Ui/Controls/Window/WindowBackdrop.cs | 61 ++++++---------- ...ckButtonVisibilityToVisibilityConverter.cs | 18 ++--- .../Converters/FallbackBrushConverter.cs | 24 ++----- .../Converters/ProgressThicknessConverter.cs | 4 +- src/Wpf.Ui/Extensions/ColorExtensions.cs | 70 +++++++++---------- .../Extensions/ContextMenuExtensions.cs | 16 ++--- src/Wpf.Ui/Extensions/UiElementExtensions.cs | 2 +- src/Wpf.Ui/Extensions/UriExtensions.cs | 6 +- src/Wpf.Ui/Hardware/DisplayDpi.cs | 8 +-- src/Wpf.Ui/Hardware/DpiHelper.cs | 4 +- src/Wpf.Ui/Input/IRelayCommand.cs | 2 +- src/Wpf.Ui/Input/IRelayCommand{T}.cs | 2 +- src/Wpf.Ui/Input/RelayCommand{T}.cs | 4 +- src/Wpf.Ui/Interop/Dwmapi.cs | 6 +- src/Wpf.Ui/Interop/Kernel32.cs | 4 +- src/Wpf.Ui/Interop/ShObjIdl.cs | 4 +- src/Wpf.Ui/Interop/Shell32.cs | 6 +- src/Wpf.Ui/Interop/UnsafeNativeMethods.cs | 2 +- src/Wpf.Ui/Interop/UnsafeReflection.cs | 2 +- src/Wpf.Ui/Interop/User32.cs | 6 +- src/Wpf.Ui/Interop/UxTheme.cs | 4 +- src/Wpf.Ui/Interop/WinDef/POINT.cs | 2 +- src/Wpf.Ui/Interop/WinDef/POINTL.cs | 2 +- src/Wpf.Ui/Interop/WinDef/RECT.cs | 2 +- src/Wpf.Ui/Interop/WinDef/RECTL.cs | 2 +- src/Wpf.Ui/Interop/WinDef/SIZE.cs | 2 +- src/Wpf.Ui/Markup/Design.cs | 61 +++++++--------- src/Wpf.Ui/Properties/AssemblyInfo.cs | 1 - .../SimpleContentDialogCreateOptions.cs | 8 +-- src/Wpf.Ui/ThemeService.cs | 2 +- src/Wpf.Ui/UiApplication.cs | 2 +- src/Wpf.Ui/Win32/Utilities.cs | 15 ++-- tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs | 11 ++- .../Extensions/SymbolExtensionsTests.cs | 4 +- 112 files changed, 546 insertions(+), 605 deletions(-) delete mode 100644 src/Wpf.Ui/Controls/ContentDialog/ContentDialogEventArgs.cs create mode 100644 src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogButtonClickEventArgs.cs create mode 100644 src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosedEventArgs.cs create mode 100644 src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosingEventArgs.cs rename src/Wpf.Ui/Controls/{IThemeElement.cs => IThemeControl.cs} (92%) create mode 100644 src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs rename src/Wpf.Ui/Controls/NavigationView/{NavigationViewEventArgs.cs => NavigatingCancelEventArgs.cs} (76%) diff --git a/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs b/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs index abbcfe58c..2ab58c2dc 100644 --- a/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs +++ b/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs @@ -29,31 +29,15 @@ public static class TransitionAnimationProvider /// Returns if the transition was applied. Otherwise . public static bool ApplyTransition(object element, Transition type, int duration) { - if (type == Transition.None) + if (type == Transition.None + || !HardwareAcceleration.IsSupported(RenderingTier.PartialAcceleration) + || element is not UIElement uiElement + || duration < 10) { return false; } - // Disable transitions for non-accelerated devices. - if (!HardwareAcceleration.IsSupported(RenderingTier.PartialAcceleration)) - { - return false; - } - - if (element is not UIElement uiElement) - { - return false; - } - - if (duration < 10) - { - return false; - } - - if (duration > 10000) - { - duration = 10000; - } + duration = duration > 10000 ? 10000 : duration; var timespanDuration = new Duration(TimeSpan.FromMilliseconds(duration)); diff --git a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs index 539c5210d..9bd5d2328 100644 --- a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs +++ b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs @@ -94,23 +94,14 @@ public static void Apply( themeDictionaryName = "Dark"; break; case ApplicationTheme.HighContrast: - switch (ApplicationThemeManager.GetSystemTheme()) + themeDictionaryName = ApplicationThemeManager.GetSystemTheme() switch { - case SystemTheme.HC1: - themeDictionaryName = "HC1"; - break; - case SystemTheme.HC2: - themeDictionaryName = "HC2"; - break; - case SystemTheme.HCBlack: - themeDictionaryName = "HCBlack"; - break; - case SystemTheme.HCWhite: - default: - themeDictionaryName = "HCWhite"; - break; - } - + SystemTheme.HC1 => "HC1", + SystemTheme.HC2 => "HC2", + SystemTheme.HCBlack => "HCBlack", + SystemTheme.HCWhite => "HCBlack", + _ => "HCWhite", + }; break; } diff --git a/src/Wpf.Ui/Controls/Anchor/Anchor.cs b/src/Wpf.Ui/Controls/Anchor/Anchor.cs index 0e88c29cc..032009df4 100644 --- a/src/Wpf.Ui/Controls/Anchor/Anchor.cs +++ b/src/Wpf.Ui/Controls/Anchor/Anchor.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/anchor // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 4c394f50f..d478e4a2c 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -225,9 +225,12 @@ public event TypedEventHandler RemoveHandler(TextChangedEvent, value); } - protected TextBox? TextBox = null; - protected Popup SuggestionsPopup = null!; - protected ListView? SuggestionsList = null!; + protected TextBox? TextBox { get; set; } = null; + + protected Popup SuggestionsPopup { get; set; } = null!; + + protected ListView? SuggestionsList { get; set; } = null!; + private bool _changingTextAfterSuggestionChosen; private bool _isChangedTextOutSideOfTextBox; private object? _selectedItem; diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBoxTextChangedEventArgs.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBoxTextChangedEventArgs.cs index 0aa4cfae9..87d82a490 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBoxTextChangedEventArgs.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBoxTextChangedEventArgs.cs @@ -15,5 +15,6 @@ public AutoSuggestBoxTextChangedEventArgs(RoutedEvent eventArgs, object sender) : base(eventArgs, sender) { } public required string Text { get; init; } + public required AutoSuggestionBoxTextChangeReason Reason { get; init; } } diff --git a/src/Wpf.Ui/Controls/Badge/Badge.cs b/src/Wpf.Ui/Controls/Badge/Badge.cs index 2106341f9..cebd04cdb 100644 --- a/src/Wpf.Ui/Controls/Badge/Badge.cs +++ b/src/Wpf.Ui/Controls/Badge/Badge.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/badge // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index 8de2c32d3..9e1e4739e 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index 8ca69ce7b..ea6d82561 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -2,8 +2,9 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library + using Wpf.Ui.Converters; // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs index f680d12c4..ba3efbb22 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index 7b80f077a..fd14c98fa 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -4,7 +4,6 @@ // All Rights Reserved. using System.Windows.Controls; -using Wpf.Ui.Converters; // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/CardAction/CardAction.cs b/src/Wpf.Ui/Controls/CardAction/CardAction.cs index 7c6ae7dcc..dc73e9189 100644 --- a/src/Wpf.Ui/Controls/CardAction/CardAction.cs +++ b/src/Wpf.Ui/Controls/CardAction/CardAction.cs @@ -3,8 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using Wpf.Ui.Converters; - // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/CardControl/CardControl.cs b/src/Wpf.Ui/Controls/CardControl/CardControl.cs index 27cf026d5..9d1a06a64 100644 --- a/src/Wpf.Ui/Controls/CardControl/CardControl.cs +++ b/src/Wpf.Ui/Controls/CardControl/CardControl.cs @@ -3,8 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System.ComponentModel; -using System.Windows; using System.Windows.Automation.Peers; using Wpf.Ui.AutomationPeers; diff --git a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs index 0e4870b15..d4c64c246 100644 --- a/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs +++ b/src/Wpf.Ui/Controls/CardExpander/CardExpander.cs @@ -3,8 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using Wpf.Ui.Converters; - // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs b/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs index 39c419cbf..0828b8ebc 100644 --- a/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs +++ b/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs @@ -43,26 +43,19 @@ namespace Wpf.Ui.Controls; /// public class ClientAreaBorder : System.Windows.Controls.Border, IThemeControl { - private bool _borderBrushApplied = false; - - private const int SM_CXFRAME = 32; - + /*private const int SM_CXFRAME = 32; private const int SM_CYFRAME = 33; - - private const int SM_CXPADDEDBORDER = 92; - - private System.Windows.Window? _oldWindow; - + private const int SM_CXPADDEDBORDER = 92;*/ private static Thickness? _paddedBorderThickness; - private static Thickness? _resizeFrameBorderThickness; - private static Thickness? _windowChromeNonClientFrameThickness; + private bool _borderBrushApplied = false; + private System.Windows.Window? _oldWindow; public ApplicationTheme ApplicationTheme { get; set; } = ApplicationTheme.Unknown; /// - /// Get the system value in WPF units. + /// Gets the system value in WPF units. /// public Thickness PaddedBorderThickness { @@ -92,7 +85,7 @@ public Thickness PaddedBorderThickness } /// - /// Get the system and values in WPF units. + /// Gets the system and values in WPF units. /// public Thickness ResizeFrameBorderThickness => _resizeFrameBorderThickness ??= new Thickness( @@ -103,10 +96,13 @@ public Thickness PaddedBorderThickness ); /// + /// Gets the thickness of the window's non-client frame used for maximizing the window with a custom chrome. + /// + /// /// If you use a to extend the client area of a window to the non-client area, you need to handle the edge margin issue when the window is maximized. /// Use this property to get the correct margin value when the window is maximized, so that when the window is maximized, the client area can completely cover the screen client area by no less than a single pixel at any DPI. /// The method cannot obtain this value directly. - /// + /// public Thickness WindowChromeNonClientFrameThickness => _windowChromeNonClientFrameThickness ??= new Thickness( ResizeFrameBorderThickness.Left + PaddedBorderThickness.Left, @@ -174,11 +170,8 @@ private void OnWindowStateChanged(object? sender, EventArgs e) return; } - Padding = window.WindowState switch - { - WindowState.Maximized => WindowChromeNonClientFrameThickness, - _ => default, - }; + var padding = window.WindowState == WindowState.Maximized ? WindowChromeNonClientFrameThickness : default; + SetCurrentValue(PaddingProperty, padding); } private void ApplyDefaultWindowBorder() @@ -191,15 +184,14 @@ private void ApplyDefaultWindowBorder() _borderBrushApplied = true; // SystemParameters.WindowGlassBrush - _oldWindow.BorderThickness = new Thickness(1); - _oldWindow.BorderBrush = new SolidColorBrush( - ApplicationTheme == ApplicationTheme.Light - ? Color.FromArgb(0xFF, 0x7A, 0x7A, 0x7A) - : Color.FromArgb(0xFF, 0x3A, 0x3A, 0x3A) - ); + var borderColor = ApplicationTheme == ApplicationTheme.Light + ? Color.FromArgb(0xFF, 0x7A, 0x7A, 0x7A) + : Color.FromArgb(0xFF, 0x3A, 0x3A, 0x3A); + _oldWindow.SetCurrentValue(System.Windows.Controls.Control.BorderBrushProperty, new SolidColorBrush(borderColor)); + _oldWindow.SetCurrentValue(System.Windows.Controls.Control.BorderThicknessProperty, new Thickness(1)); } - private (double factorX, double factorY) GetDpi() + private (double FactorX, double FactorY) GetDpi() { if (PresentationSource.FromVisual(this) is { } source) { diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 3758aa8b7..2bebf9dbd 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -543,7 +543,7 @@ public async Task ShowAsync(CancellationToken cancellationT /// public virtual void Hide(ContentDialogResult result = ContentDialogResult.None) { - ContentDialogClosingEventArgs closingEventArgs = new ContentDialogClosingEventArgs(ClosingEvent, this) + var closingEventArgs = new ContentDialogClosingEventArgs(ClosingEvent, this) { Result = result }; @@ -561,7 +561,7 @@ public virtual void Hide(ContentDialogResult result = ContentDialogResult.None) /// protected virtual void OnClosed(ContentDialogResult result) { - ContentDialogClosedEventArgs closedEventArgs = new ContentDialogClosedEventArgs(ClosedEvent, this) + var closedEventArgs = new ContentDialogClosedEventArgs(ClosedEvent, this) { Result = result }; @@ -575,7 +575,7 @@ protected virtual void OnClosed(ContentDialogResult result) /// The button that was clicked. protected virtual void OnButtonClick(ContentDialogButton button) { - ContentDialogButtonClickEventArgs buttonClickEventArgs = new ContentDialogButtonClickEventArgs( + var buttonClickEventArgs = new ContentDialogButtonClickEventArgs( ButtonClickedEvent, this ) diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialogEventArgs.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialogEventArgs.cs deleted file mode 100644 index e58903c99..000000000 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialogEventArgs.cs +++ /dev/null @@ -1,32 +0,0 @@ -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. -// Copyright (C) Leszek Pomianowski and WPF UI Contributors. -// All Rights Reserved. - -// ReSharper disable once CheckNamespace -namespace Wpf.Ui.Controls; - -public class ContentDialogClosingEventArgs : RoutedEventArgs -{ - public ContentDialogClosingEventArgs(RoutedEvent routedEvent, object source) - : base(routedEvent, source) { } - - public required ContentDialogResult Result { get; init; } - public bool Cancel { get; set; } -} - -public class ContentDialogClosedEventArgs : RoutedEventArgs -{ - public ContentDialogClosedEventArgs(RoutedEvent routedEvent, object source) - : base(routedEvent, source) { } - - public required ContentDialogResult Result { get; init; } -} - -public class ContentDialogButtonClickEventArgs : RoutedEventArgs -{ - public ContentDialogButtonClickEventArgs(RoutedEvent routedEvent, object source) - : base(routedEvent, source) { } - - public required ContentDialogButton Button { get; init; } -} diff --git a/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogButtonClickEventArgs.cs b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogButtonClickEventArgs.cs new file mode 100644 index 000000000..9372921d3 --- /dev/null +++ b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogButtonClickEventArgs.cs @@ -0,0 +1,15 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +public class ContentDialogButtonClickEventArgs : RoutedEventArgs +{ + public ContentDialogButtonClickEventArgs(RoutedEvent routedEvent, object source) + : base(routedEvent, source) { } + + public required ContentDialogButton Button { get; init; } +} diff --git a/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosedEventArgs.cs b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosedEventArgs.cs new file mode 100644 index 000000000..88cb3f243 --- /dev/null +++ b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosedEventArgs.cs @@ -0,0 +1,15 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +public class ContentDialogClosedEventArgs : RoutedEventArgs +{ + public ContentDialogClosedEventArgs(RoutedEvent routedEvent, object source) + : base(routedEvent, source) { } + + public required ContentDialogResult Result { get; init; } +} diff --git a/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosingEventArgs.cs b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosingEventArgs.cs new file mode 100644 index 000000000..7ab462f0a --- /dev/null +++ b/src/Wpf.Ui/Controls/ContentDialog/EventArgs/ContentDialogClosingEventArgs.cs @@ -0,0 +1,17 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +public class ContentDialogClosingEventArgs : RoutedEventArgs +{ + public ContentDialogClosingEventArgs(RoutedEvent routedEvent, object source) + : base(routedEvent, source) { } + + public required ContentDialogResult Result { get; init; } + + public bool Cancel { get; set; } +} diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs index 54ac88c50..85a38feb5 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs @@ -1,53 +1,53 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// This Code is based on a StackOverflow-Answer: https://stackoverflow.com/a/56736232/9759874 -using System; using System.Reflection; -using System.Windows; using System.Windows.Threading; -namespace Wpf.Ui.Styles.Controls +namespace Wpf.Ui.Styles.Controls; + +/// +/// Overwrites ContextMenu-Style for some UIElements (like RichTextBox) that don't take the default ContextMenu-Style by default. +/// The code inside this CodeBehind-Class forces this ContextMenu-Style on these UIElements through Reflection (because it is only accessible through Reflection it is also only possible through CodeBehind and not XAML) +/// +public partial class ContextMenu : ResourceDictionary { /// - /// Overwrites ContextMenu-Style for some UIElements (like RichTextBox) that don't take the default ContextMenu-Style by default. - /// The code inside this CodeBehind-Class forces this ContextMenu-Style on these UIElements through Reflection (because it is only accessible through Reflection it is also only possible through CodeBehind and not XAML) + /// Initializes a new instance of the class and registers editing styles with . /// - // This Code is based on a StackOverflow-Answer: https://stackoverflow.com/a/56736232/9759874 - partial class ContextMenu : ResourceDictionary + public ContextMenu() { - /// - /// Registers editing styles with . - /// - public ContextMenu() - { - // Run OnResourceDictionaryLoaded asynchronously to ensure other ResourceDictionary are already loaded before adding new entries - Dispatcher.CurrentDispatcher.BeginInvoke( - DispatcherPriority.Normal, - new Action(OnResourceDictionaryLoaded) - ); - } - - private void OnResourceDictionaryLoaded() - { - var currentAssembly = typeof(Application).Assembly; + // Run OnResourceDictionaryLoaded asynchronously to ensure other ResourceDictionary are already loaded before adding new entries + Dispatcher.CurrentDispatcher.BeginInvoke( + DispatcherPriority.Normal, + new Action(OnResourceDictionaryLoaded) + ); + } - AddEditorContextMenuDefaultStyle(currentAssembly); - } + private void OnResourceDictionaryLoaded() + { + var currentAssembly = typeof(Application).Assembly; - private void AddEditorContextMenuDefaultStyle(Assembly currentAssembly) - { - var contextMenuStyle = this["UiContextMenu"] as Style; - var editorContextMenuType = Type.GetType( - "System.Windows.Documents.TextEditorContextMenu+EditorContextMenu, " + currentAssembly - ); + AddEditorContextMenuDefaultStyle(currentAssembly); + } - if (editorContextMenuType == null || contextMenuStyle == null) - return; + private void AddEditorContextMenuDefaultStyle(Assembly currentAssembly) + { + var editorContextMenuType = Type.GetType( + "System.Windows.Documents.TextEditorContextMenu+EditorContextMenu, " + currentAssembly + ); - var editorContextMenuStyle = new Style(editorContextMenuType, contextMenuStyle); - Add(editorContextMenuType, editorContextMenuStyle); + if (editorContextMenuType == null + || this["UiContextMenu"] is not Style contextMenuStyle) + { + return; } + + var editorContextMenuStyle = new Style(editorContextMenuType, contextMenuStyle); + Add(editorContextMenuType, editorContextMenuStyle); } } diff --git a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs index d1b71b040..ab0867e23 100644 --- a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs +++ b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs @@ -14,6 +14,8 @@ namespace Wpf.Ui.Controls; /// A DataGrid control that displays data in rows and columns and allows /// for the entering and editing of data. /// +[StyleTypedProperty(Property = nameof(CheckBoxColumnElementStyle), StyleTargetType = typeof(CheckBox))] +[StyleTypedProperty(Property = nameof(CheckBoxColumnEditingElementStyle), StyleTargetType = typeof(CheckBox))] public class DataGrid : System.Windows.Controls.DataGrid { /// Identifies the dependency property. diff --git a/src/Wpf.Ui/Controls/DateTimeHelper.cs b/src/Wpf.Ui/Controls/DateTimeHelper.cs index 8641af312..87085aaee 100644 --- a/src/Wpf.Ui/Controls/DateTimeHelper.cs +++ b/src/Wpf.Ui/Controls/DateTimeHelper.cs @@ -2,26 +2,28 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// +// NOTE: This date time helper assumes it is working in a Gregorian calendar +// If we ever support non Gregorian calendars this class would need to be redesigned + using System.Diagnostics; using System.Windows.Controls; namespace Wpf.Ui.Controls; -// NOTICE: This date time helper assumes it is working in a Gregorian calendar -// If we ever support non Gregorian calendars this class would need to be redesigned internal static class DateTimeHelper { - private static System.Globalization.Calendar cal = new GregorianCalendar(); + private static readonly System.Globalization.Calendar Cal = new GregorianCalendar(); public static DateTime? AddDays(DateTime time, int days) { try { - return cal.AddDays(time, days); + return Cal.AddDays(time, days); } catch (System.ArgumentException) { @@ -33,7 +35,7 @@ internal static class DateTimeHelper { try { - return cal.AddMonths(time, months); + return Cal.AddMonths(time, months); } catch (System.ArgumentException) { @@ -45,7 +47,7 @@ internal static class DateTimeHelper { try { - return cal.AddYears(time, years); + return Cal.AddYears(time, years); } catch (System.ArgumentException) { @@ -144,16 +146,16 @@ internal static DateTimeFormatInfo GetDateFormat(CultureInfo culture) return dtfi; } - // returns if the date is included in the range + // returns true if the date is included in the range public static bool InRange(DateTime date, CalendarDateRange range) { return InRange(date, range.Start, range.End); } - // returns if the date is included in the range + // returns true if the date is included in the range public static bool InRange(DateTime date, DateTime start, DateTime end) { - Debug.Assert(DateTime.Compare(start, end) < 1); + Debug.Assert(DateTime.Compare(start, end) < 1, "Start date must be less than or equal to the end date."); if (CompareDays(date, start) > -1 && CompareDays(date, end) < 1) { diff --git a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs index 9206fdcfb..bf639b559 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs +++ b/src/Wpf.Ui/Controls/DynamicScrollBar/DynamicScrollBar.cs @@ -13,12 +13,10 @@ namespace Wpf.Ui.Controls; /// public class DynamicScrollBar : System.Windows.Controls.Primitives.ScrollBar { + private readonly EventIdentifier _interactiveIdentifier = new(); private bool _isScrolling = false; - private bool _isInteracted = false; - private readonly EventIdentifier _interactiveIdentifier = new(); - /// Identifies the dependency property. public static readonly DependencyProperty IsScrollingProperty = DependencyProperty.Register( nameof(IsScrolling), diff --git a/src/Wpf.Ui/Controls/EventIdentifier.cs b/src/Wpf.Ui/Controls/EventIdentifier.cs index 94357f1a4..bd74a74a9 100644 --- a/src/Wpf.Ui/Controls/EventIdentifier.cs +++ b/src/Wpf.Ui/Controls/EventIdentifier.cs @@ -14,7 +14,7 @@ namespace Wpf.Ui.Controls; internal class EventIdentifier { /// - /// Current identifier. + /// Gets or sets the current identifier. /// public long Current { get; internal set; } = 0; diff --git a/src/Wpf.Ui/Controls/IThemeElement.cs b/src/Wpf.Ui/Controls/IThemeControl.cs similarity index 92% rename from src/Wpf.Ui/Controls/IThemeElement.cs rename to src/Wpf.Ui/Controls/IThemeControl.cs index 1c6ec5497..8f15dd435 100644 --- a/src/Wpf.Ui/Controls/IThemeElement.cs +++ b/src/Wpf.Ui/Controls/IThemeControl.cs @@ -11,7 +11,7 @@ namespace Wpf.Ui.Controls; public interface IThemeControl { /// - /// The theme is currently set. + /// Gets the theme that is currently set. /// public Appearance.ApplicationTheme ApplicationTheme { get; } } diff --git a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs index bd5201a67..970eeb69f 100644 --- a/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/ImageIcon.cs @@ -32,7 +32,7 @@ public ImageSource? Source set => SetValue(SourceProperty, value); } - protected System.Windows.Controls.Image? Image; + protected System.Windows.Controls.Image? Image { get; set; } protected override UIElement InitializeChildren() { diff --git a/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs b/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs index 923225bd5..74d9d14ff 100644 --- a/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs +++ b/src/Wpf.Ui/Controls/IconSource/FontIconSource.cs @@ -93,7 +93,7 @@ public string Glyph public override IconElement CreateIconElement() { - FontIcon fontIcon = new FontIcon() { Glyph = Glyph }; + var fontIcon = new FontIcon() { Glyph = Glyph }; if (!Equals(FontFamily, SystemFonts.MessageFontFamily)) { diff --git a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs index 62ebf7a7d..70ac3ca09 100644 --- a/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs +++ b/src/Wpf.Ui/Controls/InfoBadge/InfoBadge.cs @@ -3,8 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using Wpf.Ui.Converters; - namespace Wpf.Ui.Controls; public class InfoBadge : System.Windows.Controls.Control diff --git a/src/Wpf.Ui/Controls/InfoBar/InfoBar.cs b/src/Wpf.Ui/Controls/InfoBar/InfoBar.cs index 192c0986c..80de344f4 100644 --- a/src/Wpf.Ui/Controls/InfoBar/InfoBar.cs +++ b/src/Wpf.Ui/Controls/InfoBar/InfoBar.cs @@ -17,9 +17,7 @@ namespace Wpf.Ui.Controls; /// public class InfoBar : System.Windows.Controls.ContentControl { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsClosableProperty = DependencyProperty.Register( nameof(IsClosable), typeof(bool), @@ -27,9 +25,7 @@ public class InfoBar : System.Windows.Controls.ContentControl new PropertyMetadata(true) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register( nameof(IsOpen), typeof(bool), @@ -37,29 +33,23 @@ public class InfoBar : System.Windows.Controls.ContentControl new PropertyMetadata(false) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(string), typeof(InfoBar), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( nameof(Message), typeof(string), typeof(InfoBar), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty SeverityProperty = DependencyProperty.Register( nameof(Severity), typeof(InfoBarSeverity), @@ -67,9 +57,7 @@ public class InfoBar : System.Windows.Controls.ContentControl new PropertyMetadata(InfoBarSeverity.Informational) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), @@ -78,8 +66,7 @@ public class InfoBar : System.Windows.Controls.ContentControl ); /// - /// Gets or sets a value that indicates whether the user can close the - /// . Defaults to true. + /// Gets or sets a value indicating whether the user can close the . Defaults to true. /// public bool IsClosable { @@ -88,8 +75,7 @@ public bool IsClosable } /// - /// Gets or sets a value that indicates whether the - /// is open. + /// Gets or sets a value indicating whether the is open. /// public bool IsOpen { @@ -132,7 +118,9 @@ public InfoBarSeverity Severity /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); - /// + /// + /// Initializes a new instance of the class. + /// public InfoBar() { SetValue( diff --git a/src/Wpf.Ui/Controls/ItemRange.cs b/src/Wpf.Ui/Controls/ItemRange.cs index 9c8f29b74..5325586af 100644 --- a/src/Wpf.Ui/Controls/ItemRange.cs +++ b/src/Wpf.Ui/Controls/ItemRange.cs @@ -2,9 +2,10 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel +// // Copyright (C) S. Bäumlisberger // All Rights Reserved. @@ -14,9 +15,10 @@ namespace Wpf.Ui.Controls; /// Items range. /// Based on . /// -public struct ItemRange +public readonly struct ItemRange { public int StartIndex { get; } + public int EndIndex { get; } public ItemRange(int startIndex, int endIndex) @@ -26,8 +28,6 @@ public ItemRange(int startIndex, int endIndex) EndIndex = endIndex; } - public bool Contains(int itemIndex) - { - return itemIndex >= StartIndex && itemIndex <= EndIndex; - } + public readonly bool Contains(int itemIndex) => + itemIndex >= StartIndex && itemIndex <= EndIndex; } diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 0b5582890..da840fed0 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -249,7 +249,7 @@ public MessageBox() }; } - protected TaskCompletionSource? Tcs; + protected TaskCompletionSource? Tcs { get; set; } [Obsolete($"Use {nameof(ShowDialogAsync)} instead")] public new void Show() diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs b/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs index 9cd23d8b7..22671313f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs +++ b/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs @@ -9,10 +9,11 @@ namespace Wpf.Ui.Controls; /// /// A component whose ViewModel is separate from the DataContext and can be navigated by . /// +/// The type of the ViewModel associated with the view. This type optionally may implement to participate in navigation processes. public interface INavigableView { /// - /// ViewModel used by the view. + /// Gets the view model used by the view. /// Optionally, it may implement and be navigated by . /// T ViewModel { get; } diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs b/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs index 3bbf1a417..74d21ccc0 100644 --- a/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs +++ b/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -29,7 +29,7 @@ public interface INavigationView Visibility HeaderVisibility { get; set; } /// - /// Gets or sets a value that indicates whether the header is always visible. + /// Gets or sets a value indicating whether the header is always visible. /// bool AlwaysShowHeader { get; set; } @@ -64,7 +64,7 @@ public interface INavigationView object? ContentOverlay { get; set; } /// - /// Gets a value that indicates whether the back button is enabled or disabled. + /// Gets a value indicating whether the back button is enabled or disabled. /// bool IsBackEnabled { get; } @@ -75,17 +75,17 @@ public interface INavigationView NavigationViewBackButtonVisible IsBackButtonVisible { get; set; } /// - /// Gets or sets a value that indicates whether the toggle button is visible. + /// Gets or sets a value indicating whether the toggle button is visible. /// bool IsPaneToggleVisible { get; set; } /// - /// Gets or sets a value that specifies whether the NavigationView pane is expanded to its full width. + /// Gets or sets a value indicating whether the NavigationView pane is expanded to its full width. /// bool IsPaneOpen { get; set; } /// - /// Gets or sets a value that determines whether the pane is shown. + /// Gets or sets a value indicating whether the pane is shown. /// bool IsPaneVisible { get; set; } @@ -115,7 +115,7 @@ public interface INavigationView object? PaneFooter { get; set; } /// - /// Gets a value that specifies how the pane and content areas of a NavigationView are being shown. + /// Gets or sets a value that specifies how the pane and content areas of a NavigationView are being shown. /// It is not the same PaneDisplayMode as in WinUi. /// NavigationViewPaneDisplayMode PaneDisplayMode { get; set; } @@ -136,7 +136,7 @@ public interface INavigationView BreadcrumbBar? BreadcrumbBar { get; set; } /// - /// Template Property for and . + /// Gets or sets the template property for and . /// ControlTemplate? ItemTemplate { get; set; } @@ -191,7 +191,7 @@ public interface INavigationView event TypedEventHandler Navigated; /// - /// Gets a value that indicates whether there is at least one entry in back navigation history. + /// Gets a value indicating whether there is at least one entry in back navigation history. /// bool CanGoBack { get; } @@ -210,9 +210,6 @@ public interface INavigationView /// /// Synchronously adds an element to the navigation stack and navigates current navigation Frame to the /// - /// - /// - /// bool NavigateWithHierarchy(Type pageType, object? dataContext = null); /// diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs index a9862da19..9ff7e0d3c 100644 --- a/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -18,12 +18,12 @@ namespace Wpf.Ui.Controls; public interface INavigationViewItem { /// - /// Unique identifier that allows the item to be located in the navigation. + /// Gets the unique identifier that allows the item to be located in the navigation. /// string Id { get; } /// - /// Get or sets content + /// Gets or sets the content /// object Content { get; set; } @@ -43,39 +43,39 @@ public interface INavigationViewItem object? MenuItemsSource { get; set; } /// - /// Gets information whether the current element is active. + /// Gets a value indicating whether the current element is active. /// bool IsActive { get; } /// - /// Gets information whether the sub- are expanded. + /// Gets or sets a value indicating whether the sub- are expanded. /// bool IsExpanded { get; internal set; } /// - /// A unique tag used by the parent navigation system for the purpose of searching and navigating. + /// Gets or sets the unique tag used by the parent navigation system for the purpose of searching and navigating. /// string TargetPageTag { get; set; } /// - /// The type of the page to be navigated. (Should be derived from ). + /// Gets or sets the type of the page to be navigated. (Should be derived from ). /// Type? TargetPageType { get; set; } InfoBadge? InfoBadge { get; set; } /// - /// Specifies caching characteristics for a page involved in a navigation. + /// Gets or sets the caching characteristics for a page involved in a navigation. /// NavigationCacheMode NavigationCacheMode { get; set; } /// - /// Template Property + /// Gets or sets the template property /// ControlTemplate? Template { get; set; } /// - /// Gets parent if in collection + /// Gets or sets the parent if it's in collection /// INavigationViewItem? NavigationViewItemParent { get; internal set; } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs b/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs new file mode 100644 index 000000000..ac0a304de --- /dev/null +++ b/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs @@ -0,0 +1,18 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. +// +// Based on Windows UI Library +// Copyright(c) Microsoft Corporation.All rights reserved. + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +public class NavigatedEventArgs : RoutedEventArgs +{ + public NavigatedEventArgs(RoutedEvent routedEvent, object source) + : base(routedEvent, source) { } + + public required object Page { get; init; } +} diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewEventArgs.cs b/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs similarity index 76% rename from src/Wpf.Ui/Controls/NavigationView/NavigationViewEventArgs.cs rename to src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs index 206552414..2db4e2bec 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewEventArgs.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -15,13 +15,6 @@ public NavigatingCancelEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { } public required object Page { get; init; } - public bool Cancel { get; set; } -} - -public class NavigatedEventArgs : RoutedEventArgs -{ - public NavigatedEventArgs(RoutedEvent routedEvent, object source) - : base(routedEvent, source) { } - public required object Page { get; init; } + public bool Cancel { get; set; } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs index a49238c18..1e9507880 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -11,7 +11,7 @@ namespace Wpf.Ui.Controls; internal class NavigationCache { - private IDictionary _entires = new Dictionary(); + private readonly IDictionary _entires = new Dictionary(); public object? Remember(Type? entryType, NavigationCacheMode cacheMode, Func generate) { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs index 2bd38c327..64b0099b5 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.AttachedProperties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.AttachedProperties.cs index bb1c06a8a..361bdfe56 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.AttachedProperties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.AttachedProperties.cs @@ -6,17 +6,27 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines attached properties for . +/// public partial class NavigationView { public static readonly DependencyProperty HeaderContentProperty = DependencyProperty.RegisterAttached( "HeaderContent", typeof(object), - typeof(FrameworkElement), + typeof(NavigationView), new FrameworkPropertyMetadata(null) ); + /// Helper for getting from . + /// to read from. + /// HeaderContent property value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0033:Add [AttachedPropertyBrowsableForType]", Justification = "Don't need to pollute all FE with this attached property")] public static object? GetHeaderContent(FrameworkElement target) => target.GetValue(HeaderContentProperty); - public static void SetHeaderContent(FrameworkElement target, object headerContent) => + /// Helper for setting on . + /// to set on. + /// HeaderContent property value. + public static void SetHeaderContent(FrameworkElement target, object? headerContent) => target.SetValue(HeaderContentProperty, headerContent); } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index 0b853223e..f370c066b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -2,6 +2,8 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationview?view=winrt-22621 using System.Collections; using System.Collections.ObjectModel; @@ -12,8 +14,6 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -// Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationview?view=winrt-22621 - /// /// Represents a container that enables navigation of app content. It has a header, a view for the main content, and a menu pane for navigation commands. /// @@ -55,16 +55,17 @@ public NavigationView() /// public INavigationViewItem? SelectedItem { get; protected set; } - protected Dictionary PageIdOrTargetTagNavigationViewsDictionary = new(); - protected Dictionary PageTypeNavigationViewsDictionary = new(); + protected Dictionary PageIdOrTargetTagNavigationViewsDictionary { get; } = new(); + + protected Dictionary PageTypeNavigationViewsDictionary { get; } = new(); private readonly ObservableCollection _autoSuggestBoxItems = new(); private readonly ObservableCollection _breadcrumbBarItems = new(); - private static readonly Thickness s_titleBarPaneOpenMargin = new(35, 0, 0, 0); - private static readonly Thickness s_titleBarPaneCompactMargin = new(55, 0, 0, 0); - private static readonly Thickness s_autoSuggestBoxMargin = new(8, 8, 8, 16); - private static readonly Thickness s_frameMargin = new(0, 50, 0, 0); + private static readonly Thickness TitleBarPaneOpenMarginDefault = new(35, 0, 0, 0); + private static readonly Thickness TitleBarPaneCompactMarginDefault = new(55, 0, 0, 0); + private static readonly Thickness AutoSuggestBoxMarginDefault = new(8, 8, 8, 16); + private static readonly Thickness FrameMarginDefault = new(0, 50, 0, 0); protected static void UpdateVisualState(NavigationView navigationView) { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs index 5b5b9754d..ba6c0fcfe 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs @@ -2,19 +2,19 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. - // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines events for . +/// public partial class NavigationView { - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent PaneOpenedEvent = EventManager.RegisterRoutedEvent( nameof(PaneOpened), RoutingStrategy.Bubble, @@ -22,9 +22,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent PaneClosedEvent = EventManager.RegisterRoutedEvent( nameof(PaneClosed), RoutingStrategy.Bubble, @@ -32,9 +30,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent SelectionChangedEvent = EventManager.RegisterRoutedEvent( nameof(SelectionChanged), RoutingStrategy.Bubble, @@ -42,9 +38,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent ItemInvokedEvent = EventManager.RegisterRoutedEvent( nameof(ItemInvoked), RoutingStrategy.Bubble, @@ -52,9 +46,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent BackRequestedEvent = EventManager.RegisterRoutedEvent( nameof(BackRequested), RoutingStrategy.Bubble, @@ -62,9 +54,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent NavigatingEvent = EventManager.RegisterRoutedEvent( nameof(Navigating), RoutingStrategy.Bubble, @@ -72,9 +62,7 @@ public partial class NavigationView typeof(NavigationView) ); - /// - /// Property for . - /// + /// Identifies the routed event. public static readonly RoutedEvent NavigatedEvent = EventManager.RegisterRoutedEvent( nameof(Navigated), RoutingStrategy.Bubble, @@ -174,8 +162,6 @@ protected virtual void OnBackRequested() /// /// Raises the navigating requested event. /// - /// - /// protected virtual bool OnNavigating(object sourcePage) { var eventArgs = new NavigatingCancelEventArgs(NavigatingEvent, this) { Page = sourcePage }; @@ -188,7 +174,6 @@ protected virtual bool OnNavigating(object sourcePage) /// /// Raises the navigated requested event. /// - /// protected virtual void OnNavigated(object page) { var eventArgs = new NavigatedEventArgs(NavigatedEvent, this) { Page = page }; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 6e1c8db8c..557a21a7f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -2,6 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// // Based on Windows UI Library using System.Collections.ObjectModel; @@ -15,9 +16,9 @@ namespace Wpf.Ui.Controls; /// public partial class NavigationView { - protected readonly List Journal = new(50); + protected List Journal { get; } = new(50); - protected readonly ObservableCollection NavigationStack = new(); + protected ObservableCollection NavigationStack { get; } = new(); private readonly NavigationCache _cache = new(); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Parent.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Parent.cs index 8daa5a863..7cb9a58ba 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Parent.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Parent.cs @@ -2,25 +2,27 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; +/// +/// Defines xxx for . +/// public partial class NavigationView { /// /// Attached property for 's to get its parent. /// - internal static readonly DependencyProperty NavigationParentProperty = - DependencyProperty.RegisterAttached( - nameof(NavigationParent), - typeof(INavigationView), - typeof(INavigationView), - new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits) - ); + internal static readonly DependencyProperty NavigationParentProperty = DependencyProperty.RegisterAttached( + nameof(NavigationParent), + typeof(INavigationView), + typeof(INavigationView), + new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits) + ); /// /// @@ -39,9 +41,8 @@ internal INavigationView NavigationParent internal static NavigationView? GetNavigationParent(T navigationItem) where T : DependencyObject, INavigationViewItem { - if (navigationItem.GetValue(NavigationParentProperty) is NavigationView navigationView) - return navigationView; - - return null; + return navigationItem.GetValue(NavigationParentProperty) is NavigationView navigationView + ? navigationView + : null; } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index 849e3fdef..b70c78e22 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -570,7 +570,7 @@ private static void OnIsPaneOpenChanged(DependencyObject d, DependencyPropertyCh navigationView.TitleBar?.SetCurrentValue( MarginProperty, - navigationView.IsPaneOpen ? s_titleBarPaneOpenMargin : s_titleBarPaneCompactMargin + navigationView.IsPaneOpen ? TitleBarPaneOpenMarginDefault : TitleBarPaneCompactMarginDefault ); UpdateVisualState(navigationView); @@ -591,7 +591,7 @@ DependencyPropertyChangedEventArgs e navigationView.FrameMargin = new Thickness(0); oldValue.Margin = new Thickness(0); - if (navigationView.AutoSuggestBox?.Margin == s_autoSuggestBoxMargin) + if (navigationView.AutoSuggestBox?.Margin == AutoSuggestBoxMarginDefault) { navigationView.AutoSuggestBox.SetCurrentValue(MarginProperty, new Thickness(0)); } @@ -604,12 +604,12 @@ DependencyPropertyChangedEventArgs e return; } - navigationView.FrameMargin = s_frameMargin; - titleBar.Margin = s_titleBarPaneOpenMargin; + navigationView.FrameMargin = FrameMarginDefault; + titleBar.Margin = TitleBarPaneOpenMarginDefault; if (navigationView.AutoSuggestBox?.Margin is { Bottom: 0, Left: 0, Right: 0, Top: 0 }) { - navigationView.AutoSuggestBox.SetCurrentValue(MarginProperty, s_autoSuggestBoxMargin); + navigationView.AutoSuggestBox.SetCurrentValue(MarginProperty, AutoSuggestBoxMarginDefault); } } @@ -640,11 +640,11 @@ DependencyPropertyChangedEventArgs e autoSuggestBox.QuerySubmitted += navigationView.AutoSuggestBoxOnQuerySubmitted; if ( - navigationView.TitleBar?.Margin == s_titleBarPaneOpenMargin + navigationView.TitleBar?.Margin == TitleBarPaneOpenMarginDefault && autoSuggestBox.Margin is { Bottom: 0, Left: 0, Right: 0, Top: 0 } ) { - autoSuggestBox.Margin = s_autoSuggestBoxMargin; + autoSuggestBox.Margin = AutoSuggestBoxMarginDefault; } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs index 583ca3100..7a3692ec0 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -64,34 +64,34 @@ public partial class NavigationView private const string TemplateElementAutoSuggestBoxSymbolButton = "PART_AutoSuggestBoxSymbolButton"; /// - /// Control responsible for rendering the content. + /// Gets or sets the control responsible for rendering the content. /// - protected NavigationViewContentPresenter NavigationViewContentPresenter = null!; + protected NavigationViewContentPresenter NavigationViewContentPresenter { get; set; } = null!; /// - /// Control located at the top of the pane with left arrow icon. + /// Gets or sets the control located at the top of the pane with left arrow icon. /// - protected System.Windows.Controls.ItemsControl MenuItemsItemsControl = null!; + protected System.Windows.Controls.ItemsControl MenuItemsItemsControl { get; set; } = null!; /// - /// Control located at the top of the pane with hamburger icon. + /// Gets or sets the control located at the top of the pane with hamburger icon. /// - protected System.Windows.Controls.ItemsControl FooterMenuItemsItemsControl = null!; + protected System.Windows.Controls.ItemsControl FooterMenuItemsItemsControl { get; set; } = null!; /// - /// Control located at the top of the pane with left arrow icon. + /// Gets or sets the control located at the top of the pane with left arrow icon. /// - protected System.Windows.Controls.Button? BackButton; + protected System.Windows.Controls.Button? BackButton { get; set; } /// - /// Control located at the top of the pane with hamburger icon. + /// Gets or sets the control located at the top of the pane with hamburger icon. /// - protected System.Windows.Controls.Button? ToggleButton; + protected System.Windows.Controls.Button? ToggleButton { get; set; } /// - /// Control that is visitable if PaneDisplayMode="Left" and in compact state + /// Gets or sets the control that is visitable if PaneDisplayMode="Left" and in compact state /// - protected System.Windows.Controls.Button? AutoSuggestBoxSymbolButton; + protected System.Windows.Controls.Button? AutoSuggestBoxSymbolButton { get; set; } /// public override void OnApplyTemplate() diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs index 2b9b91c25..329fb5e3b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs index 52da8819b..1a4bdad8e 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. @@ -18,5 +18,6 @@ public NavigationViewBreadcrumbItem(INavigationViewItem item) } public object Content { get; } + public string PageId { get; } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index d3e618e20..35f9d8bd8 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -2,6 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// // Based on Windows UI Library using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index c930b13bb..4b82e97bf 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -224,7 +224,7 @@ public NavigationCacheMode NavigationCacheMode /// public string Id { get; } - protected Grid? ChevronGrid; + protected Grid? ChevronGrid { get; set; } static NavigationViewItem() { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs index 0eb08fa0a..df000c1f0 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs @@ -2,10 +2,10 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. -// - +// // https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationviewitemheader?view=winrt-22621 // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs index ce89f6513..d94a9c7c4 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs index b230be3fe..007614602 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs b/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs index e87e0e682..de20f3878 100644 --- a/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs +++ b/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace @@ -14,17 +14,17 @@ namespace Wpf.Ui.Controls; public interface INumberFormatter { /// - /// Returns a string representation of a value. + /// Returns a string representation of a value. /// string FormatDouble(double? value); /// - /// Returns a string representation of an value. + /// Returns a string representation of an value. /// string FormatInt(int? value); /// - /// Returns a string representation of a value. + /// Returns a string representation of a value. /// string FormatUInt(uint? value); } diff --git a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs index ea472467f..2c7837127 100644 --- a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs +++ b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index d85c2bde6..dff7317cd 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -2,7 +2,13 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// // This Source Code is partially based on the source code provided by the .NET Foundation. +// +// TODO: Mask (with placeholder); Clipboard paste; +// TODO: Constant decimals when formatting. Although this can actually be done with NumberFormatter. +// TODO: Disable expression by default +// TODO: Lock to digit characters only by property using System.Windows.Data; using System.Windows.Input; @@ -10,11 +16,6 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -// TODO: Mask (with placeholder); Clipboard paste; -// TODO: Constant decimals when formatting. Although this can actually be done with NumberFormatter. -// TODO: Disable expression by default -// TODO: Lock to digit characters only by property - /// /// Represents a control that can be used to display and edit numbers. /// diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs index 17c88f42a..752068831 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs index 4dfe465a1..f99a5d741 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs index f32255e16..a93c4d278 100644 --- a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs +++ b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index 1c5f134fb..d89f1b8bb 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -2,17 +2,17 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// TODO: This is an initial implementation and requires the necessary corrections, tests and adjustments. +// +// TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true +// PasswordProperty always contains raw password using System.Windows.Controls; // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -// TODO: This is an initial implementation and requires the necessary corrections, tests and adjustments. -// - -// TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true -// PasswordProperty always contains raw password - /// /// The modified password control. /// diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index ee1ffaf26..8c5e79bef 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -2,6 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/progress-ring using Brush = System.Windows.Media.Brush; diff --git a/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs b/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs index 69eda0b41..9a68889ef 100644 --- a/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs +++ b/src/Wpf.Ui/Controls/RichTextBox/RichTextBox.cs @@ -7,7 +7,7 @@ namespace Wpf.Ui.Controls; /// -/// TODO: Add description +/// Extends the control with additional properties. /// public class RichTextBox : System.Windows.Controls.RichTextBox { diff --git a/src/Wpf.Ui/Controls/ScrollDirection.cs b/src/Wpf.Ui/Controls/ScrollDirection.cs index d8dcacb34..70a555837 100644 --- a/src/Wpf.Ui/Controls/ScrollDirection.cs +++ b/src/Wpf.Ui/Controls/ScrollDirection.cs @@ -2,9 +2,10 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel +// // Copyright (C) S. Bäumlisberger // All Rights Reserved. diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index b95bb3511..c55d83b72 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -2,6 +2,8 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// TODO: Refactor as popup, detach from the window renderer using System.Windows.Controls; using Wpf.Ui.Input; @@ -9,8 +11,6 @@ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -// TODO: Refactor as popup, detach from the window renderer - /// /// Snackbar inform user of a process that an app has performed or will perform. It appears temporarily, towards the bottom of the window. /// @@ -246,7 +246,7 @@ public Snackbar(SnackbarPresenter presenter) SetValue(TemplateButtonCommandProperty, new RelayCommand(_ => Hide())); } - protected readonly SnackbarPresenter Presenter; + protected SnackbarPresenter Presenter { get; } /// /// Shows the diff --git a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs index efa3bfcac..b085beb45 100644 --- a/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs +++ b/src/Wpf.Ui/Controls/Snackbar/SnackbarPresenter.cs @@ -24,9 +24,9 @@ public SnackbarPresenter() }; } - protected readonly Queue Queue = new(); + protected Queue Queue { get; } = new(); - protected CancellationTokenSource CancellationTokenSource = new(); + protected CancellationTokenSource CancellationTokenSource { get; set; } = new(); protected virtual void OnUnloaded() { diff --git a/src/Wpf.Ui/Controls/SpacingMode.cs b/src/Wpf.Ui/Controls/SpacingMode.cs index 73a7f8af2..81f5b7d2c 100644 --- a/src/Wpf.Ui/Controls/SpacingMode.cs +++ b/src/Wpf.Ui/Controls/SpacingMode.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index d77fdc9a8..336baf80b 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -15,13 +15,13 @@ namespace Wpf.Ui.Controls; [TemplatePart(Name = TemplateElementToggleButton, Type = typeof(ToggleButton))] public class SplitButton : Wpf.Ui.Controls.Button { - private ContextMenu? _contextMenu; - /// /// Template element represented by the ToggleButton name. /// private const string TemplateElementToggleButton = "ToggleButton"; + private ContextMenu? _contextMenu; + /// /// Gets or sets control responsible for toggling the drop-down button. /// @@ -101,7 +101,7 @@ private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyProper { if (d is SplitButton dropDownButton) { - dropDownButton.OnIsDropDownOpenChanged(e.NewValue is bool ? (bool)e.NewValue : false); + dropDownButton.OnIsDropDownOpenChanged(e.NewValue is bool boolVal && boolVal); } } @@ -115,6 +115,8 @@ protected virtual void OnContextMenuOpened(object sender, RoutedEventArgs e) SetCurrentValue(IsDropDownOpenProperty, true); } + /// This method is invoked when the changes. + /// The new value of . protected virtual void OnIsDropDownOpenChanged(bool currentValue) { } /// diff --git a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs index 0f7884940..66e21e3a8 100644 --- a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs +++ b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System.Windows.Documents; using Wpf.Ui.Extensions; // ReSharper disable once CheckNamespace @@ -21,8 +20,10 @@ public class TextBlock : System.Windows.Controls.TextBlock typeof(TextBlock), new PropertyMetadata( FontTypography.Body, - static (o, args) => ((TextBlock)o).OnFontTypographyChanged((FontTypography)args.NewValue) - ) + static (o, args) => + { + ((TextBlock)o).OnFontTypographyChanged((FontTypography)args.NewValue); + }) ); /// Identifies the dependency property. @@ -32,8 +33,10 @@ public class TextBlock : System.Windows.Controls.TextBlock typeof(TextBlock), new PropertyMetadata( TextColor.Primary, - static (o, args) => ((TextBlock)o).OnAppearanceChanged((TextColor)args.NewValue) - ) + static (o, args) => + { + ((TextBlock)o).OnAppearanceChanged((TextColor)args.NewValue); + }) ); /// diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 8d1de86bd..56de2502e 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -35,7 +35,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl private static DpiScale? dpiScale; - private DependencyObject? parentWindow; + private DependencyObject? _parentWindow; /// Identifies the dependency property. public static readonly DependencyProperty ApplicationThemeProperty = DependencyProperty.Register( @@ -372,10 +372,10 @@ public event TypedEventHandler HelpClicked /// public Action? MinimizeActionOverride { get; set; } + private readonly TitleBarButton[] _buttons = new TitleBarButton[4]; private System.Windows.Window _currentWindow = null!; - private System.Windows.Controls.Grid _mainGrid = null!; + /*private System.Windows.Controls.Grid _mainGrid = null!;*/ private System.Windows.Controls.ContentPresenter _icon = null!; - private readonly TitleBarButton[] _buttons = new TitleBarButton[4]; /// /// Initializes a new instance of the class and sets the default event. @@ -428,16 +428,16 @@ public override void OnApplyTemplate() { base.OnApplyTemplate(); - parentWindow = VisualTreeHelper.GetParent(this); + _parentWindow = VisualTreeHelper.GetParent(this); - while (parentWindow != null && parentWindow is not Window) + while (_parentWindow is not null and not Window) { - parentWindow = VisualTreeHelper.GetParent(parentWindow); + _parentWindow = VisualTreeHelper.GetParent(_parentWindow); } MouseRightButtonUp += TitleBar_MouseRightButtonUp; - _mainGrid = GetTemplateChild(ElementMainGrid); + /*_mainGrid = GetTemplateChild(ElementMainGrid);*/ _icon = GetTemplateChild(ElementIcon); var helpButton = GetTemplateChild(ElementHelpButton); @@ -650,7 +650,7 @@ private void TitleBar_MouseRightButtonUp(object sender, MouseButtonEventArgs e) } SystemCommands.ShowSystemMenu( - parentWindow as Window, + _parentWindow as Window, new Point(point.X / dpiScale.Value.DpiScaleX, point.Y / dpiScale.Value.DpiScaleY) ); } diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index af69868b2..2a0686b4b 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -87,8 +87,8 @@ public Brush RenderButtonsForeground public bool IsHovered { get; private set; } + private readonly Brush _defaultBackgroundBrush = Brushes.Transparent; // REVIEW: Should it be transparent? private User32.WM_NCHITTEST _returnValue; - private Brush _defaultBackgroundBrush = Brushes.Transparent; // REVIEW: Should it be transparent? private bool _isClickedDown; @@ -183,7 +183,6 @@ internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnInt if (this.IsMouseOverElement(lParam)) { /*Debug.WriteLine($"Hitting {ButtonType} | return code {_returnValue}");*/ - Hover(); returnIntPtr = (IntPtr)_returnValue; return true; @@ -205,7 +204,20 @@ internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnInt } } - private void UpdateReturnValue(TitleBarButtonType buttonType) => + private static void OnButtonTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is not TitleBarButton titleBarButton) + { + return; + } + + titleBarButton.OnButtonTypeChanged(e); + } + + protected void OnButtonTypeChanged(DependencyPropertyChangedEventArgs e) + { + var buttonType = (TitleBarButtonType)e.NewValue; + _returnValue = buttonType switch { TitleBarButtonType.Unknown => User32.WM_NCHITTEST.HTNOWHERE, @@ -214,12 +226,7 @@ private void UpdateReturnValue(TitleBarButtonType buttonType) => TitleBarButtonType.Close => User32.WM_NCHITTEST.HTCLOSE, TitleBarButtonType.Restore => User32.WM_NCHITTEST.HTMAXBUTTON, TitleBarButtonType.Maximize => User32.WM_NCHITTEST.HTMAXBUTTON, - _ => throw new ArgumentOutOfRangeException(nameof(buttonType), buttonType, null) + _ => throw new ArgumentOutOfRangeException(nameof(buttonType), buttonType, $"Unsupported button type: {buttonType}.") }; - - private static void OnButtonTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var titleBarButton = (TitleBarButton)d; - titleBarButton.UpdateReturnValue((TitleBarButtonType)e.NewValue); } } diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs index 842374b93..7d6971283 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs @@ -3,10 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System.ComponentModel; -using System.Drawing; -using System.Windows; - namespace Wpf.Ui.Controls; /// diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs index 2e44526e1..ebaaa6356 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGrid.cs @@ -83,15 +83,17 @@ protected virtual void AddChild(object value) throw new InvalidOperationException($"{typeof(TreeGrid)} cannot have multiple content"); }*/ - protected virtual void OnHeadersChanged() + protected virtual void OnHeadersChanged(DependencyPropertyChangedEventArgs e) { // Headers changed } - protected virtual void OnContentChanged() + /* + protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e) { // Content changed } + */ private static void OnHeadersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { @@ -100,9 +102,10 @@ private static void OnHeadersChanged(DependencyObject d, DependencyPropertyChang return; } - treeGrid.OnHeadersChanged(); + treeGrid.OnHeadersChanged(e); } + /* private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not TreeGrid treeGrid) @@ -110,6 +113,7 @@ private static void OnContentChanged(DependencyObject d, DependencyPropertyChang return; } - treeGrid.OnContentChanged(); + treeGrid.OnContentChanged(e); } + */ } diff --git a/src/Wpf.Ui/Controls/TreeGrid/TreeGridHeader.cs b/src/Wpf.Ui/Controls/TreeGrid/TreeGridHeader.cs index d0d35f18b..a36b4e0bc 100644 --- a/src/Wpf.Ui/Controls/TreeGrid/TreeGridHeader.cs +++ b/src/Wpf.Ui/Controls/TreeGrid/TreeGridHeader.cs @@ -11,24 +11,20 @@ namespace Wpf.Ui.Controls; /// public class TreeGridHeader : System.Windows.FrameworkElement { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( nameof(Title), typeof(string), typeof(TreeGridHeader), - new PropertyMetadata(String.Empty, OnTitleChanged) + new PropertyMetadata(string.Empty, OnTitleChanged) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty GroupProperty = DependencyProperty.Register( nameof(Group), typeof(string), typeof(TreeGridHeader), - new PropertyMetadata(String.Empty) + new PropertyMetadata(string.Empty) ); /// @@ -36,8 +32,8 @@ public class TreeGridHeader : System.Windows.FrameworkElement /// public string Title { - get => (string)GetValue(NameProperty); - set => SetValue(NameProperty, value); + get => (string)GetValue(TitleProperty); + set => SetValue(TitleProperty, value); } /// @@ -52,22 +48,26 @@ public string Group } /// - /// This virtual method is called when is changed. + /// This virtual method is called when is changed. /// protected virtual void OnTitleChanged() { var title = Title; - if (!String.IsNullOrEmpty(Group) || String.IsNullOrEmpty(title)) + if (!string.IsNullOrEmpty(Group) || string.IsNullOrEmpty(title)) + { return; + } - Group = title.ToLower().Trim(); + SetCurrentValue(GroupProperty, title.ToLower().Trim()); } private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not TreeGridHeader header) + { return; + } header.OnTitleChanged(); } diff --git a/src/Wpf.Ui/Controls/TypedEventHandler.cs b/src/Wpf.Ui/Controls/TypedEventHandler.cs index 4f1c17ea9..a7cd6a7d4 100644 --- a/src/Wpf.Ui/Controls/TypedEventHandler.cs +++ b/src/Wpf.Ui/Controls/TypedEventHandler.cs @@ -2,6 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs index 97d275f6b..9512b5656 100644 --- a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs +++ b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs @@ -2,9 +2,10 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel +// // Copyright (C) S. Bäumlisberger // All Rights Reserved. diff --git a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs index ec98e651a..2123737b9 100644 --- a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs +++ b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger diff --git a/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs b/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs index 3b5933e51..143558c92 100644 --- a/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs +++ b/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs @@ -2,9 +2,10 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel +// // Copyright (C) S. Bäumlisberger // All Rights Reserved. diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs index 227b5fb04..2cff1c282 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel @@ -524,12 +524,10 @@ protected override Size MeasureOverride(Size availableSize) } } - var groupItem = ItemsOwner as IHierarchicalVirtualizationAndScrollInfo; - Size extent; Size desiredSize; - if (groupItem != null) + if (ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem) { /* If the ItemsOwner is a group item the availableSize is ifinity. * Therfore the vieport size provided by the group item is used. */ diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 75af8ac59..916c2e429 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel // Copyright (C) S. Bäumlisberger // All Rights Reserved. -// - +// // Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. // https://github.com/sbaeumlisberger/VirtualizingWrapPanel @@ -192,8 +192,9 @@ ItemsOwner is IHierarchicalVirtualizationAndScrollInfo groupItem /// /// Calculates child size. /// - private Size CalculateChildSize(Size availableSize) + private Size CalculateChildSize(Size _) { + // REVIEW: this method comes with side effects. code smell if (Items.Count == 0) { return new Size(0, 0); diff --git a/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs b/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs index ab3c80493..c9708b0c0 100644 --- a/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs +++ b/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs @@ -111,22 +111,14 @@ public static bool ApplyBackdrop(IntPtr hWnd, WindowBackdropType backdropType) return false; } - switch (backdropType) + return backdropType switch { - case WindowBackdropType.Auto: - return ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_AUTO); - - case WindowBackdropType.Mica: - return ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_MAINWINDOW); - - case WindowBackdropType.Acrylic: - return ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_TRANSIENTWINDOW); - - case WindowBackdropType.Tabbed: - return ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_TABBEDWINDOW); - } - - return ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_DISABLE); + WindowBackdropType.Auto => ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_AUTO), + WindowBackdropType.Mica => ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_MAINWINDOW), + WindowBackdropType.Acrylic => ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_TRANSIENTWINDOW), + WindowBackdropType.Tabbed => ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_TABBEDWINDOW), + _ => ApplyDwmwWindowAttrubute(hWnd, Dwmapi.DWMSBT.DWMSBT_DISABLE), + }; } /// @@ -247,7 +239,7 @@ private static bool ApplyDwmwWindowAttrubute(IntPtr hWnd, Dwmapi.DWMSBT dwmSbt) private static bool ApplyLegacyMicaBackdrop(IntPtr hWnd) { - var backdropPvAttribute = 1; //Enable + var backdropPvAttribute = 1; // Enable // TODO: Validate HRESULT var dwmApiResult = Dwmapi.DwmSetWindowAttribute( @@ -260,10 +252,10 @@ private static bool ApplyLegacyMicaBackdrop(IntPtr hWnd) return dwmApiResult == HRESULT.S_OK; } - private static bool ApplyLegacyAcrylicBackdrop(IntPtr hWnd) + /*private static bool ApplyLegacyAcrylicBackdrop(IntPtr hWnd) { throw new NotImplementedException(); - } + }*/ private static bool RestoreContentBackground(IntPtr hWnd) { @@ -303,28 +295,19 @@ private static bool RestoreContentBackground(IntPtr hWnd) private static Brush GetFallbackBackgroundBrush() { - if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.HighContrast) + return ApplicationThemeManager.GetAppTheme() switch { - switch (ApplicationThemeManager.GetSystemTheme()) + ApplicationTheme.HighContrast => ApplicationThemeManager.GetSystemTheme() switch { - case SystemTheme.HC1: - return new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x32, 0x36)); - case SystemTheme.HC2: - return new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)); - case SystemTheme.HCBlack: - return new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)); - case SystemTheme.HCWhite: - default: - return new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFA, 0xEF)); - } - } - else if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Dark) - { - return new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)); - } - else - { - return new SolidColorBrush(Color.FromArgb(0xFF, 0xFA, 0xFA, 0xFA)); - } + SystemTheme.HC1 => new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x32, 0x36)), + SystemTheme.HC2 => new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)), + SystemTheme.HCBlack => new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)), + SystemTheme.HCWhite => new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)), + _ => new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFA, 0xEF)), + }, + ApplicationTheme.Dark => new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)), + ApplicationTheme.Light => new SolidColorBrush(Color.FromArgb(0xFF, 0xFA, 0xFA, 0xFA)), + _ => new SolidColorBrush(Color.FromArgb(0xFF, 0xFA, 0xFA, 0xFA)) + }; } } diff --git a/src/Wpf.Ui/Converters/BackButtonVisibilityToVisibilityConverter.cs b/src/Wpf.Ui/Converters/BackButtonVisibilityToVisibilityConverter.cs index 9185b398a..2cd0f1d03 100644 --- a/src/Wpf.Ui/Converters/BackButtonVisibilityToVisibilityConverter.cs +++ b/src/Wpf.Ui/Converters/BackButtonVisibilityToVisibilityConverter.cs @@ -12,18 +12,14 @@ internal class BackButtonVisibilityToVisibilityConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (value is not NavigationViewBackButtonVisible backButtonVisibility) + return value switch { - return Visibility.Collapsed; - } - - switch (backButtonVisibility) - { - case NavigationViewBackButtonVisible.Collapsed: - return Visibility.Collapsed; - default: - return Visibility.Visible; - } + not NavigationViewBackButtonVisible _ => Visibility.Collapsed, + NavigationViewBackButtonVisible.Collapsed => Visibility.Collapsed, + NavigationViewBackButtonVisible.Visible => Visibility.Visible, + NavigationViewBackButtonVisible.Auto => Visibility.Visible, + _ => Visibility.Collapsed + }; } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) diff --git a/src/Wpf.Ui/Converters/FallbackBrushConverter.cs b/src/Wpf.Ui/Converters/FallbackBrushConverter.cs index 411ccd592..cec13b2be 100644 --- a/src/Wpf.Ui/Converters/FallbackBrushConverter.cs +++ b/src/Wpf.Ui/Converters/FallbackBrushConverter.cs @@ -11,26 +11,12 @@ internal class FallbackBrushConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (value is SolidColorBrush brush) + return value switch { - return brush; - } - - if (value is Color) - { - return new SolidColorBrush((Color)value); - } - - // We draw red to visibly see an invalid bind in the UI. - return new SolidColorBrush( - new Color - { - A = 255, - R = 255, - G = 0, - B = 0 - } - ); + SolidColorBrush brush => brush, + Color color => new SolidColorBrush(color), + _ => new SolidColorBrush(Colors.Red) + }; } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) diff --git a/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs b/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs index a0f602cb9..cc10cc0e4 100644 --- a/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs +++ b/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs @@ -2,6 +2,8 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// TODO: It's too hardcoded, we should define better formula. using System.Windows.Data; @@ -11,8 +13,6 @@ internal class ProgressThicknessConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - // TODO: It's too hardcoded, we should define better formula. - if (value is double height) { return height / 8; diff --git a/src/Wpf.Ui/Extensions/ColorExtensions.cs b/src/Wpf.Ui/Extensions/ColorExtensions.cs index fa9031ec0..0eb71c2de 100644 --- a/src/Wpf.Ui/Extensions/ColorExtensions.cs +++ b/src/Wpf.Ui/Extensions/ColorExtensions.cs @@ -11,9 +11,9 @@ namespace Wpf.Ui.Extensions; public static class ColorExtensions { /// - /// Maximum size with the current precision. + /// Maximum size with the current precision. /// - private static readonly float _byteMax = (float)Byte.MaxValue; + private static readonly float _byteMax = (float)byte.MaxValue; /// /// Creates a from a . @@ -88,7 +88,7 @@ public static double GetSaturation(this Color color) /// Updated . public static Color UpdateLuminance(this Color color, float factor) { - if (factor > 100f || factor < -100f) + if (factor is > 100 or < -100) { throw new ArgumentOutOfRangeException(nameof(factor)); } @@ -108,7 +108,7 @@ public static Color UpdateLuminance(this Color color, float factor) /// Updated . public static Color UpdateSaturation(this Color color, float factor) { - if (factor > 100f || factor < -100f) + if (factor is > 100f or < -100f) { throw new ArgumentOutOfRangeException(nameof(factor)); } @@ -128,7 +128,7 @@ public static Color UpdateSaturation(this Color color, float factor) /// Updated . public static Color UpdateBrightness(this Color color, float factor) { - if (factor > 100f || factor < -100f) + if (factor is > 100f or < -100f) { throw new ArgumentOutOfRangeException(nameof(factor)); } @@ -155,17 +155,17 @@ public static Color Update( float luminanceFactor = 0 ) { - if (brightnessFactor > 100f || brightnessFactor < -100f) + if (brightnessFactor is > 100f or < -100f) { throw new ArgumentOutOfRangeException(nameof(brightnessFactor)); } - if (saturationFactor > 100f || saturationFactor < -100f) + if (saturationFactor is > 100f or < -100f) { throw new ArgumentOutOfRangeException(nameof(saturationFactor)); } - if (luminanceFactor > 100f || luminanceFactor < -100f) + if (luminanceFactor is > 100f or < -100f) { throw new ArgumentOutOfRangeException(nameof(luminanceFactor)); } @@ -349,45 +349,45 @@ public static (int R, int G, int B) FromHsvToRgb(float hue, float saturation, fl var f = hueAngle - (float)Math.Floor(hueAngle); var p = brightness * (1.0f - saturation); - var q = brightness * (1.0f - saturation * f); + var q = brightness * (1.0f - (saturation * f)); var t = brightness * (1.0f - (saturation * (1.0f - f))); switch ((int)hueAngle) { case 0: - red = (int)(brightness * 255.0f + 0.5f); - green = (int)(t * 255.0f + 0.5f); - blue = (int)(p * 255.0f + 0.5f); + red = (int)((brightness * 255.0f) + 0.5f); + green = (int)((t * 255.0f) + 0.5f); + blue = (int)((p * 255.0f) + 0.5f); break; case 1: - red = (int)(q * 255.0f + 0.5f); - green = (int)(brightness * 255.0f + 0.5f); - blue = (int)(p * 255.0f + 0.5f); + red = (int)((q * 255.0f) + 0.5f); + green = (int)((brightness * 255.0f) + 0.5f); + blue = (int)((p * 255.0f) + 0.5f); break; case 2: - red = (int)(p * 255.0f + 0.5f); - green = (int)(brightness * 255.0f + 0.5f); - blue = (int)(t * 255.0f + 0.5f); + red = (int)((p * 255.0f) + 0.5f); + green = (int)((brightness * 255.0f) + 0.5f); + blue = (int)((t * 255.0f) + 0.5f); break; case 3: - red = (int)(p * 255.0f + 0.5f); - green = (int)(q * 255.0f + 0.5f); - blue = (int)(brightness * 255.0f + 0.5f); + red = (int)((p * 255.0f) + 0.5f); + green = (int)((q * 255.0f) + 0.5f); + blue = (int)((brightness * 255.0f) + 0.5f); break; case 4: - red = (int)(t * 255.0f + 0.5f); - green = (int)(p * 255.0f + 0.5f); - blue = (int)(brightness * 255.0f + 0.5f); + red = (int)((t * 255.0f) + 0.5f); + green = (int)((p * 255.0f) + 0.5f); + blue = (int)((brightness * 255.0f) + 0.5f); break; case 5: - red = (int)(brightness * 255.0f + 0.5f); - green = (int)(p * 255.0f + 0.5f); - blue = (int)(q * 255.0f + 0.5f); + red = (int)((brightness * 255.0f) + 0.5f); + green = (int)((p * 255.0f) + 0.5f); + blue = (int)((q * 255.0f) + 0.5f); break; } @@ -419,14 +419,14 @@ private static int CalcHslChannel(float color, float saturation, float lightness } else { - num1 = lightness + saturation - lightness * saturation; + num1 = lightness + saturation - (lightness * saturation); } num2 = (2f * lightness) - num1; if (color * 6f < 1) { - return (int)((num2 + (num1 - num2) * 6f * color) * _byteMax); + return (int)((num2 + ((num1 - num2) * 6f * color)) * _byteMax); } if (color * 2f < 1) @@ -436,7 +436,7 @@ private static int CalcHslChannel(float color, float saturation, float lightness if (color * 3f < 2) { - return (int)((num2 + (num1 - num2) * (0.666666666f - color) * 6f) * _byteMax); + return (int)((num2 + ((num1 - num2) * (0.666666666f - color) * 6f)) * _byteMax); } return (int)(num2 * _byteMax); @@ -449,7 +449,7 @@ private static bool AlmostEquals(float numberOne, float numberTwo, float precisi { if (precision <= 0) { - precision = Single.Epsilon; + precision = float.Epsilon; } return numberOne >= (numberTwo - precision) && numberOne <= (numberTwo + precision); @@ -473,13 +473,13 @@ private static float ToPercentage(float value) /// private static byte ToColorByte(int value) { - if (value > Byte.MaxValue) + if (value > byte.MaxValue) { - value = Byte.MaxValue; + value = byte.MaxValue; } - else if (value < Byte.MinValue) + else if (value < byte.MinValue) { - value = Byte.MinValue; + value = byte.MinValue; } return Convert.ToByte(value); diff --git a/src/Wpf.Ui/Extensions/ContextMenuExtensions.cs b/src/Wpf.Ui/Extensions/ContextMenuExtensions.cs index 8b4cb3853..276da91e2 100644 --- a/src/Wpf.Ui/Extensions/ContextMenuExtensions.cs +++ b/src/Wpf.Ui/Extensions/ContextMenuExtensions.cs @@ -24,14 +24,8 @@ public static void ApplyMica(this ContextMenu contextMenu) private static void ContextMenuOnOpened(object sender, RoutedEventArgs e) { - if (sender is not ContextMenu contextMenu) - { - return; - } - - var source = PresentationSource.FromVisual(contextMenu) as HwndSource; - - if (source == null) + if (sender is not ContextMenu contextMenu + || PresentationSource.FromVisual(contextMenu) is not HwndSource source) { return; } @@ -41,9 +35,9 @@ private static void ContextMenuOnOpened(object sender, RoutedEventArgs e) UnsafeNativeMethods.ApplyWindowDarkMode(source.Handle); } - // Needs more work with the Popup service + // TODO: Needs more work with the Popup service - //if (Background.Apply(source.Handle, BackgroundType.Mica)) - // contextMenu.Background = Brushes.Transparent; + /*if (Background.Apply(source.Handle, BackgroundType.Mica)) + contextMenu.Background = Brushes.Transparent;*/ } } diff --git a/src/Wpf.Ui/Extensions/UiElementExtensions.cs b/src/Wpf.Ui/Extensions/UiElementExtensions.cs index 40b955237..164c54e3a 100644 --- a/src/Wpf.Ui/Extensions/UiElementExtensions.cs +++ b/src/Wpf.Ui/Extensions/UiElementExtensions.cs @@ -22,7 +22,7 @@ public static bool IsMouseOverElement(this UIElement element, IntPtr lParam) try { var mousePosScreen = new Point(Get_X_LParam(lParam), Get_Y_LParam(lParam)); - var bounds = new Rect(default(Point), element.RenderSize); + var bounds = new Rect(default, element.RenderSize); Point mousePosRelative = element.PointFromScreen(mousePosScreen); diff --git a/src/Wpf.Ui/Extensions/UriExtensions.cs b/src/Wpf.Ui/Extensions/UriExtensions.cs index dc2e4a747..12ed7bf63 100644 --- a/src/Wpf.Ui/Extensions/UriExtensions.cs +++ b/src/Wpf.Ui/Extensions/UriExtensions.cs @@ -20,15 +20,11 @@ public static Uri TrimLastSegment(this Uri uri) return uri; } -#if NET5_0_OR_GREATER var uriLastSegmentLength = uri.Segments[^1].Length; -#else - var uriLastSegmentLength = uri.Segments[uri.Segments.Length - 1].Length; -#endif var uriOriginalString = uri.ToString(); return new Uri( - uriOriginalString.Substring(0, uriOriginalString.Length - uriLastSegmentLength), + uriOriginalString[..^uriLastSegmentLength], UriKind.RelativeOrAbsolute ); } diff --git a/src/Wpf.Ui/Hardware/DisplayDpi.cs b/src/Wpf.Ui/Hardware/DisplayDpi.cs index caed2f3ab..8ea68b963 100644 --- a/src/Wpf.Ui/Hardware/DisplayDpi.cs +++ b/src/Wpf.Ui/Hardware/DisplayDpi.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // This Source Code is partially based on the source code provided by the .NET Foundation. namespace Wpf.Ui.Hardware; @@ -11,10 +11,10 @@ namespace Wpf.Ui.Hardware; /// Stores DPI information from which a or /// is rendered. /// -public struct DisplayDpi +public readonly struct DisplayDpi { /// - /// Initializes a new instance of the System.Windows.DpiScale structure. + /// Initializes a new instance of the structure. /// /// The DPI scale on the X axis. /// The DPI scale on the Y axis. @@ -28,7 +28,7 @@ public DisplayDpi(double dpiScaleX, double dpiScaleY) } /// - /// Initializes a new instance of the System.Windows.DpiScale structure. + /// Initializes a new instance of the structure. /// /// The DPI on the X axis. /// The DPI on the Y axis. diff --git a/src/Wpf.Ui/Hardware/DpiHelper.cs b/src/Wpf.Ui/Hardware/DpiHelper.cs index a489df6c7..335776bed 100644 --- a/src/Wpf.Ui/Hardware/DpiHelper.cs +++ b/src/Wpf.Ui/Hardware/DpiHelper.cs @@ -23,10 +23,12 @@ internal static class DpiHelper /// internal const int DefaultDpi = 96; + /* /// /// Occurs when application DPI is changed. /// - //public static event EventHandler DpiChanged; + public static event EventHandler DpiChanged; + */ /// /// Gets DPI of the selected . diff --git a/src/Wpf.Ui/Input/IRelayCommand.cs b/src/Wpf.Ui/Input/IRelayCommand.cs index 32061434e..0bbd4de35 100644 --- a/src/Wpf.Ui/Input/IRelayCommand.cs +++ b/src/Wpf.Ui/Input/IRelayCommand.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Wpf.Ui/Input/IRelayCommand{T}.cs b/src/Wpf.Ui/Input/IRelayCommand{T}.cs index 4d4b069da..ae93e1dd6 100644 --- a/src/Wpf.Ui/Input/IRelayCommand{T}.cs +++ b/src/Wpf.Ui/Input/IRelayCommand{T}.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - +// // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Wpf.Ui/Input/RelayCommand{T}.cs b/src/Wpf.Ui/Input/RelayCommand{T}.cs index 73a95b2b4..c3ea26d57 100644 --- a/src/Wpf.Ui/Input/RelayCommand{T}.cs +++ b/src/Wpf.Ui/Input/RelayCommand{T}.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// - +// // This file is inspired from the MvvmLight library (lbugnion/MvvmLight) using System.Runtime.CompilerServices; diff --git a/src/Wpf.Ui/Interop/Dwmapi.cs b/src/Wpf.Ui/Interop/Dwmapi.cs index 2cb8200df..8bb49b605 100644 --- a/src/Wpf.Ui/Interop/Dwmapi.cs +++ b/src/Wpf.Ui/Interop/Dwmapi.cs @@ -2,16 +2,16 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - +// // NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods -// - +// // Windows Kits\10\Include\10.0.22000.0\um\dwmapi.h using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/Kernel32.cs b/src/Wpf.Ui/Interop/Kernel32.cs index 2a41ebfcf..02b2d75e0 100644 --- a/src/Wpf.Ui/Interop/Kernel32.cs +++ b/src/Wpf.Ui/Interop/Kernel32.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - +// // NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. diff --git a/src/Wpf.Ui/Interop/ShObjIdl.cs b/src/Wpf.Ui/Interop/ShObjIdl.cs index f909410b4..d1774844d 100644 --- a/src/Wpf.Ui/Interop/ShObjIdl.cs +++ b/src/Wpf.Ui/Interop/ShObjIdl.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - +// // NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index cad8717d4..3a571041f 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - -// NOTE +// +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index 3db8bb8a0..23b080089 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/UnsafeReflection.cs b/src/Wpf.Ui/Interop/UnsafeReflection.cs index e1fd4b64c..7239adaea 100644 --- a/src/Wpf.Ui/Interop/UnsafeReflection.cs +++ b/src/Wpf.Ui/Interop/UnsafeReflection.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/User32.cs b/src/Wpf.Ui/Interop/User32.cs index e6b604363..1f284763a 100644 --- a/src/Wpf.Ui/Interop/User32.cs +++ b/src/Wpf.Ui/Interop/User32.cs @@ -2,12 +2,12 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - -// NOTE +// +// NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods diff --git a/src/Wpf.Ui/Interop/UxTheme.cs b/src/Wpf.Ui/Interop/UxTheme.cs index 6b91f294b..9eb0f7be4 100644 --- a/src/Wpf.Ui/Interop/UxTheme.cs +++ b/src/Wpf.Ui/Interop/UxTheme.cs @@ -2,11 +2,11 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. -// - +// // NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. diff --git a/src/Wpf.Ui/Interop/WinDef/POINT.cs b/src/Wpf.Ui/Interop/WinDef/POINT.cs index 332d209e1..567aa6423 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINT.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINT.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/WinDef/POINTL.cs b/src/Wpf.Ui/Interop/WinDef/POINTL.cs index 48dd894df..eb7304897 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINTL.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/WinDef/RECT.cs b/src/Wpf.Ui/Interop/WinDef/RECT.cs index 6b0f0392c..83a4ebef1 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECT.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECT.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/WinDef/RECTL.cs b/src/Wpf.Ui/Interop/WinDef/RECTL.cs index 0f0bf29c7..b12a2e0f9 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECTL.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Interop/WinDef/SIZE.cs b/src/Wpf.Ui/Interop/WinDef/SIZE.cs index a3e8f5bc0..6e77f4304 100644 --- a/src/Wpf.Ui/Interop/WinDef/SIZE.cs +++ b/src/Wpf.Ui/Interop/WinDef/SIZE.cs @@ -2,7 +2,7 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -// - +// // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. diff --git a/src/Wpf.Ui/Markup/Design.cs b/src/Wpf.Ui/Markup/Design.cs index 4e5d1c351..7973f029e 100644 --- a/src/Wpf.Ui/Markup/Design.cs +++ b/src/Wpf.Ui/Markup/Design.cs @@ -21,67 +21,56 @@ namespace Wpf.Ui.Markup; public static class Design { private static readonly string DesignProcessName = "devenv"; - - static bool? _inDesignMode; + private static bool? _inDesignMode; /// - /// Indicates whether or not the framework is in design-time mode. (Caliburn.Micro implementation) + /// Gets a value indicating whether the framework is in design-time mode. (Caliburn.Micro implementation) /// - private static bool InDesignMode - { - get - { - if (_inDesignMode != null) - { - return _inDesignMode ?? false; - } - - _inDesignMode = (bool) - DependencyPropertyDescriptor - .FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)) - .Metadata.DefaultValue; - - if ( - !(_inDesignMode ?? false) - && System - .Diagnostics.Process.GetCurrentProcess() - .ProcessName.StartsWith(DesignProcessName, System.StringComparison.Ordinal) - ) - { - _inDesignMode = true; - } - - return _inDesignMode ?? false; - } - } + private static bool InDesignMode => _inDesignMode ??= + (bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue + || System.Diagnostics.Process.GetCurrentProcess().ProcessName.StartsWith(DesignProcessName, StringComparison.Ordinal); - public static DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( + public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( "Background", typeof(System.Windows.Media.Brush), typeof(Design), - new PropertyMetadata(OnBackgroundPropertyChanged) + new PropertyMetadata(OnBackgroundChanged) ); - public static DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached( + public static readonly DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached( "Foreground", typeof(System.Windows.Media.Brush), typeof(Design), - new PropertyMetadata(OnForegroundPropertyChanged) + new PropertyMetadata(OnForegroundChanged) ); + /// Helper for getting from . + /// to read from. + /// Background property value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0033:Add [AttachedPropertyBrowsableForType]", Justification = "Because")] public static System.Windows.Media.Brush? GetBackground(DependencyObject dependencyObject) => (System.Windows.Media.Brush)dependencyObject.GetValue(BackgroundProperty); + /// Helper for setting on . + /// to set on. + /// Background property value. public static void SetBackground(DependencyObject dependencyObject, System.Windows.Media.Brush? value) => dependencyObject.SetValue(BackgroundProperty, value); + /// Helper for getting from . + /// to read from. + /// Foreground property value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0033:Add [AttachedPropertyBrowsableForType]", Justification = "Because")] public static System.Windows.Media.Brush? GetForeground(DependencyObject dependencyObject) => (System.Windows.Media.Brush)dependencyObject.GetValue(ForegroundProperty); + /// Helper for setting on . + /// to set on. + /// Foreground property value. public static void SetForeground(DependencyObject dependencyObject, System.Windows.Media.Brush? value) => dependencyObject.SetValue(ForegroundProperty, value); - private static void OnBackgroundPropertyChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) + private static void OnBackgroundChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) { if (!InDesignMode) { @@ -91,7 +80,7 @@ private static void OnBackgroundPropertyChanged(DependencyObject? d, DependencyP d?.GetType()?.GetProperty("Background")?.SetValue(d, e.NewValue, null); } - private static void OnForegroundPropertyChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) + private static void OnForegroundChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) { if (!InDesignMode) { diff --git a/src/Wpf.Ui/Properties/AssemblyInfo.cs b/src/Wpf.Ui/Properties/AssemblyInfo.cs index e937b0a75..7fc969823 100644 --- a/src/Wpf.Ui/Properties/AssemblyInfo.cs +++ b/src/Wpf.Ui/Properties/AssemblyInfo.cs @@ -4,7 +4,6 @@ // All Rights Reserved. using System.Runtime.InteropServices; -using System.Windows; using System.Windows.Markup; [assembly: ComVisible(false)] diff --git a/src/Wpf.Ui/SimpleContentDialogCreateOptions.cs b/src/Wpf.Ui/SimpleContentDialogCreateOptions.cs index 282367a33..7715f9e42 100644 --- a/src/Wpf.Ui/SimpleContentDialogCreateOptions.cs +++ b/src/Wpf.Ui/SimpleContentDialogCreateOptions.cs @@ -27,13 +27,13 @@ public class SimpleContentDialogCreateOptions /// /// Gets or sets the default text of the primary button at the bottom of the content dialog. - /// If not added, or , it will not be displayed. + /// If not added, or , it will not be displayed. /// - public string PrimaryButtonText { get; set; } = String.Empty; + public string PrimaryButtonText { get; set; } = string.Empty; /// /// Gets or sets the default text of the secondary button at the bottom of the content dialog. - /// If not added, or , it will not be displayed. + /// If not added, or , it will not be displayed. /// - public string SecondaryButtonText { get; set; } = String.Empty; + public string SecondaryButtonText { get; set; } = string.Empty; } diff --git a/src/Wpf.Ui/ThemeService.cs b/src/Wpf.Ui/ThemeService.cs index a6b5a1a8a..713cc9440 100644 --- a/src/Wpf.Ui/ThemeService.cs +++ b/src/Wpf.Ui/ThemeService.cs @@ -72,7 +72,7 @@ public bool SetAccent(Color accentColor) public bool SetAccent(SolidColorBrush accentSolidBrush) { Color color = accentSolidBrush.Color; - color.A = (byte)Math.Round(accentSolidBrush.Opacity * Byte.MaxValue); + color.A = (byte)Math.Round(accentSolidBrush.Opacity * byte.MaxValue); ApplicationAccentColorManager.Apply(color); diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 29098c302..48ba47ddb 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -70,7 +70,7 @@ public ResourceDictionary Resources { if (_resources is null) { - _resources = new ResourceDictionary(); + _resources = new(); try { diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index 4091de2ee..013389a3b 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -19,6 +19,9 @@ namespace Wpf.Ui.Win32; internal class Utilities { private static readonly PlatformID _osPlatform = Environment.OSVersion.Platform; + public static readonly Version Vista = new(6, 0); + public static readonly Version Windows7 = new(6, 1); + public static readonly Version Windows8 = new(6, 2); private static readonly Version _osVersion = #if NET5_0_OR_GREATER @@ -35,17 +38,17 @@ internal class Utilities /// /// Gets a value indicating whether the operating system version is greater than or equal to 6.0. /// - public static bool IsOSVistaOrNewer => _osVersion >= new Version(6, 0); + public static bool IsOSVistaOrNewer => _osVersion >= Vista; /// /// Gets a value indicating whether the operating system version is greater than or equal to 6.1. /// - public static bool IsOSWindows7OrNewer => _osVersion >= new Version(6, 1); + public static bool IsOSWindows7OrNewer => _osVersion >= Windows7; /// /// Gets a value indicating whether the operating system version is greater than or equal to 6.2. /// - public static bool IsOSWindows8OrNewer => _osVersion >= new Version(6, 2); + public static bool IsOSWindows8OrNewer => _osVersion >= Windows8; /// /// Gets a value indicating whether the operating system version is greater than or equal to 10.0* (build 10240). @@ -90,7 +93,7 @@ public static void SafeDispose(ref T disposable) { // Dispose can safely be called on an object multiple times. IDisposable t = disposable; - disposable = default(T); + disposable = default; if (t is null) { @@ -104,14 +107,14 @@ public static void SafeRelease(ref T comObject) where T : class { T t = comObject; - comObject = default(T); + comObject = default; if (t is null) { return; } - Debug.Assert(Marshal.IsComObject(t)); + Debug.Assert(Marshal.IsComObject(t), "Object is not a COM object."); Marshal.ReleaseComObject(t); } diff --git a/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs b/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs index b97771af9..e1c337693 100644 --- a/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs +++ b/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs @@ -1,8 +1,7 @@ -namespace Wpf.Ui.Gallery.UnitTests +namespace Wpf.Ui.Gallery.UnitTests; + +public class UnitTest1 { - public class UnitTest1 - { - [Fact] - public void Test1() { } - } + [Fact] + public void Test1() { } } diff --git a/tests/Wpf.Ui.UnitTests/Extensions/SymbolExtensionsTests.cs b/tests/Wpf.Ui.UnitTests/Extensions/SymbolExtensionsTests.cs index e12d6c8ae..3e2aae925 100644 --- a/tests/Wpf.Ui.UnitTests/Extensions/SymbolExtensionsTests.cs +++ b/tests/Wpf.Ui.UnitTests/Extensions/SymbolExtensionsTests.cs @@ -40,7 +40,7 @@ public void GivenAllRegularSymbols_GetString_ReturnsValidString() var receivedString = regularSymbol.GetString(); - Assert.NotEqual(String.Empty, receivedString); + Assert.NotEqual(string.Empty, receivedString); } } @@ -56,7 +56,7 @@ public void GivenAllFilledSymbols_GetString_ReturnsValidString() var receivedString = filledSymbol.GetString(); - Assert.NotEqual(String.Empty, receivedString); + Assert.NotEqual(string.Empty, receivedString); } } } From 704aa7e7460cf73fa1f907939293ac87a6384998 Mon Sep 17 00:00:00 2001 From: koal44 Date: Sat, 30 Mar 2024 23:26:30 -0700 Subject: [PATCH 17/33] Edit .editorconfig to suppress warnings related to valueconverters --- .editorconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.editorconfig b/.editorconfig index 1eb2d7ce5..e3feb3434 100644 --- a/.editorconfig +++ b/.editorconfig @@ -398,3 +398,8 @@ dotnet_diagnostic.SA1208.severity = none dotnet_diagnostic.SA1518.severity = none dotnet_diagnostic.SA1615.severity = none dotnet_diagnostic.SA1502.severity = none + +# Suppress some ValueConverter warnings +dotnet_diagnostic.WPF0073.severity = none # Add ValueConversion attribute (unknown types) +dotnet_diagnostic.WPF0071.severity = none # Add ValueConversion attribute +dotnet_diagnostic.WPF0070.severity = none # Add default field to converter From d5fed4349bf03d06b48475ed9a6f43f8fe1ee05a Mon Sep 17 00:00:00 2001 From: koal44 Date: Sun, 31 Mar 2024 12:19:54 -0700 Subject: [PATCH 18/33] Cleanup warning related to 'var' --- .editorconfig | 2 +- .../Services/WindowsProviderService.cs | 2 +- .../ClientAreaBorder/ClientAreaBorder.cs | 4 +-- .../Controls/ContextMenu/ContextMenu.xaml.cs | 2 +- src/Wpf.Ui/Controls/DataGrid/DataGrid.cs | 2 +- .../NavigationView/NavigationView.Base.cs | 2 +- .../NavigationView.Navigation.cs | 35 +++++++++---------- .../NavigationView/NavigationViewActivator.cs | 11 +++--- .../Controls/RatingControl/RatingControl.cs | 6 ++-- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 22 ++++++------ .../VirtualizingPanelBase.cs | 10 +++--- .../VirtualizingWrapPanel.cs | 2 +- src/Wpf.Ui/Interop/UnsafeNativeMethods.cs | 16 ++++----- src/Wpf.Ui/TaskBarService.cs | 6 ++-- src/Wpf.Ui/Win32/Utilities.cs | 2 +- .../TransitionAnimationProviderTests.cs | 2 +- 16 files changed, 62 insertions(+), 64 deletions(-) diff --git a/.editorconfig b/.editorconfig index e3feb3434..97b6c4421 100644 --- a/.editorconfig +++ b/.editorconfig @@ -96,7 +96,7 @@ dotnet_style_readonly_field = true:warning # var preferences csharp_style_var_elsewhere = false:warning csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = false:warning +csharp_style_var_when_type_is_apparent = false:none # Expression-bodied members csharp_style_expression_bodied_accessors = false:silent diff --git a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs index 0752cf1bb..2a795dee6 100644 --- a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs +++ b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs @@ -22,7 +22,7 @@ public void Show() throw new InvalidOperationException($"The window class should be derived from {typeof(Window)}."); } - var windowInstance = _serviceProvider.GetService() as Window + Window windowInstance = _serviceProvider.GetService() as Window ?? throw new InvalidOperationException("Window is not registered as service."); windowInstance.Owner = Application.Current.MainWindow; windowInstance.Show(); diff --git a/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs b/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs index 0828b8ebc..498638413 100644 --- a/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs +++ b/src/Wpf.Ui/Controls/ClientAreaBorder/ClientAreaBorder.cs @@ -170,7 +170,7 @@ private void OnWindowStateChanged(object? sender, EventArgs e) return; } - var padding = window.WindowState == WindowState.Maximized ? WindowChromeNonClientFrameThickness : default; + Thickness padding = window.WindowState == WindowState.Maximized ? WindowChromeNonClientFrameThickness : default; SetCurrentValue(PaddingProperty, padding); } @@ -184,7 +184,7 @@ private void ApplyDefaultWindowBorder() _borderBrushApplied = true; // SystemParameters.WindowGlassBrush - var borderColor = ApplicationTheme == ApplicationTheme.Light + Color borderColor = ApplicationTheme == ApplicationTheme.Light ? Color.FromArgb(0xFF, 0x7A, 0x7A, 0x7A) : Color.FromArgb(0xFF, 0x3A, 0x3A, 0x3A); _oldWindow.SetCurrentValue(System.Windows.Controls.Control.BorderBrushProperty, new SolidColorBrush(borderColor)); diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs index 85a38feb5..f21669f15 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs @@ -30,7 +30,7 @@ public ContextMenu() private void OnResourceDictionaryLoaded() { - var currentAssembly = typeof(Application).Assembly; + Assembly currentAssembly = typeof(Application).Assembly; AddEditorContextMenuDefaultStyle(currentAssembly); } diff --git a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs index ab0867e23..8ca0f5463 100644 --- a/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs +++ b/src/Wpf.Ui/Controls/DataGrid/DataGrid.cs @@ -70,7 +70,7 @@ private void ColumnsOnCollectionChanged(object? sender, NotifyCollectionChangedE private void UpdateColumnElementStyles() { - foreach (var singleColumn in Columns) + foreach (DataGridColumn singleColumn in Columns) { UpdateSingleColumn(singleColumn); } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index f370c066b..86bdbac3d 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -454,7 +454,7 @@ protected virtual void CloseNavigationViewItemMenus() DeactivateMenuItems(MenuItems); DeactivateMenuItems(FooterMenuItems); - var currentItem = PageIdOrTargetTagNavigationViewsDictionary[Journal[^1]]; + INavigationViewItem currentItem = PageIdOrTargetTagNavigationViewsDictionary[Journal[^1]]; if (currentItem.NavigationViewItemParent is null) { currentItem.Activate(this); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 557a21a7f..24d25f848 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -44,39 +44,34 @@ private readonly Dictionary< /// public virtual bool Navigate(Type pageType, object? dataContext = null) { - if (!PageTypeNavigationViewsDictionary.TryGetValue(pageType, out var navigationViewItem)) + if (PageTypeNavigationViewsDictionary.TryGetValue(pageType, out INavigationViewItem navigationViewItem)) { - return TryToNavigateWithoutINavigationViewItem(pageType, false, dataContext); + return NavigateInternal(navigationViewItem, dataContext); } - return NavigateInternal(navigationViewItem, dataContext); + return TryToNavigateWithoutINavigationViewItem(pageType, false, dataContext); } /// public virtual bool Navigate(string pageIdOrTargetTag, object? dataContext = null) { - if ( - !PageIdOrTargetTagNavigationViewsDictionary.TryGetValue( - pageIdOrTargetTag, - out INavigationViewItem? navigationViewItem - ) - ) + if (PageIdOrTargetTagNavigationViewsDictionary.TryGetValue(pageIdOrTargetTag, out INavigationViewItem navigationViewItem)) { - return false; + return NavigateInternal(navigationViewItem, dataContext); } - return NavigateInternal(navigationViewItem, dataContext); + return false; } /// public virtual bool NavigateWithHierarchy(Type pageType, object? dataContext = null) { - if (!PageTypeNavigationViewsDictionary.TryGetValue(pageType, out var navigationViewItem)) + if (PageTypeNavigationViewsDictionary.TryGetValue(pageType, out INavigationViewItem? navigationViewItem)) { - return TryToNavigateWithoutINavigationViewItem(pageType, true, dataContext); + return NavigateInternal(navigationViewItem, dataContext, true); } - return NavigateInternal(navigationViewItem, dataContext, true); + return TryToNavigateWithoutINavigationViewItem(pageType, true, dataContext); } /// @@ -403,12 +398,13 @@ private void UpdateCurrentNavigationStackItem(INavigationViewItem viewItem) private void RecreateNavigationStackFromHistory(INavigationViewItem item) { - if (!_complexNavigationStackHistory.TryGetValue(item, out var historyList) || historyList.Count == 0) + List historyList; + if (!_complexNavigationStackHistory.TryGetValue(item, out historyList) || historyList.Count == 0) { return; } - var latestHistory = historyList[^1]; + INavigationViewItem?[] latestHistory = historyList[^1]; var startIndex = 0; if (latestHistory[0]!.IsMenuElement) @@ -441,7 +437,7 @@ private void RecreateNavigationStackFromHistory(INavigationViewItem item) private void AddToNavigationStackHistory(INavigationViewItem viewItem) { - var lastItem = NavigationStack[^1]; + INavigationViewItem lastItem = NavigationStack[^1]; var startIndex = NavigationStack.IndexOf(viewItem); if (startIndex < 0) @@ -449,7 +445,8 @@ private void AddToNavigationStackHistory(INavigationViewItem viewItem) startIndex = 0; } - if (!_complexNavigationStackHistory.TryGetValue(lastItem, out var historyList)) + List historyList; + if (!_complexNavigationStackHistory.TryGetValue(lastItem, out historyList)) { historyList = new List(5); _complexNavigationStackHistory.Add(lastItem, historyList); @@ -467,7 +464,7 @@ private void AddToNavigationStackHistory(INavigationViewItem viewItem) historyList.Add(array); - var latestHistory = historyList[^1]; + INavigationViewItem?[] latestHistory = historyList[^1]; int i = 0; for (int j = startIndex; j < NavigationStack.Count - 1; j++) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs index 69b6008c3..8521bb04f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs @@ -46,7 +46,7 @@ internal static class NavigationViewActivator #if NET48_OR_GREATER || NETCOREAPP3_0_OR_GREATER if (ControlsServices.ControlsServiceProvider != null) { - var pageConstructors = pageType.GetConstructors(); + ConstructorInfo[] pageConstructors = pageType.GetConstructors(); var parameterlessCount = pageConstructors.Count(ctor => ctor.GetParameters().Length == 0); var parameterfullCount = pageConstructors.Length - parameterlessCount; @@ -79,7 +79,7 @@ internal static class NavigationViewActivator } } - var emptyConstructor = FindParameterlessConstructor(pageType) + ConstructorInfo emptyConstructor = FindParameterlessConstructor(pageType) ?? throw new InvalidOperationException( $"The {pageType} page does not have a parameterless constructor. If you are using {typeof(IPageService)} do not navigate initially and don't use Cache or Precache." ); @@ -111,7 +111,7 @@ internal static class NavigationViewActivator return parameterfullCtors .Select(ctor => { - var parameters = ctor.GetParameters(); + ParameterInfo[] parameters = ctor.GetParameters(); int score = parameters.Aggregate(0, (acc, prm) => acc + (ResolveConstructorParameter(prm.ParameterType, dataContext) != null ? 1 : 0)); score = score != parameters.Length ? 0 : score; @@ -125,7 +125,8 @@ internal static class NavigationViewActivator private static FrameworkElement? InvokeElementConstructor(ConstructorInfo ctor, object? dataContext) { - var args = ctor.GetParameters() + IEnumerable args = ctor + .GetParameters() .Select(prm => ResolveConstructorParameter(prm.ParameterType, dataContext)); return ctor.Invoke(args.ToArray()) as FrameworkElement; @@ -134,7 +135,7 @@ internal static class NavigationViewActivator private static FrameworkElement? InvokeElementConstructor(Type tPage, object? dataContext) { - var ctor = dataContext is null + ConstructorInfo ctor = dataContext is null ? tPage.GetConstructor(Type.EmptyTypes) : tPage.GetConstructor(new[] { dataContext!.GetType() }); diff --git a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs index 255ccb2ef..cd40fbb4d 100644 --- a/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs +++ b/src/Wpf.Ui/Controls/RatingControl/RatingControl.cs @@ -148,7 +148,7 @@ protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); - var currentPossition = e.GetPosition(this); + Point currentPossition = e.GetPosition(this); var mouseOffset = currentPossition.X * 100 / ActualWidth; if (e.LeftButton != MouseButtonState.Pressed) @@ -164,7 +164,7 @@ protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); - var currentPossition = e.GetPosition(this); + Point currentPossition = e.GetPosition(this); var mouseOffset = currentPossition.X * 100 / ActualWidth; if (e.LeftButton == MouseButtonState.Pressed) @@ -340,7 +340,7 @@ private void SetStarsPresence(int index) private void UpdateStar(int starIndex, StarValue starValue) { - var selectedIcon = starIndex switch + SymbolIcon? selectedIcon = starIndex switch { 1 => _symbolIconStarTwo, 2 => _symbolIconStarThree, diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs index 56de2502e..dd4bb52b8 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.cs @@ -440,10 +440,10 @@ public override void OnApplyTemplate() /*_mainGrid = GetTemplateChild(ElementMainGrid);*/ _icon = GetTemplateChild(ElementIcon); - var helpButton = GetTemplateChild(ElementHelpButton); - var minimizeButton = GetTemplateChild(ElementMinimizeButton); - var maximizeButton = GetTemplateChild(ElementMaximizeButton); - var closeButton = GetTemplateChild(ElementCloseButton); + TitleBarButton helpButton = GetTemplateChild(ElementHelpButton); + TitleBarButton minimizeButton = GetTemplateChild(ElementMinimizeButton); + TitleBarButton maximizeButton = GetTemplateChild(ElementMaximizeButton); + TitleBarButton closeButton = GetTemplateChild(ElementCloseButton); _buttons[0] = maximizeButton; _buttons[1] = minimizeButton; @@ -567,8 +567,8 @@ private void OnWindowContentRendered(object? sender, EventArgs e) window.ContentRendered -= OnWindowContentRendered; - var handle = new WindowInteropHelper(window).Handle; - var windowSource = HwndSource.FromHwnd(handle) + IntPtr handle = new WindowInteropHelper(window).Handle; + HwndSource windowSource = HwndSource.FromHwnd(handle) ?? throw new ArgumentNullException("Window source is null"); windowSource.AddHook(HwndSourceHook); } @@ -590,15 +590,15 @@ or User32.WM.NCLBUTTONUP return IntPtr.Zero; } - foreach (var button in _buttons) + foreach (TitleBarButton button in _buttons) { - if (!button.ReactToHwndHook(message, lParam, out var returnIntPtr)) + if (!button.ReactToHwndHook(message, lParam, out IntPtr returnIntPtr)) { continue; } // Fix for when sometimes, button hover backgrounds aren't cleared correctly, causing multiple buttons to appear as if hovered. - foreach (var anotherButton in _buttons) + foreach (TitleBarButton anotherButton in _buttons) { if (anotherButton == button) { @@ -642,7 +642,7 @@ or User32.WM.NCLBUTTONUP /// private void TitleBar_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { - var point = PointToScreen(e.GetPosition(this)); + Point point = PointToScreen(e.GetPosition(this)); if (dpiScale is null) { @@ -658,7 +658,7 @@ private void TitleBar_MouseRightButtonUp(object sender, MouseButtonEventArgs e) private T GetTemplateChild(string name) where T : DependencyObject { - var element = GetTemplateChild(name); + DependencyObject element = GetTemplateChild(name); if (element is not T tElement) { diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs index 2cff1c282..0520ebb37 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs @@ -485,7 +485,7 @@ protected virtual void UpdateScrollInfo(Size availableSize, Size extent) /// protected int GetItemIndexFromChildIndex(int childIndex) { - var generatorPosition = GetGeneratorPositionFromChildIndex(childIndex); + GeneratorPosition generatorPosition = GetGeneratorPositionFromChildIndex(childIndex); return ItemContainerGenerator.IndexFromGeneratorPosition(generatorPosition); } @@ -531,8 +531,8 @@ protected override Size MeasureOverride(Size availableSize) { /* If the ItemsOwner is a group item the availableSize is ifinity. * Therfore the vieport size provided by the group item is used. */ - var viewportSize = groupItem.Constraints.Viewport.Size; - var headerSize = groupItem.HeaderDesiredSizes.PixelSize; + Size viewportSize = groupItem.Constraints.Viewport.Size; + Size headerSize = groupItem.HeaderDesiredSizes.PixelSize; double availableWidth = Math.Max(viewportSize.Width - 5, 0); // left margin of 5 dp double availableHeight = Math.Max(viewportSize.Height - headerSize.Height, 0); availableSize = new Size(availableWidth, availableHeight); @@ -572,7 +572,7 @@ protected override Size MeasureOverride(Size availableSize) /// protected virtual void RealizeItems() { - var startPosition = ItemContainerGenerator.GeneratorPositionFromIndex(ItemRange.StartIndex); + GeneratorPosition startPosition = ItemContainerGenerator.GeneratorPositionFromIndex(ItemRange.StartIndex); var childIndex = startPosition.Offset == 0 ? startPosition.Index : startPosition.Index + 1; using IDisposable at = ItemContainerGenerator.StartAt( @@ -625,7 +625,7 @@ protected virtual void VirtualizeItems() { for (int childIndex = InternalChildren.Count - 1; childIndex >= 0; childIndex--) { - var generatorPosition = GetGeneratorPositionFromChildIndex(childIndex); + GeneratorPosition generatorPosition = GetGeneratorPositionFromChildIndex(childIndex); var itemIndex = ItemContainerGenerator.IndexFromGeneratorPosition(generatorPosition); diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 916c2e429..c0a852c1d 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -200,7 +200,7 @@ private Size CalculateChildSize(Size _) return new Size(0, 0); } - var startPosition = ItemContainerGenerator.GeneratorPositionFromIndex(0); + GeneratorPosition startPosition = ItemContainerGenerator.GeneratorPositionFromIndex(0); using IDisposable at = ItemContainerGenerator.StartAt( startPosition, diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index 23b080089..575aeaf75 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -86,7 +86,7 @@ public static bool RemoveWindowDarkMode(IntPtr handle) } var pvAttribute = 0x0; // Disable - var dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; + Dwmapi.DWMWINDOWATTRIBUTE dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; if (!Win32.Utilities.IsOSWindows11Insider1OrNewer) { @@ -125,7 +125,7 @@ public static bool ApplyWindowDarkMode(IntPtr handle) } var pvAttribute = 0x1; // Enable - var dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; + Dwmapi.DWMWINDOWATTRIBUTE dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; if (!Win32.Utilities.IsOSWindows11Insider1OrNewer) { @@ -184,7 +184,7 @@ public static bool RemoveWindowTitlebarContents(IntPtr handle) var windowStyleLong = User32.GetWindowLong(handle, User32.GWL.GWL_STYLE); windowStyleLong &= ~(int)User32.WS.SYSMENU; - var result = SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong); + IntPtr result = SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong); return result.ToInt64() > 0x0; } @@ -328,8 +328,8 @@ public static bool ApplyWindowLegacyAcrylicEffect(IntPtr handle) nColor = 0x990000 & 0xFFFFFF }; - var accentStructSize = Marshal.SizeOf(accentPolicy); - var accentPtr = Marshal.AllocHGlobal(accentStructSize); + int accentStructSize = Marshal.SizeOf(accentPolicy); + IntPtr accentPtr = Marshal.AllocHGlobal(accentStructSize); Marshal.StructureToPtr(accentPolicy, accentPtr, false); @@ -354,7 +354,7 @@ public static Color GetDwmColor() { try { - Dwmapi.DwmGetColorizationParameters(out var dwmParams); + Dwmapi.DwmGetColorizationParameters(out Dwmapi.DWMCOLORIZATIONPARAMS dwmParams); var values = BitConverter.GetBytes(dwmParams.clrColor); return Color.FromArgb(255, values[2], values[1], values[0]); @@ -461,7 +461,7 @@ public static bool RemoveWindowCaption(Window window) return false; } - var windowHandle = new WindowInteropHelper(window).Handle; + IntPtr windowHandle = new WindowInteropHelper(window).Handle; return RemoveWindowCaption(windowHandle); } @@ -501,7 +501,7 @@ public static bool ExtendClientAreaIntoTitleBar(Window window) return false; } - var windowHandle = new WindowInteropHelper(window).Handle; + IntPtr windowHandle = new WindowInteropHelper(window).Handle; return ExtendClientAreaIntoTitleBar(windowHandle); } diff --git a/src/Wpf.Ui/TaskBarService.cs b/src/Wpf.Ui/TaskBarService.cs index 2fa3ed4f6..eea009e5b 100644 --- a/src/Wpf.Ui/TaskBarService.cs +++ b/src/Wpf.Ui/TaskBarService.cs @@ -33,7 +33,7 @@ public virtual TaskBarProgressState GetState(Window? window) return TaskBarProgressState.None; } - var windowHandle = new WindowInteropHelper(window).Handle; + IntPtr windowHandle = new WindowInteropHelper(window).Handle; if (!_progressStates.TryGetValue(windowHandle, out TaskBarProgressState progressState)) { @@ -78,7 +78,7 @@ public virtual bool SetValue(Window? window, int current, int total) return false; } - var windowHandle = new WindowInteropHelper(window).Handle; + IntPtr windowHandle = new WindowInteropHelper(window).Handle; if (!_progressStates.TryGetValue(windowHandle, out TaskBarProgressState progressState)) { @@ -108,7 +108,7 @@ int total /// public virtual bool SetValue(IntPtr hWnd, int current, int total) { - if (!_progressStates.TryGetValue(hWnd, out var progressState)) + if (!_progressStates.TryGetValue(hWnd, out TaskBarProgressState progressState)) { return TaskBarProgress.SetValue(hWnd, TaskBarProgressState.Normal, current, total); } diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index 013389a3b..bc19dbfa3 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -223,7 +223,7 @@ private static bool TryGetRegistryKey(string path, string key, out object? value try { - using var rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path); + using Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path); if (rk == null) { diff --git a/tests/Wpf.Ui.UnitTests/Animations/TransitionAnimationProviderTests.cs b/tests/Wpf.Ui.UnitTests/Animations/TransitionAnimationProviderTests.cs index 2007d3bce..cfecdae4f 100644 --- a/tests/Wpf.Ui.UnitTests/Animations/TransitionAnimationProviderTests.cs +++ b/tests/Wpf.Ui.UnitTests/Animations/TransitionAnimationProviderTests.cs @@ -12,7 +12,7 @@ public class TransitionAnimationProviderTests [Fact] public void ApplyTransition_ReturnsFalse_WhenDurationIsLessThan10() { - var mockedUiElement = Substitute.For(); + UIElement mockedUiElement = Substitute.For(); var result = TransitionAnimationProvider.ApplyTransition(mockedUiElement, Transition.FadeIn, -10); From 40116b1c463328f58a5bc7f92a7a5e1756451552 Mon Sep 17 00:00:00 2001 From: koal44 Date: Sun, 31 Mar 2024 17:42:36 -0700 Subject: [PATCH 19/33] Fix warnings --- src/Wpf.Ui.Demo.Console/Program.cs | 4 + .../Utilities/ThemeUtilities.cs | 6 +- .../Views/Pages/DataPage.xaml.cs | 2 + .../Views/Pages/SettingsPage.xaml.cs | 2 +- src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs | 10 +- .../ViewModels/MainWindowViewModel.cs | 29 +- .../ViewModels/SettingsViewModel.cs | 2 +- src/Wpf.Ui.Gallery/App.xaml.cs | 2 - .../Controllers/MonacoController.cs | 2 +- .../Controls/ControlExample.xaml.cs | 42 +- .../GalleryNavigationPresenter.xaml.cs | 8 +- .../Controls/PageControlDocumentation.xaml.cs | 49 ++- .../Controls/TermsOfUseContentDialog.xaml.cs | 3 +- .../Controls/TypographyControl.xaml.cs | 15 +- .../ControlsLookup/ControlPages.cs | 8 +- .../ControlsLookup/GalleryPage.cs | 2 +- .../ControlsLookup/GalleryPageAttribute.cs | 3 +- src/Wpf.Ui.Gallery/GalleryAssembly.cs | 2 +- .../Helpers/NameToPageTypeConverter.cs | 2 +- .../PaneDisplayModeToIndexConverter.cs | 42 +- src/Wpf.Ui.Gallery/Models/Person.cs | 2 +- .../Pages/BasicInput/AnchorViewModel.cs | 2 + .../Pages/BasicInput/ButtonViewModel.cs | 4 + .../Pages/BasicInput/CheckBoxViewModel.cs | 17 +- .../Pages/BasicInput/ComboBoxViewModel.cs | 12 +- .../Pages/BasicInput/RadioButtonViewModel.cs | 2 + .../Pages/BasicInput/RatingViewModel.cs | 4 + .../Pages/BasicInput/ThumbRateViewModel.cs | 12 +- .../Pages/BasicInput/ToggleButtonViewModel.cs | 2 + .../Pages/Collections/DataGridViewModel.cs | 2 +- .../Pages/Collections/ListBoxViewModel.cs | 6 +- .../Pages/Collections/ListViewViewModel.cs | 6 +- .../ViewModels/Pages/DashboardViewModel.cs | 2 +- .../Pages/DesignGuidance/IconsViewModel.cs | 26 +- .../ContentDialogViewModel.cs | 2 +- .../DialogsAndFlyouts/FlyoutViewModel.cs | 2 + .../DialogsAndFlyouts/MessageBoxViewModel.cs | 10 +- .../DialogsAndFlyouts/SnackbarViewModel.cs | 2 +- .../Navigation/BreadcrumbBarViewModel.cs | 22 +- .../Pages/OpSystem/FilePickerViewModel.cs | 22 +- .../ViewModels/Pages/SettingsViewModel.cs | 2 +- .../Pages/StatusAndInfo/InfoBadgeViewModel.cs | 2 +- .../Pages/StatusAndInfo/InfoBarViewModel.cs | 8 +- .../Windows/MonacoWindowViewModel.cs | 10 +- .../Windows/SandboxWindowViewModel.cs | 2 +- .../DialogsAndFlyouts/ContentDialog.xaml.cs | 1 - .../DialogsAndFlyoutsPage.xaml.cs | 1 - .../DialogsAndFlyouts/FlyoutPage.xaml.cs | 1 - .../DialogsAndFlyouts/MessageBoxPage.xaml.cs | 1 - .../DialogsAndFlyouts/SnackbarPage.xaml.cs | 1 - .../Views/Pages/Layout/CardActionPage.xaml.cs | 14 - .../Views/Pages/Layout/LayoutPage.xaml.cs | 1 - .../Views/Pages/Text/LabelPage.xaml.cs | 1 - .../Views/Pages/Text/NumberBoxPage.xaml.cs | 1 - .../Views/Pages/Text/PasswordBoxPage.xaml.cs | 1 - .../Views/Pages/Text/RichTextBoxPage.xaml.cs | 1 - .../Views/Pages/Text/TextBlockPage.xaml.cs | 1 - .../Views/Pages/Text/TextBoxPage.xaml.cs | 1 - .../Views/Windows/EditorWindow.xaml.cs | 398 +++++++++--------- .../Views/Windows/MainWindow.xaml.cs | 8 +- .../Views/Windows/SandboxWindow.xaml.cs | 11 +- src/Wpf.Ui.SyntaxHighlight/Highlighter.cs | 45 +- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 2 +- src/Wpf.Ui.Tray/Hicon.cs | 13 +- src/Wpf.Ui.Tray/Interop/Shell32.cs | 10 +- src/Wpf.Ui.Tray/Interop/User32.cs | 10 +- ...IconEvent.cs => NotifyIconEventHandler.cs} | 0 src/Wpf.Ui.Tray/TrayHandler.cs | 4 +- .../Animations/TransitionAnimationProvider.cs | 2 +- .../Controls/ContextMenu/ContextMenu.xaml | 2 +- .../Controls/ContextMenu/ContextMenu.xaml.cs | 2 +- .../NavigationView.Navigation.cs | 8 +- .../NavigationView/NavigationViewActivator.cs | 11 +- .../Controls/SplitButton/SplitButton.cs | 2 +- .../Controls/SplitButton/SplitButton.xaml | 2 +- src/Wpf.Ui/INavigationService.cs | 6 +- src/Wpf.Ui/NavigationService.cs | 4 +- 77 files changed, 507 insertions(+), 477 deletions(-) rename src/Wpf.Ui.Tray/{NotifyIconEvent.cs => NotifyIconEventHandler.cs} (100%) diff --git a/src/Wpf.Ui.Demo.Console/Program.cs b/src/Wpf.Ui.Demo.Console/Program.cs index 515e5e98a..f49dc953f 100644 --- a/src/Wpf.Ui.Demo.Console/Program.cs +++ b/src/Wpf.Ui.Demo.Console/Program.cs @@ -3,11 +3,15 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Diagnostics; + public static class Program { [STAThread] public static void Main(string[] args) { + Debug.WriteLine("Args: " + string.Join(", ", args)); + if (Application.Current is null) { Console.WriteLine($"Application.Current is null."); diff --git a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs index 1152f4ddd..80034b7df 100644 --- a/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs +++ b/src/Wpf.Ui.Demo.Console/Utilities/ThemeUtilities.cs @@ -12,7 +12,7 @@ public static void ApplyTheme(this FrameworkElement frameworkElement) { ApplicationThemeManager.Apply(frameworkElement); - ThemeChangedEvent themeChanged = (sender, args) => + void themeChanged(ApplicationTheme sender, Color args) { ApplicationThemeManager.Apply(frameworkElement); if (frameworkElement is Window window) @@ -27,7 +27,7 @@ public static void ApplyTheme(this FrameworkElement frameworkElement) ); } } - }; + } if (frameworkElement.IsLoaded) { @@ -88,6 +88,7 @@ public static void ChangeTheme() ApplicationThemeManager.Apply(applicationTheme, updateAccent: false); } + /* /// /// Applies Resources in the . /// @@ -131,4 +132,5 @@ private static void Apply(FrameworkElement frameworkElement) frameworkElement.Resources[resource.Key] = resource.Value; } } + */ } diff --git a/src/Wpf.Ui.Demo.Console/Views/Pages/DataPage.xaml.cs b/src/Wpf.Ui.Demo.Console/Views/Pages/DataPage.xaml.cs index 023c4dc75..fc2055e05 100644 --- a/src/Wpf.Ui.Demo.Console/Views/Pages/DataPage.xaml.cs +++ b/src/Wpf.Ui.Demo.Console/Views/Pages/DataPage.xaml.cs @@ -30,6 +30,7 @@ private void InitializeData() var random = new Random(); for (int i = 0; i < 8192; i++) + { ColorsCollection.Add( new DataColor { @@ -43,5 +44,6 @@ private void InitializeData() ) } ); + } } } diff --git a/src/Wpf.Ui.Demo.Console/Views/Pages/SettingsPage.xaml.cs b/src/Wpf.Ui.Demo.Console/Views/Pages/SettingsPage.xaml.cs index e8e900114..f0dc451e2 100644 --- a/src/Wpf.Ui.Demo.Console/Views/Pages/SettingsPage.xaml.cs +++ b/src/Wpf.Ui.Demo.Console/Views/Pages/SettingsPage.xaml.cs @@ -43,6 +43,6 @@ private void OnDarkThemeRadioButtonChecked(object sender, RoutedEventArgs e) private string GetAssemblyVersion() { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() - ?? String.Empty; + ?? string.Empty; } } diff --git a/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs b/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs index 0d7e98bef..eaf149880 100644 --- a/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs +++ b/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs @@ -3,13 +3,7 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System.Windows; - [assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located -//(used if a resource is not found in the page, -// app, or any theme specific resource dictionaries) + ResourceDictionaryLocation.None, // Where theme specific resource dictionaries are located (used if a resource is not found in the page, or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly // Where the generic resource dictionary is located (used if a resource is not found in the page, app, or any theme specific resource dictionaries) )] diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs index 08e56af05..00526eb12 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs @@ -13,7 +13,7 @@ public partial class MainWindowViewModel : ObservableObject private bool _isInitialized = false; [ObservableProperty] - private string _applicationTitle = String.Empty; + private string _applicationTitle = string.Empty; [ObservableProperty] private ObservableCollection _navigationItems = new(); @@ -24,18 +24,21 @@ public partial class MainWindowViewModel : ObservableObject [ObservableProperty] private ObservableCollection _trayMenuItems = new(); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Demo")] public MainWindowViewModel(INavigationService navigationService) { if (!_isInitialized) + { InitializeViewModel(); + } } private void InitializeViewModel() { ApplicationTitle = "WPF UI - MVVM Demo"; - NavigationItems = new ObservableCollection - { + NavigationItems = + [ new NavigationViewItem() { Content = "Home", @@ -47,23 +50,23 @@ private void InitializeViewModel() Content = "Data", Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 }, TargetPageType = typeof(Views.Pages.DataPage) - } - }; + }, + ]; - NavigationFooter = new ObservableCollection - { + NavigationFooter = + [ new NavigationViewItem() { Content = "Settings", Icon = new SymbolIcon { Symbol = SymbolRegular.Settings24 }, TargetPageType = typeof(Views.Pages.SettingsPage) - } - }; + }, + ]; - TrayMenuItems = new ObservableCollection - { - new MenuItem { Header = "Home", Tag = "tray_home" } - }; + TrayMenuItems = + [ + new() { Header = "Home", Tag = "tray_home" } + ]; _isInitialized = true; } diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs index d9dcaae14..3d6f6f613 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs @@ -38,7 +38,7 @@ private void InitializeViewModel() _isInitialized = true; } - private string GetAssemblyVersion() + private static string GetAssemblyVersion() { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty; diff --git a/src/Wpf.Ui.Gallery/App.xaml.cs b/src/Wpf.Ui.Gallery/App.xaml.cs index 5a9d7528b..b211e99cb 100644 --- a/src/Wpf.Ui.Gallery/App.xaml.cs +++ b/src/Wpf.Ui.Gallery/App.xaml.cs @@ -13,7 +13,6 @@ namespace Wpf.Ui.Gallery; -#pragma warning disable IDE0058 // Expression value is never used public partial class App { // The .NET Generic Host provides dependency injection, configuration, logging, and other services. @@ -92,4 +91,3 @@ private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledEx // For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0 } } -#pragma warning restore IDE0058 // Expression value is never used diff --git a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs index f42b9506e..fb0161eb6 100644 --- a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs +++ b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs @@ -16,7 +16,7 @@ public class MonacoController private const string EditorObject = "wpfUiMonacoEditor"; - private volatile WebView2 _webView; + private readonly WebView2 _webView; public MonacoController(WebView2 webView) { diff --git a/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml.cs b/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml.cs index 0f0905cb8..218613d1e 100644 --- a/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml.cs @@ -10,6 +10,7 @@ namespace Wpf.Ui.Gallery.Controls; [ContentProperty(nameof(ExampleContent))] public class ControlExample : Control { + /// Identifies the dependency property. public static readonly DependencyProperty HeaderTextProperty = DependencyProperty.Register( nameof(HeaderText), typeof(string), @@ -17,6 +18,7 @@ public class ControlExample : Control new PropertyMetadata(null) ); + /// Identifies the dependency property. public static readonly DependencyProperty ExampleContentProperty = DependencyProperty.Register( nameof(ExampleContent), typeof(object), @@ -24,6 +26,7 @@ public class ControlExample : Control new PropertyMetadata(null) ); + /// Identifies the dependency property. public static readonly DependencyProperty XamlCodeProperty = DependencyProperty.Register( nameof(XamlCode), typeof(string), @@ -31,16 +34,20 @@ public class ControlExample : Control new PropertyMetadata(null) ); + /// Identifies the dependency property. public static readonly DependencyProperty XamlCodeSourceProperty = DependencyProperty.Register( nameof(XamlCodeSource), typeof(Uri), typeof(ControlExample), new PropertyMetadata( null, - static (o, args) => ((ControlExample)o).OnXamlCodeSourceChanged((Uri)args.NewValue) - ) + static (o, args) => + { + ((ControlExample)o).OnXamlCodeSourceChanged((Uri?)args.NewValue); + }) ); + /// Identifies the dependency property. public static readonly DependencyProperty CsharpCodeProperty = DependencyProperty.Register( nameof(CsharpCode), typeof(string), @@ -48,19 +55,22 @@ public class ControlExample : Control new PropertyMetadata(null) ); + /// Identifies the dependency property. public static readonly DependencyProperty CsharpCodeSourceProperty = DependencyProperty.Register( nameof(CsharpCodeSource), typeof(Uri), typeof(ControlExample), new PropertyMetadata( null, - static (o, args) => ((ControlExample)o).OnCsharpCodeSourceChanged((Uri)args.NewValue) - ) + static (o, args) => + { + ((ControlExample)o).OnCsharpCodeSourceChanged((Uri?)args.NewValue); + }) ); public string? HeaderText { - get => (string)GetValue(HeaderTextProperty); + get => (string?)GetValue(HeaderTextProperty); set => SetValue(HeaderTextProperty, value); } @@ -72,45 +82,45 @@ public object? ExampleContent public string? XamlCode { - get => (string)GetValue(XamlCodeProperty); + get => (string?)GetValue(XamlCodeProperty); set => SetValue(XamlCodeProperty, value); } public Uri? XamlCodeSource { - get => (Uri)GetValue(XamlCodeSourceProperty); + get => (Uri?)GetValue(XamlCodeSourceProperty); set => SetValue(XamlCodeSourceProperty, value); } public string? CsharpCode { - get => (string)GetValue(CsharpCodeProperty); + get => (string?)GetValue(CsharpCodeProperty); set => SetValue(CsharpCodeProperty, value); } public Uri? CsharpCodeSource { - get => (Uri)GetValue(CsharpCodeSourceProperty); + get => (Uri?)GetValue(CsharpCodeSourceProperty); set => SetValue(CsharpCodeSourceProperty, value); } - private void OnXamlCodeSourceChanged(Uri uri) + private void OnXamlCodeSourceChanged(Uri? uri) { - XamlCode = LoadResource(uri); + SetCurrentValue(XamlCodeProperty, LoadResource(uri)); } - private void OnCsharpCodeSourceChanged(Uri uri) + private void OnCsharpCodeSourceChanged(Uri? uri) { - CsharpCode = LoadResource(uri); + SetCurrentValue(CsharpCodeProperty, LoadResource(uri)); } - private static string LoadResource(Uri uri) + private static string LoadResource(Uri? uri) { try { - if (Application.GetResourceStream(uri) is not { } steamInfo) + if (uri is null || Application.GetResourceStream(uri) is not { } steamInfo) { - return String.Empty; + return string.Empty; } using StreamReader streamReader = new(steamInfo.Stream, Encoding.UTF8); diff --git a/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs b/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs index 28c1b652a..9dddc090c 100644 --- a/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs @@ -7,9 +7,7 @@ namespace Wpf.Ui.Gallery.Controls; public class GalleryNavigationPresenter : System.Windows.Controls.Control { - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( nameof(ItemsSource), typeof(object), @@ -17,9 +15,7 @@ public class GalleryNavigationPresenter : System.Windows.Controls.Control new PropertyMetadata(null) ); - /// - /// Property for . - /// + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(Wpf.Ui.Input.IRelayCommand), diff --git a/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs b/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs index 2c6416377..2f65580bd 100644 --- a/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs @@ -13,27 +13,42 @@ public class PageControlDocumentation : Control public static readonly DependencyProperty ShowProperty = DependencyProperty.RegisterAttached( "Show", typeof(bool), - typeof(FrameworkElement), + typeof(PageControlDocumentation), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender) ); public static readonly DependencyProperty DocumentationTypeProperty = DependencyProperty.RegisterAttached( "DocumentationType", typeof(Type), - typeof(FrameworkElement), + typeof(PageControlDocumentation), new FrameworkPropertyMetadata(null) ); + /// Helper for getting from . + /// to read from. + /// Show property value. + [AttachedPropertyBrowsableForType(typeof(FrameworkElement))] public static bool GetShow(FrameworkElement target) => (bool)target.GetValue(ShowProperty); + /// Helper for setting on . + /// to set on. + /// Show property value. public static void SetShow(FrameworkElement target, bool show) => target.SetValue(ShowProperty, show); + /// Helper for getting from . + /// to read from. + /// DocumentationType property value. + [AttachedPropertyBrowsableForType(typeof(FrameworkElement))] public static Type? GetDocumentationType(FrameworkElement target) => (Type?)target.GetValue(DocumentationTypeProperty); - public static void SetDocumentationType(FrameworkElement target, Type type) => + /// Helper for setting on . + /// to set on. + /// DocumentationType property value. + public static void SetDocumentationType(FrameworkElement target, Type? type) => target.SetValue(DocumentationTypeProperty, type); + /// Identifies the dependency property. public static readonly DependencyProperty NavigationViewProperty = DependencyProperty.Register( nameof(NavigationView), typeof(INavigationView), @@ -41,6 +56,7 @@ public static void SetDocumentationType(FrameworkElement target, Type type) => new FrameworkPropertyMetadata(null) ); + /// Identifies the dependency property. public static readonly DependencyProperty IsDocumentationLinkVisibleProperty = DependencyProperty.Register( nameof(IsDocumentationLinkVisible), @@ -49,6 +65,7 @@ public static void SetDocumentationType(FrameworkElement target, Type type) => new FrameworkPropertyMetadata(Visibility.Collapsed) ); + /// Identifies the dependency property. public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(ICommand), @@ -58,7 +75,7 @@ public static void SetDocumentationType(FrameworkElement target, Type type) => public INavigationView? NavigationView { - get => (INavigationView)GetValue(NavigationViewProperty); + get => (INavigationView?)GetValue(NavigationViewProperty); set => SetValue(NavigationViewProperty, value); } @@ -86,7 +103,9 @@ public PageControlDocumentation() private void OnLoaded() { if (NavigationView is null) + { throw new ArgumentNullException(nameof(NavigationView)); + } NavigationView.Navigated += NavigationViewOnNavigated; } @@ -99,26 +118,26 @@ private void OnUnloaded() private void NavigationViewOnNavigated(NavigationView sender, NavigatedEventArgs args) { - IsDocumentationLinkVisible = Visibility.Collapsed; + SetCurrentValue(IsDocumentationLinkVisibleProperty, Visibility.Collapsed); if (args.Page is not FrameworkElement page || !GetShow(page)) { - Visibility = Visibility.Collapsed; + SetCurrentValue(VisibilityProperty, Visibility.Collapsed); return; } _page = page; - Visibility = Visibility.Visible; + SetCurrentValue(VisibilityProperty, Visibility.Visible); if (GetDocumentationType(page) is not null) { - IsDocumentationLinkVisible = Visibility.Visible; + SetCurrentValue(IsDocumentationLinkVisibleProperty, Visibility.Visible); } } private void OnClick(string? param) { - if (String.IsNullOrWhiteSpace(param) || _page is null) + if (string.IsNullOrWhiteSpace(param) || _page is null) { return; } @@ -136,10 +155,10 @@ private void OnClick(string? param) => CreateUrlForDocumentation(documentationType), "xaml" => CreateUrlForGithub(_page.GetType(), ".xaml"), "c#" => CreateUrlForGithub(_page.GetType(), ".xaml.cs"), - _ => String.Empty + _ => string.Empty }; - if (String.IsNullOrEmpty(navigationUrl)) + if (string.IsNullOrEmpty(navigationUrl)) { return; } @@ -161,7 +180,7 @@ private static string CreateUrlForGithub(Type pageType, ReadOnlySpan fileE const string baseUrl = "https://github.com/lepoco/wpfui/tree/main/src/Wpf.Ui.Gallery/"; const string baseNamespace = "Wpf.Ui.Gallery"; - var pageFullNameWithoutBaseNamespace = pageType.FullName.AsSpan().Slice(baseNamespace.Length + 1); + ReadOnlySpan pageFullNameWithoutBaseNamespace = pageType.FullName.AsSpan()[(baseNamespace.Length + 1)..]; Span pageUrl = stackalloc char[pageFullNameWithoutBaseNamespace.Length]; pageFullNameWithoutBaseNamespace.CopyTo(pageUrl); @@ -174,19 +193,19 @@ private static string CreateUrlForGithub(Type pageType, ReadOnlySpan fileE } } - return String.Concat(baseUrl, pageUrl, fileExtension); + return string.Concat(baseUrl, pageUrl, fileExtension); } private static string CreateUrlForDocumentation(Type type) { const string baseUrl = "https://wpfui.lepo.co/api/"; - return String.Concat(baseUrl, type.FullName, ".html"); + return string.Concat(baseUrl, type.FullName, ".html"); } private static void SwitchThemes() { - var currentTheme = Wpf.Ui.Appearance.ApplicationThemeManager.GetAppTheme(); + Appearance.ApplicationTheme currentTheme = Wpf.Ui.Appearance.ApplicationThemeManager.GetAppTheme(); Wpf.Ui.Appearance.ApplicationThemeManager.Apply( currentTheme == Wpf.Ui.Appearance.ApplicationTheme.Light diff --git a/src/Wpf.Ui.Gallery/Controls/TermsOfUseContentDialog.xaml.cs b/src/Wpf.Ui.Gallery/Controls/TermsOfUseContentDialog.xaml.cs index 5c3a2e764..bcc07c4f3 100644 --- a/src/Wpf.Ui.Gallery/Controls/TermsOfUseContentDialog.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/TermsOfUseContentDialog.xaml.cs @@ -23,9 +23,8 @@ protected override void OnButtonClick(ContentDialogButton button) base.OnButtonClick(button); return; } - ; - TextBlock.Visibility = Visibility.Visible; + TextBlock.SetCurrentValue(VisibilityProperty, Visibility.Visible); CheckBox.Focus(); } } diff --git a/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs b/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs index bea28d2e3..8969969b0 100644 --- a/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System.Windows; using System.Windows.Controls; using Wpf.Ui.Controls; @@ -11,6 +10,7 @@ namespace Wpf.Ui.Gallery.Controls; public class TypographyControl : Control { + /// Identifies the dependency property. public static readonly DependencyProperty ExampleProperty = DependencyProperty.Register( nameof(Example), typeof(string), @@ -18,6 +18,7 @@ public class TypographyControl : Control new PropertyMetadata(string.Empty) ); + /// Identifies the dependency property. public static readonly DependencyProperty ExampleFontTypographyProperty = DependencyProperty.Register( nameof(ExampleFontTypography), typeof(FontTypography), @@ -25,10 +26,12 @@ public class TypographyControl : Control new PropertyMetadata( FontTypography.Body, static (o, args) => - ((TypographyControl)o).OnExampleFontTypographyChanged((FontTypography)args.NewValue) - ) + { + ((TypographyControl)o).OnExampleFontTypographyChanged((FontTypography)args.NewValue); + }) ); + /// Identifies the dependency property. public static readonly DependencyProperty VariableFontProperty = DependencyProperty.Register( nameof(VariableFont), typeof(string), @@ -36,6 +39,7 @@ public class TypographyControl : Control new PropertyMetadata(string.Empty) ); + /// Identifies the dependency property. public static readonly DependencyProperty SizeLinHeightProperty = DependencyProperty.Register( nameof(SizeLinHeight), typeof(string), @@ -43,6 +47,7 @@ public class TypographyControl : Control new PropertyMetadata(string.Empty) ); + /// Identifies the dependency property. public static readonly DependencyProperty FontTypographyStyleProperty = DependencyProperty.Register( nameof(FontTypographyStyle), typeof(string), @@ -70,7 +75,7 @@ public string VariableFont public string SizeLinHeight { - get => (string)GetValue(VariableFontProperty); + get => (string)GetValue(SizeLinHeightProperty); set => SetValue(SizeLinHeightProperty, value); } @@ -82,6 +87,6 @@ public string FontTypographyStyle private void OnExampleFontTypographyChanged(FontTypography fontTypography) { - FontTypographyStyle = fontTypography.ToString(); + SetCurrentValue(FontTypographyStyleProperty, fontTypography.ToString()); } } diff --git a/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs b/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs index 48c4a0cb6..3cf39d7ba 100644 --- a/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs +++ b/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs @@ -5,24 +5,24 @@ namespace Wpf.Ui.Gallery.ControlsLookup; -static class ControlPages +internal static class ControlPages { private const string PageSuffix = "Page"; public static IEnumerable All() { foreach ( - var type in GalleryAssembly + Type? type in GalleryAssembly .Asssembly.GetTypes() .Where(t => t.IsDefined(typeof(GalleryPageAttribute))) ) { - var galleryPageAttribute = type.GetCustomAttributes().FirstOrDefault(); + GalleryPageAttribute? galleryPageAttribute = type.GetCustomAttributes().FirstOrDefault(); if (galleryPageAttribute is not null) { yield return new GalleryPage( - type.Name.Substring(0, type.Name.LastIndexOf(PageSuffix)), + type.Name[..type.Name.LastIndexOf(PageSuffix)], galleryPageAttribute.Description, galleryPageAttribute.Icon, type diff --git a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPage.cs b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPage.cs index 119ba603d..10cd73160 100644 --- a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPage.cs +++ b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPage.cs @@ -7,4 +7,4 @@ namespace Wpf.Ui.Gallery.ControlsLookup; -record GalleryPage(string Name, string Description, SymbolRegular Icon, Type PageType); +internal record GalleryPage(string Name, string Description, SymbolRegular Icon, Type PageType); diff --git a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs index 95bea27a6..a201ca741 100644 --- a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs +++ b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs @@ -8,9 +8,10 @@ namespace Wpf.Ui.Gallery.ControlsLookup; [AttributeUsage(AttributeTargets.Class)] -class GalleryPageAttribute : Attribute +internal class GalleryPageAttribute : Attribute { public string Description { get; } + public SymbolRegular Icon { get; } public GalleryPageAttribute(string description, SymbolRegular icon) diff --git a/src/Wpf.Ui.Gallery/GalleryAssembly.cs b/src/Wpf.Ui.Gallery/GalleryAssembly.cs index c78340ba0..f4f100121 100644 --- a/src/Wpf.Ui.Gallery/GalleryAssembly.cs +++ b/src/Wpf.Ui.Gallery/GalleryAssembly.cs @@ -5,7 +5,7 @@ namespace Wpf.Ui.Gallery; -class GalleryAssembly +internal class GalleryAssembly { public static Assembly Asssembly => Assembly.GetExecutingAssembly(); } diff --git a/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs b/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs index 39fb2f648..da448a069 100644 --- a/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs +++ b/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs @@ -17,6 +17,6 @@ internal sealed class NameToPageTypeConverter { pageName = pageName.Trim().ToLower() + "page"; - return PageTypes.FirstOrDefault(singlePageType => singlePageType.Name.ToLower() == pageName); + return PageTypes.FirstOrDefault(singlePageType => singlePageType.Name.Equals(pageName, StringComparison.CurrentCultureIgnoreCase)); } } diff --git a/src/Wpf.Ui.Gallery/Helpers/PaneDisplayModeToIndexConverter.cs b/src/Wpf.Ui.Gallery/Helpers/PaneDisplayModeToIndexConverter.cs index 6117988c5..23bbf4a9e 100644 --- a/src/Wpf.Ui.Gallery/Helpers/PaneDisplayModeToIndexConverter.cs +++ b/src/Wpf.Ui.Gallery/Helpers/PaneDisplayModeToIndexConverter.cs @@ -11,41 +11,23 @@ internal sealed class PaneDisplayModeToIndexConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (value is NavigationViewPaneDisplayMode.LeftFluent) + return value switch { - return 1; - } - - if (value is NavigationViewPaneDisplayMode.Top) - { - return 2; - } - - if (value is NavigationViewPaneDisplayMode.Bottom) - { - return 3; - } - - return 0; + NavigationViewPaneDisplayMode.LeftFluent => 1, + NavigationViewPaneDisplayMode.Top => 2, + NavigationViewPaneDisplayMode.Bottom => 3, + _ => 0 + }; } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { - if (value is 1) + return value switch { - return NavigationViewPaneDisplayMode.LeftFluent; - } - - if (value is 2) - { - return NavigationViewPaneDisplayMode.Top; - } - - if (value is 3) - { - return NavigationViewPaneDisplayMode.Bottom; - } - - return NavigationViewPaneDisplayMode.Left; + 1 => NavigationViewPaneDisplayMode.LeftFluent, + 2 => NavigationViewPaneDisplayMode.Top, + 3 => NavigationViewPaneDisplayMode.Bottom, + _ => NavigationViewPaneDisplayMode.Left + }; } } diff --git a/src/Wpf.Ui.Gallery/Models/Person.cs b/src/Wpf.Ui.Gallery/Models/Person.cs index 4c7416f17..11dbd7fdd 100644 --- a/src/Wpf.Ui.Gallery/Models/Person.cs +++ b/src/Wpf.Ui.Gallery/Models/Person.cs @@ -11,7 +11,7 @@ public record Person public string LastName { get; init; } - public string Name => FirstName + " " + LastName; + public string Name => $"{FirstName} {LastName}"; public string Company { get; init; } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs index e2e32330a..f836fa614 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs @@ -16,7 +16,9 @@ public partial class AnchorViewModel : ObservableObject private void OnAnchorCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsAnchorEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs index 3355c06e3..517208cd6 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs @@ -19,7 +19,9 @@ public partial class ButtonViewModel : ObservableObject private void OnSimpleButtonCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsSimpleButtonEnabled = !(checkbox?.IsChecked ?? false); } @@ -28,7 +30,9 @@ private void OnSimpleButtonCheckboxChecked(object sender) private void OnUiButtonCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsUiButtonEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs index 6e50f3837..e7fe0ecb6 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs @@ -25,12 +25,11 @@ public partial class CheckBoxViewModel : ObservableObject private void OnSelectAllChecked(object sender) { if (sender is not CheckBox checkBox) + { return; + } - if (checkBox.IsChecked == null) - checkBox.IsChecked = !( - OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked - ); + checkBox.IsChecked ??= !OptionOneCheckBoxChecked || !OptionTwoCheckBoxChecked || !OptionThreeCheckBoxChecked; if (checkBox.IsChecked == true) { @@ -49,11 +48,9 @@ private void OnSelectAllChecked(object sender) [RelayCommand] private void OnSingleChecked(string option) { - if (OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked) - SelectAllCheckBoxChecked = true; - else if (!OptionOneCheckBoxChecked && !OptionTwoCheckBoxChecked && !OptionThreeCheckBoxChecked) - SelectAllCheckBoxChecked = false; - else - SelectAllCheckBoxChecked = null; + bool allChecked = OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked; + bool allUnchecked = !OptionOneCheckBoxChecked && !OptionTwoCheckBoxChecked && !OptionThreeCheckBoxChecked; + + SelectAllCheckBoxChecked = allChecked ? true : allUnchecked ? false : (bool?)null; } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs index 6e0d1b4ed..f6922aad1 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs @@ -8,17 +8,17 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput; public partial class ComboBoxViewModel : ObservableObject { [ObservableProperty] - private IList _comboBoxFontFamilies = new ObservableCollection - { + private ObservableCollection _comboBoxFontFamilies = + [ "Arial", "Comic Sans MS", "Segoe UI", "Times New Roman" - }; + ]; [ObservableProperty] - private IList _comboBoxFontSizes = new ObservableCollection - { + private ObservableCollection _comboBoxFontSizes = + [ 8, 9, 10, @@ -33,5 +33,5 @@ public partial class ComboBoxViewModel : ObservableObject 36, 48, 72 - }; + ]; } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs index e08251a0a..4bf2bb27e 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs @@ -16,7 +16,9 @@ public partial class RadioButtonViewModel : ObservableObject private void OnRadioButtonCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsRadioButtonEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs index 6b336dca3..ade563762 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs @@ -25,7 +25,9 @@ public partial class RatingViewModel : ObservableObject private void OnFirstRatingCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsFirstRatingEnabled = !(checkbox?.IsChecked ?? false); } @@ -34,7 +36,9 @@ private void OnFirstRatingCheckboxChecked(object sender) private void OnSecondRatingCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsSecondRatingEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs index 89c1951b9..9be74eb97 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs @@ -16,13 +16,12 @@ public partial class ThumbRateViewModel : ObservableObject private string _thumRateStateCodeText = ""; private ThumbRateState _thumbRateState = ThumbRateState.Liked; + public ThumbRateState ThumbRateState { get => _thumbRateState; set { - SetProperty(ref _thumbRateState, value); - ThumRateStateText = value switch { ThumbRateState.Liked => "Liked", @@ -30,13 +29,8 @@ public ThumbRateState ThumbRateState _ => "None" }; - ThumRateStateCodeText = - $" "Liked", - ThumbRateState.Disliked => "Disliked", - _ => "None" - })}\" />"; + ThumRateStateCodeText = $""; + SetProperty(ref _thumbRateState, value); } } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs index 015b7f12a..35e216ae0 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs @@ -16,7 +16,9 @@ public partial class ToggleButtonViewModel : ObservableObject private void OnToggleButtonCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsToggleButtonEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs index f1c1b8223..0622a7f67 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs @@ -17,7 +17,7 @@ public DataGridViewModel() _productsCollection = GenerateProducts(); } - private ObservableCollection GenerateProducts() + private static ObservableCollection GenerateProducts() { var random = new Random(); var products = new ObservableCollection { }; diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs index 4a82a5c23..542904522 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs @@ -12,13 +12,13 @@ public partial class ListBoxViewModel : ObservableObject public ListBoxViewModel() { - _listBoxItems = new ObservableCollection - { + _listBoxItems = + [ "Arial", "Comic Sans MS", "Courier New", "Segoe UI", "Times New Roman" - }; + ]; } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs index 5099d5819..a515c9a3a 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs @@ -17,7 +17,7 @@ public int ListViewSelectionModeComboBoxSelectedIndex get => _listViewSelectionModeComboBoxSelectedIndex; set { - SetProperty(ref _listViewSelectionModeComboBoxSelectedIndex, value); + SetProperty(ref _listViewSelectionModeComboBoxSelectedIndex, value); UpdateListViewSelectionMode(value); } } @@ -33,7 +33,7 @@ public ListViewViewModel() _basicListViewItems = GeneratePersons(); } - private ObservableCollection GeneratePersons() + private static ObservableCollection GeneratePersons() { var random = new Random(); var persons = new ObservableCollection(); @@ -83,6 +83,7 @@ private ObservableCollection GeneratePersons() }; for (int i = 0; i < 50; i++) + { persons.Add( new Person( names[random.Next(0, names.Length)], @@ -90,6 +91,7 @@ private ObservableCollection GeneratePersons() companies[random.Next(0, companies.Length)] ) ); + } return persons; } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs index 4aaacf993..60d3d3e00 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs @@ -19,7 +19,7 @@ public DashboardViewModel(INavigationService navigationService) [RelayCommand] private void OnCardClick(string parameter) { - if (String.IsNullOrWhiteSpace(parameter)) + if (string.IsNullOrWhiteSpace(parameter)) { return; } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs index 796604395..8b85c8cea 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs @@ -13,22 +13,22 @@ public partial class IconsViewModel : ObservableObject, INavigationAware { private int _selectedIconId = 0; - private string _autoSuggestBoxText = String.Empty; + private string _autoSuggestBoxText = string.Empty; [ObservableProperty] private SymbolRegular _selectedSymbol = SymbolRegular.Empty; [ObservableProperty] - private string _selectedSymbolName = String.Empty; + private string _selectedSymbolName = string.Empty; [ObservableProperty] - private string _selectedSymbolUnicodePoint = String.Empty; + private string _selectedSymbolUnicodePoint = string.Empty; [ObservableProperty] - private string _selectedSymbolTextGlyph = String.Empty; + private string _selectedSymbolTextGlyph = string.Empty; [ObservableProperty] - private string _selectedSymbolXaml = String.Empty; + private string _selectedSymbolXaml = string.Empty; [ObservableProperty] private bool _isIconFilled = false; @@ -47,7 +47,7 @@ public string AutoSuggestBoxText get => _autoSuggestBoxText; set { - SetProperty(ref _autoSuggestBoxText, value); + SetProperty(ref _autoSuggestBoxText, value); UpdateSearchResults(value); } } @@ -64,7 +64,7 @@ public IconsViewModel() foreach (string iconName in names) { - var icon = SymbolGlyph.Parse(iconName); + SymbolRegular icon = SymbolGlyph.Parse(iconName); icons.Add( new DisplayableIcon @@ -107,7 +107,9 @@ public void OnIconSelected(int parameter) public void OnCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsIconFilled = checkbox?.IsChecked ?? false; @@ -117,23 +119,25 @@ public void OnCheckboxChecked(object sender) private void UpdateSymbolData() { if (IconsCollection.Count - 1 < _selectedIconId) + { return; + } - var selectedSymbol = IconsCollection.FirstOrDefault(sym => sym.Id == _selectedIconId); + DisplayableIcon selectedSymbol = IconsCollection.FirstOrDefault(sym => sym.Id == _selectedIconId); SelectedSymbol = selectedSymbol.Icon; SelectedSymbolName = selectedSymbol.Name; SelectedSymbolUnicodePoint = selectedSymbol.Code; SelectedSymbolTextGlyph = $"&#x{selectedSymbol.Code};"; SelectedSymbolXaml = - $""; + $""; } private void UpdateSearchResults(string searchedText) { _ = Task.Run(() => { - if (String.IsNullOrEmpty(searchedText)) + if (string.IsNullOrEmpty(searchedText)) { FilteredIconsCollection = IconsCollection; @@ -143,7 +147,7 @@ private void UpdateSearchResults(string searchedText) var formattedText = searchedText.ToLower().Trim(); FilteredIconsCollection = IconsCollection - .Where(icon => icon.Name.ToLower().Contains(formattedText)) + .Where(icon => icon.Name.Contains(formattedText, StringComparison.OrdinalIgnoreCase)) .ToArray(); return true; diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs index 18f425d81..69c0867ab 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs @@ -12,7 +12,7 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; public partial class ContentDialogViewModel(IContentDialogService contentDialogService) : ObservableObject { [ObservableProperty] - private string _dialogResultText = String.Empty; + private string _dialogResultText = string.Empty; [RelayCommand] private async Task OnShowDialog(object content) diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs index e9a1d3814..c72c3be78 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs @@ -14,6 +14,8 @@ public partial class FlyoutViewModel : ObservableObject private void OnButtonClick(object sender) { if (!IsFlyoutOpen) + { IsFlyoutOpen = true; + } } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs index 719779f30..399342763 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs @@ -3,18 +3,22 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Diagnostics.CodeAnalysis; + namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; public partial class MessageBoxViewModel : ObservableObject { + [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "relay command")] [RelayCommand] private void OnOpenStandardMessageBox(object sender) { - System.Windows.MessageBox.Show("Something about to happen", "I can feel it"); + MessageBox.Show("Something about to happen", "I can feel it"); } + [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "relay command")] [RelayCommand] - private async void OnOpenCustomMessageBox(object sender) + private async Task OnOpenCustomMessageBox(object sender) { var uiMessageBox = new Wpf.Ui.Controls.MessageBox { @@ -23,6 +27,6 @@ private async void OnOpenCustomMessageBox(object sender) "Never gonna give you up, never gonna let you down Never gonna run around and desert you Never gonna make you cry, never gonna say goodbye", }; - var result = await uiMessageBox.ShowDialogAsync(); + _ = await uiMessageBox.ShowDialogAsync(); } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs index 9738cf04d..2f35fca6e 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs @@ -21,7 +21,7 @@ public int SnackbarAppearanceComboBoxSelectedIndex get => _snackbarAppearanceComboBoxSelectedIndex; set { - SetProperty(ref _snackbarAppearanceComboBoxSelectedIndex, value); + SetProperty(ref _snackbarAppearanceComboBoxSelectedIndex, value); UpdateSnackbarAppearance(value); } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs index 922cb1026..a3a1f61af 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs @@ -9,17 +9,17 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation; public partial class BreadcrumbBarViewModel : ObservableObject { - private readonly IEnumerable _baseFoldersCollection = new Folder[] - { + private readonly IEnumerable _baseFoldersCollection = + [ new("Home"), new("Folder1"), new("Folder2"), new("Folder3"), - }; + ]; [ObservableProperty] - private ObservableCollection _strings = new ObservableCollection - { + private ObservableCollection _strings = + [ "Home", "Document", "Design", @@ -28,7 +28,7 @@ public partial class BreadcrumbBarViewModel : ObservableObject "Folder1", "Folder2", "Folder3" - }; + ]; [ObservableProperty] private ObservableCollection _folders = new ObservableCollection { }; @@ -45,17 +45,21 @@ private void OnStringSelected(object item) { } private void OnFolderSelected(object item) { if (item is not Folder selectedFolder) + { return; + } var index = Folders.IndexOf(selectedFolder); Folders.Clear(); var counter = 0; - foreach (var folder in _baseFoldersCollection) + foreach (Folder folder in _baseFoldersCollection) { if (counter++ > index) + { break; + } Folders.Add(folder); } @@ -71,7 +75,9 @@ private void ResetFoldersCollection() { Folders.Clear(); - foreach (var folder in _baseFoldersCollection) + foreach (Folder folder in _baseFoldersCollection) + { Folders.Add(folder); + } } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs index 2ab878efd..4cfb59363 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs @@ -13,37 +13,37 @@ public partial class FilePickerViewModel : ObservableObject private Visibility _openedFilePathVisibility = Visibility.Collapsed; [ObservableProperty] - private string _openedFilePath = String.Empty; + private string _openedFilePath = string.Empty; [ObservableProperty] private Visibility _openedPicturePathVisibility = Visibility.Collapsed; [ObservableProperty] - private string _openedPicturePath = String.Empty; + private string _openedPicturePath = string.Empty; [ObservableProperty] private Visibility _openedMultiplePathVisibility = Visibility.Collapsed; [ObservableProperty] - private string _openedMultiplePath = String.Empty; + private string _openedMultiplePath = string.Empty; [ObservableProperty] private Visibility _openedFolderPathVisibility = Visibility.Collapsed; [ObservableProperty] - private string _openedFolderPath = String.Empty; + private string _openedFolderPath = string.Empty; [ObservableProperty] - private string _fileToSaveName = String.Empty; + private string _fileToSaveName = string.Empty; [ObservableProperty] - private string _fileToSaveContents = String.Empty; + private string _fileToSaveContents = string.Empty; [ObservableProperty] private Visibility _savedFileNoticeVisibility = Visibility.Collapsed; [ObservableProperty] - private string _savedFileNotice = String.Empty; + private string _savedFileNotice = string.Empty; [RelayCommand] public void OnOpenFile() @@ -122,7 +122,7 @@ public void OnOpenMultiple() var fileNames = openFileDialog.FileNames; - OpenedMultiplePath = String.Join("\n", fileNames); + OpenedMultiplePath = string.Join("\n", fileNames); OpenedMultiplePathVisibility = Visibility.Visible; } @@ -149,7 +149,7 @@ public void OnOpenFolder() return; } - OpenedFolderPath = String.Join("\n", openFolderDialog.FolderNames); + OpenedFolderPath = string.Join("\n", openFolderDialog.FolderNames); OpenedFolderPathVisibility = Visibility.Visible; #else OpenedFolderPath = "OpenFolderDialog requires .NET 8 or newer"; @@ -169,12 +169,12 @@ public async Task OnSaveFile(CancellationToken cancellation) InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }; - if (!String.IsNullOrEmpty(FileToSaveName)) + if (!string.IsNullOrEmpty(FileToSaveName)) { var invalidChars = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); - saveFileDialog.FileName = String + saveFileDialog.FileName = string .Join( "_", FileToSaveName.Split(invalidChars.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs index 2fa66a1fb..5c679b4be 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs @@ -72,7 +72,7 @@ private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color syst } } - private string GetAssemblyVersion() + private static string GetAssemblyVersion() { return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty; } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs index e0066d79b..6d5885c0b 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs @@ -24,7 +24,7 @@ public int InfoBadgeSeverityComboBoxSelectedIndex } } - private InfoBadgeSeverity ConvertIndexToInfoBadgeSeverity(int value) + private static InfoBadgeSeverity ConvertIndexToInfoBadgeSeverity(int value) { return value switch { diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs index a2664617e..0e5f18ac0 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs @@ -22,30 +22,32 @@ public partial class InfoBarViewModel : ObservableObject private InfoBarSeverity _longInfoBarSeverity = InfoBarSeverity.Informational; private int _shortInfoBarSeverityComboBoxSelectedIndex = 0; + public int ShortInfoBarSeverityComboBoxSelectedIndex { get => _shortInfoBarSeverityComboBoxSelectedIndex; set { - SetProperty(ref _shortInfoBarSeverityComboBoxSelectedIndex, value); + SetProperty(ref _shortInfoBarSeverityComboBoxSelectedIndex, value); ShortInfoBarSeverity = ConvertIndexToInfoBarSeverity(value); } } private int _longInfoBarSeverityComboBoxSelectedIndex = 0; + public int LongInfoBarSeverityComboBoxSelectedIndex { get => _longInfoBarSeverityComboBoxSelectedIndex; set { - SetProperty(ref _longInfoBarSeverityComboBoxSelectedIndex, value); + SetProperty(ref _longInfoBarSeverityComboBoxSelectedIndex, value); LongInfoBarSeverity = ConvertIndexToInfoBarSeverity(value); } } - private InfoBarSeverity ConvertIndexToInfoBarSeverity(int value) + private static InfoBarSeverity ConvertIndexToInfoBarSeverity(int value) { return value switch { diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs index 1517e700c..799878919 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs @@ -17,11 +17,11 @@ public partial class MonacoWindowViewModel : ObservableObject public void SetWebView(WebView2 webView) { webView.NavigationCompleted += OnWebViewNavigationCompleted; - webView.UseLayoutRounding = true; - webView.DefaultBackgroundColor = System.Drawing.Color.Transparent; - webView.Source = new Uri( + webView.SetCurrentValue(FrameworkElement.UseLayoutRoundingProperty, true); + webView.SetCurrentValue(WebView2.DefaultBackgroundColorProperty, System.Drawing.Color.Transparent); + webView.SetCurrentValue(WebView2.SourceProperty, new Uri( System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"Assets\Monaco\index.html") - ); + )); _monacoController = new MonacoController(webView); } @@ -52,7 +52,7 @@ Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e DispatchAsync(InitializeEditorAsync); } - private DispatcherOperation DispatchAsync(Func callback) + private static DispatcherOperation DispatchAsync(Func callback) { return Application.Current.Dispatcher.InvokeAsync(callback); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs index 57011bb4a..2ebbc22bb 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs @@ -8,5 +8,5 @@ namespace Wpf.Ui.Gallery.ViewModels.Windows; public partial class SandboxWindowViewModel : ObservableObject { [ObservableProperty] - public string? _autoSuggestBoxText; + private string? _autoSuggestBoxText; } diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/ContentDialog.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/ContentDialog.xaml.cs index be60b6e58..ce58619bd 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/ContentDialog.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/ContentDialog.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/DialogsAndFlyoutsPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/DialogsAndFlyoutsPage.xaml.cs index f1c0640b0..66a162779 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/DialogsAndFlyoutsPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/DialogsAndFlyoutsPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml.cs index c7d3b6625..463f5bd36 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/MessageBoxPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/MessageBoxPage.xaml.cs index 9f69c5b96..5fc81e8d1 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/MessageBoxPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/MessageBoxPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/SnackbarPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/SnackbarPage.xaml.cs index 33c1b8662..cdf8ea319 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/SnackbarPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/SnackbarPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Layout/CardActionPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Layout/CardActionPage.xaml.cs index 4715e9817..ab41da6d3 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Layout/CardActionPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Layout/CardActionPage.xaml.cs @@ -3,20 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Layout; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml.cs index 125c16a9b..c5a7469e7 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Layout/LayoutPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ViewModels.Pages.Layout; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/LabelPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/LabelPage.xaml.cs index 519d6e82b..12e94dc9b 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/LabelPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/LabelPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/NumberBoxPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/NumberBoxPage.xaml.cs index f0df69a10..cfd1aab94 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/NumberBoxPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/NumberBoxPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/PasswordBoxPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/PasswordBoxPage.xaml.cs index d44310ffb..9989f9579 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/PasswordBoxPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/PasswordBoxPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/RichTextBoxPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/RichTextBoxPage.xaml.cs index 97c35fd8f..fb24632e6 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/RichTextBoxPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/RichTextBoxPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBlockPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBlockPage.xaml.cs index 164c43ca2..25476cfd1 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBlockPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBlockPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBoxPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBoxPage.xaml.cs index 25cadbcc0..a6fb31045 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBoxPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Text/TextBoxPage.xaml.cs @@ -3,7 +3,6 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. - using Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Text; diff --git a/src/Wpf.Ui.Gallery/Views/Windows/EditorWindow.xaml.cs b/src/Wpf.Ui.Gallery/Views/Windows/EditorWindow.xaml.cs index ecce5d38b..d390d88fc 100644 --- a/src/Wpf.Ui.Gallery/Views/Windows/EditorWindow.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Windows/EditorWindow.xaml.cs @@ -19,203 +19,205 @@ public EditorWindow(EditorWindowViewModel viewModel) InitializeComponent(); } - // internal class EditorDataStack : INotifyPropertyChanged - // { - // public event PropertyChangedEventHandler PropertyChanged; - - // protected void OnPropertyChanged(string name) - // { - // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - // } - - // private int - // _line = 1, - // _character = 0, - // _progress = 80; - - // private string _file = "Draft"; - - // public int Line - // { - // get => _line; - // set - // { - // if (value == _line) - // return; - // _line = value; - // OnPropertyChanged(nameof(Line)); - // } - // } - - // public int Character - // { - // get => _character; - // set - // { - // if (value == _character) - // return; - // _character = value; - // OnPropertyChanged(nameof(Character)); - // } - // } - - // public int Progress - // { - // get => _progress; - // set - // { - // if (value == _progress) - // return; - // _progress = value; - // OnPropertyChanged(nameof(Progress)); - // } - // } - - // public string File - // { - // get => _file; - // set - // { - // if (value == _file) - // return; - // _file = value; - // OnPropertyChanged(nameof(File)); - // } - // } - // } - - // private EditorDataStack DataStack = new(); - - // public string Line { get; set; } = "0"; - - // public EditorWindow(EditorWindowViewModel viewModel) - // { - // ViewModel = viewModel; - - // InitializeComponent(); - - // DataContext = DataStack; - // } - - // private void MenuItem_OnClick(object sender, RoutedEventArgs e) - // { - // if (sender is not MenuItem item) - // return; - - // string tag = item?.Tag as string ?? String.Empty; - - //#if DEBUG - // System.Diagnostics.Debug.WriteLine("DEBUG | Clicked: " + tag, "Wpf.Ui.Demo"); - //#endif - - // switch (tag) - // { - // case "exit": - // Close(); - - // break; - - // case "save": - // Save(); - - // break; - - // case "open": - // Open(); - - // break; - - // case "new_file": - // RootTextBox.Document = new(); - // DataStack.File = "Draft"; - - // break; - - // case "new_window": - // EditorWindow editorWindow = new(ViewModel); - // editorWindow.Owner = this; - // editorWindow.Show(); - - // break; - - // case "word_wrap": - // RootSnackbar.Title = "Word wrapping changed!"; - // RootSnackbar.Message = "Currently word wrapping is " + (item.IsChecked ? "Enabled" : "Disabled"); - // RootSnackbar.Show(); - - // break; - - // case "status_bar": - // RootStatusBar.Visibility = item.IsChecked ? Visibility.Visible : Visibility.Collapsed; - - // break; - - // default: - // ActionDialog.Show(); - - // break; - // } - // } - - // private void Save() - // { - // OpenFileDialog openFileDialog = new OpenFileDialog(); - // if (openFileDialog.ShowDialog() == true) - // { - // DataStack.File = openFileDialog.FileName; - // // Save - // } - // } - - // private void Open() - // { - // OpenFileDialog openFileDialog = new OpenFileDialog(); - // if (openFileDialog.ShowDialog() == true) - // { - // DataStack.File = openFileDialog.FileName; - // // Load - // } - // } - - // private void UpdateLine() - // { - // TextPointer caretPosition = RootTextBox.CaretPosition; - // TextPointer p = RootTextBox.Document.ContentStart.GetLineStartPosition(0); - - // RootTextBox.CaretPosition.GetLineStartPosition(-Int32.MaxValue, out int lineMoved); + /* + internal class EditorDataStack : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged(string name) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } + + private int + _line = 1, + _character = 0, + _progress = 80; + + private string _file = "Draft"; + + public int Line + { + get => _line; + set + { + if (value == _line) + return; + _line = value; + OnPropertyChanged(nameof(Line)); + } + } + + public int Character + { + get => _character; + set + { + if (value == _character) + return; + _character = value; + OnPropertyChanged(nameof(Character)); + } + } + + public int Progress + { + get => _progress; + set + { + if (value == _progress) + return; + _progress = value; + OnPropertyChanged(nameof(Progress)); + } + } + + public string File + { + get => _file; + set + { + if (value == _file) + return; + _file = value; + OnPropertyChanged(nameof(File)); + } + } + } + + private EditorDataStack DataStack = new(); + + public string Line { get; set; } = "0"; + + public EditorWindow(EditorWindowViewModel viewModel) + { + ViewModel = viewModel; + + InitializeComponent(); + + DataContext = DataStack; + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + if (sender is not MenuItem item) + return; + + string tag = item?.Tag as string ?? String.Empty; + +#if DEBUG + System.Diagnostics.Debug.WriteLine("DEBUG | Clicked: " + tag, "Wpf.Ui.Demo"); +#endif + + switch (tag) + { + case "exit": + Close(); + + break; + + case "save": + Save(); + + break; + + case "open": + Open(); + + break; + + case "new_file": + RootTextBox.Document = new(); + DataStack.File = "Draft"; + + break; + + case "new_window": + EditorWindow editorWindow = new(ViewModel); + editorWindow.Owner = this; + editorWindow.Show(); + + break; + + case "word_wrap": + RootSnackbar.Title = "Word wrapping changed!"; + RootSnackbar.Message = "Currently word wrapping is " + (item.IsChecked ? "Enabled" : "Disabled"); + RootSnackbar.Show(); + + break; - // DataStack.Line = -lineMoved; - // DataStack.Character = Math.Max(p.GetOffsetToPosition(caretPosition) - 1, 0); - // } - - // private void RootTextBox_OnGotFocus(object sender, RoutedEventArgs e) - // { - //#if DEBUG - // System.Diagnostics.Debug.WriteLine("DEBUG | Editor got focus", "Wpf.Ui.Demo.Editor"); - //#endif - // UpdateLine(); - // } - - // private void RootTextBox_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) - // { - // if (e.ClickCount > 2) - // return; - //#if DEBUG - // System.Diagnostics.Debug.WriteLine("DEBUG | Editor mouse down", "Wpf.Ui.Demo.Editor"); - //#endif - // UpdateLine(); - // } - - // private void RootTextBox_OnPreviewKeyUp(object sender, KeyEventArgs e) - // { - //#if DEBUG - // System.Diagnostics.Debug.WriteLine("DEBUG | Editor key up", "Wpf.Ui.Demo.Editor"); - //#endif - // UpdateLine(); - // } - - // private void ActionDialog_OnButtonRightClick(object sender, RoutedEventArgs e) - // { - // ActionDialog.Hide(); - // } + case "status_bar": + RootStatusBar.Visibility = item.IsChecked ? Visibility.Visible : Visibility.Collapsed; + + break; + + default: + ActionDialog.Show(); + + break; + } + } + + private void Save() + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + if (openFileDialog.ShowDialog() == true) + { + DataStack.File = openFileDialog.FileName; + // Save + } + } + + private void Open() + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + if (openFileDialog.ShowDialog() == true) + { + DataStack.File = openFileDialog.FileName; + // Load + } + } + + private void UpdateLine() + { + TextPointer caretPosition = RootTextBox.CaretPosition; + TextPointer p = RootTextBox.Document.ContentStart.GetLineStartPosition(0); + + RootTextBox.CaretPosition.GetLineStartPosition(-Int32.MaxValue, out int lineMoved); + + DataStack.Line = -lineMoved; + DataStack.Character = Math.Max(p.GetOffsetToPosition(caretPosition) - 1, 0); + } + + private void RootTextBox_OnGotFocus(object sender, RoutedEventArgs e) + { +#if DEBUG + System.Diagnostics.Debug.WriteLine("DEBUG | Editor got focus", "Wpf.Ui.Demo.Editor"); +#endif + UpdateLine(); + } + + private void RootTextBox_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + if (e.ClickCount > 2) + return; +#if DEBUG + System.Diagnostics.Debug.WriteLine("DEBUG | Editor mouse down", "Wpf.Ui.Demo.Editor"); +#endif + UpdateLine(); + } + + private void RootTextBox_OnPreviewKeyUp(object sender, KeyEventArgs e) + { +#if DEBUG + System.Diagnostics.Debug.WriteLine("DEBUG | Editor key up", "Wpf.Ui.Demo.Editor"); +#endif + UpdateLine(); + } + + private void ActionDialog_OnButtonRightClick(object sender, RoutedEventArgs e) + { + ActionDialog.Hide(); + } + */ } diff --git a/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml.cs b/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml.cs index c6162052f..6773a997a 100644 --- a/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Windows/MainWindow.xaml.cs @@ -47,10 +47,12 @@ private void OnNavigationSelectionChanged(object sender, RoutedEventArgs e) return; } - NavigationView.HeaderVisibility = + NavigationView.SetCurrentValue( + NavigationView.HeaderVisibilityProperty, navigationView.SelectedItem?.TargetPageType != typeof(DashboardPage) ? Visibility.Visible - : Visibility.Collapsed; + : Visibility.Collapsed + ); } private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) @@ -61,7 +63,7 @@ private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) } _isPaneOpenedOrClosedFromCode = true; - NavigationView.IsPaneOpen = !(e.NewSize.Width <= 1200); + NavigationView.SetCurrentValue(NavigationView.IsPaneOpenProperty, e.NewSize.Width > 1200); _isPaneOpenedOrClosedFromCode = false; } diff --git a/src/Wpf.Ui.Gallery/Views/Windows/SandboxWindow.xaml.cs b/src/Wpf.Ui.Gallery/Views/Windows/SandboxWindow.xaml.cs index 9200ac630..c18264dc5 100644 --- a/src/Wpf.Ui.Gallery/Views/Windows/SandboxWindow.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Windows/SandboxWindow.xaml.cs @@ -22,10 +22,13 @@ public SandboxWindow(SandboxWindowViewModel viewModel) MyTestNavigationView.Loaded += (sender, args) => { - MyTestNavigationView.MenuItemsSource = new ObservableCollection() - { - new NavigationViewItem("Home", SymbolRegular.Home24, typeof(SamplePage1)) - }; + MyTestNavigationView.SetCurrentValue( + NavigationView.MenuItemsSourceProperty, + new ObservableCollection() + { + new NavigationViewItem("Home", SymbolRegular.Home24, typeof(SamplePage1)) + } + ); var configurationBasedLogic = true; diff --git a/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs b/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs index 498d5d709..47f3ba5e0 100644 --- a/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs +++ b/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs @@ -2,6 +2,8 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// TODO: This class is work in progress. using System; using System.Linq; @@ -12,8 +14,6 @@ namespace Wpf.Ui.SyntaxHighlight; -// TODO: This class is work in progress. - /// /// Formats a string of code into control. /// Implementation and regex patterns inspired by . @@ -38,17 +38,17 @@ internal static class Highlighter private const string EntityPattern = /* language=regex */ @"(&[a-zA-Z0-9#]+;)"; - private const string PunctuationPattern = /* language=regex */ - @"(!==?|(?:[[\\] ()\{\}.:;,+\\-?=!]|<|>)+|&&|\\|\\|)"; + //private const string PunctuationPattern = /* language=regex */ + // @"(!==?|(?:[[\\] ()\{\}.:;,+\\-?=!]|<|>)+|&&|\\|\\|)"; - private const string NumberPattern = /* language=regex */ - @"(-? (?:\.\d+|\d+(?:\.\d+)?))"; + //private const string NumberPattern = /* language=regex */ + // @"(-? (?:\.\d+|\d+(?:\.\d+)?))"; - private const string BooleanPattern = /* language=regex */ - "\b(true|false)\b"; + //private const string BooleanPattern = /* language=regex */ + // "\b(true|false)\b"; - private const string AttributePattern = /* language=regex */ - "(\\s*)([a-zA-Z\\d\\-:]+)=(\" | ')(.*?)\\3"; + //private const string AttributePattern = /* language=regex */ + // "(\\s*)([a-zA-Z\\d\\-:]+)=(\" | ')(.*?)\\3"; public static Paragraph FormatAsParagraph( string code, @@ -60,22 +60,26 @@ public static Paragraph FormatAsParagraph( bool lightTheme = IsLightTheme(); - foreach (Match match in rgx.Matches(code)) + foreach (Match match in rgx.Matches(code).Cast()) { foreach (object group in match.Groups) { // Remove whole matches if (group is Match) + { continue; + } // Cast to group Group codeMatched = (Group)group; // Remove empty groups - if (String.IsNullOrEmpty(codeMatched.Value)) + if (string.IsNullOrEmpty(codeMatched.Value)) + { continue; + } - if (codeMatched.Value.Contains("\t")) + if (codeMatched.Value.Contains('\t')) { paragraph.Inlines.Add(Line(" ", Brushes.Transparent)); } @@ -83,13 +87,13 @@ public static Paragraph FormatAsParagraph( { paragraph.Inlines.Add(Line(codeMatched.Value, Brushes.Orange)); } - else if (codeMatched.Value.Contains("<") || codeMatched.Value.Contains(">")) + else if (codeMatched.Value.Contains('<') || codeMatched.Value.Contains('>')) { paragraph.Inlines.Add( Line(codeMatched.Value, lightTheme ? Brushes.DarkCyan : Brushes.CornflowerBlue) ); } - else if (codeMatched.Value.Contains("\"")) + else if (codeMatched.Value.Contains('"')) { string[] attributeArray = codeMatched.Value.Split('"'); attributeArray = attributeArray.Where(x => !string.IsNullOrEmpty(x.Trim())).ToArray(); @@ -120,7 +124,7 @@ public static Paragraph FormatAsParagraph( ); } } - else if (codeMatched.Value.Contains("'")) + else if (codeMatched.Value.Contains('\'')) { string[] attributeArray = codeMatched.Value.Split('\''); attributeArray = attributeArray.Where(x => !string.IsNullOrEmpty(x.Trim())).ToArray(); @@ -186,18 +190,23 @@ private static bool IsLightTheme() return Appearance.ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light; } + /* private static string GetPattern(SyntaxLanguage language) { - return GetPattern(language, String.Empty); + return GetPattern(language, string.Empty); } + */ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "WIP")] private static string GetPattern(SyntaxLanguage language, string code) { - var pattern = String.Empty; + var pattern = string.Empty; // TODO: Auto detected if (language == SyntaxLanguage.Autodetect) + { language = SyntaxLanguage.XAML; + } switch (language) { diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 90f4db9d9..3a50c7760 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -28,7 +28,7 @@ namespace Wpf.Ui.Tray.Controls; /// </tray:NotifyIcon> /// /// -public class NotifyIcon : System.Windows.FrameworkElement +public class NotifyIcon : System.Windows.FrameworkElement, IDisposable { private readonly Wpf.Ui.Tray.Internal.InternalNotifyIconManager internalNotifyIconManager; diff --git a/src/Wpf.Ui.Tray/Hicon.cs b/src/Wpf.Ui.Tray/Hicon.cs index c676177f0..046b9a592 100644 --- a/src/Wpf.Ui.Tray/Hicon.cs +++ b/src/Wpf.Ui.Tray/Hicon.cs @@ -2,6 +2,9 @@ // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +// +// TODO: This class is the only reason for using System.Drawing.Common. +// It is worth looking for a way to get hIcon without using it. using System; using System.Diagnostics; @@ -12,8 +15,6 @@ namespace Wpf.Ui.Tray; -// TODO: This class is the only reason for using System.Drawing.Common. It is worth looking for a way to get hIcon without using it. - /// /// Facilitates the creation of a hIcon. /// @@ -22,14 +23,13 @@ internal static class Hicon /// /// Tries to take the icon pointer assigned to the application. /// - /// public static IntPtr FromApp() { try { var processName = Process.GetCurrentProcess().MainModule?.FileName; - if (String.IsNullOrEmpty(processName)) + if (string.IsNullOrEmpty(processName)) { return IntPtr.Zero; } @@ -41,7 +41,7 @@ public static IntPtr FromApp() return IntPtr.Zero; } - //appIconsExtractIcon.ToBitmap(); + /*appIconsExtractIcon.ToBitmap();*/ return appIconsExtractIcon.Handle; } @@ -66,10 +66,9 @@ public static IntPtr FromApp() public static IntPtr FromSource(ImageSource source) { var hIcon = IntPtr.Zero; - var bitmapSource = source as BitmapSource; var bitmapFrame = source as BitmapFrame; - if (bitmapSource == null) + if (source is not BitmapSource bitmapSource) { #if DEBUG System.Diagnostics.Debug.WriteLine( diff --git a/src/Wpf.Ui.Tray/Interop/Shell32.cs b/src/Wpf.Ui.Tray/Interop/Shell32.cs index 741ca1c8f..65052b8e8 100644 --- a/src/Wpf.Ui.Tray/Interop/Shell32.cs +++ b/src/Wpf.Ui.Tray/Interop/Shell32.cs @@ -9,11 +9,14 @@ namespace Wpf.Ui.Tray.Interop; +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter +#pragma warning disable SA1401 // Fields should be private + /// /// The Windows UI provides users with access to a wide variety of objects necessary to run applications and manage the operating system. /// -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming internal static class Shell32 { /// @@ -174,3 +177,6 @@ public static extern int GetCurrentProcessExplicitAppUserModelID( [Out, MarshalAs(UnmanagedType.LPWStr)] out string AppID ); } + +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter +#pragma warning restore SA1401 // Fields should be private diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs index d38a22a70..6307a5af7 100644 --- a/src/Wpf.Ui.Tray/Interop/User32.cs +++ b/src/Wpf.Ui.Tray/Interop/User32.cs @@ -10,14 +10,14 @@ namespace Wpf.Ui.Tray.Interop; -/// -/// USER procedure declarations, constant definitions and macros. -/// // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter -#pragma warning disable SA1401 // Fields should be private + +/// +/// USER procedure declarations, constant definitions and macros. +/// internal static class User32 { /// @@ -1546,6 +1546,6 @@ public static extern int GetWindowCompositionAttribute( [DllImport(Libraries.User32, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)] public static extern uint GetDpiForWindow([In] HandleRef hwnd); } + #pragma warning restore SA1300 // Element should begin with upper-case letter #pragma warning restore SA1307 // Accessible fields should begin with upper-case letter -#pragma warning restore SA1401 // Fields should be private diff --git a/src/Wpf.Ui.Tray/NotifyIconEvent.cs b/src/Wpf.Ui.Tray/NotifyIconEventHandler.cs similarity index 100% rename from src/Wpf.Ui.Tray/NotifyIconEvent.cs rename to src/Wpf.Ui.Tray/NotifyIconEventHandler.cs diff --git a/src/Wpf.Ui.Tray/TrayHandler.cs b/src/Wpf.Ui.Tray/TrayHandler.cs index 1fcb0ef2e..02d7be465 100644 --- a/src/Wpf.Ui.Tray/TrayHandler.cs +++ b/src/Wpf.Ui.Tray/TrayHandler.cs @@ -14,12 +14,12 @@ namespace Wpf.Ui.Tray; internal class TrayHandler : HwndSource { /// - /// Id of the hooked element. + /// Gets or sets the id of the hooked element. /// public int ElementId { get; internal set; } /// - /// Creates a new hWnd as a child with transparency parameters, no size and in the default position. Then, it attach the default delegation to the messages it receives. + /// Initializes a new instance of the class, creating a new hWnd as a child with transparency parameters, no size, and in the default position. It attaches the default delegation to the messages it receives. /// /// The name of the created window. /// Parent of the created window. diff --git a/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs b/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs index 2ab58c2dc..652081570 100644 --- a/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs +++ b/src/Wpf.Ui/Animations/TransitionAnimationProvider.cs @@ -27,7 +27,7 @@ public static class TransitionAnimationProvider /// Selected transition type. /// Transition duration. /// Returns if the transition was applied. Otherwise . - public static bool ApplyTransition(object element, Transition type, int duration) + public static bool ApplyTransition(object? element, Transition type, int duration) { if (type == Transition.None || !HardwareAcceleration.IsSupported(RenderingTier.PartialAcceleration) diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml index 6dec26662..a6dbfc78e 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml @@ -6,7 +6,7 @@ --> diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs index f21669f15..10a7e07f6 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml.cs @@ -8,7 +8,7 @@ using System.Reflection; using System.Windows.Threading; -namespace Wpf.Ui.Styles.Controls; +namespace Wpf.Ui.Controls; /// /// Overwrites ContextMenu-Style for some UIElements (like RichTextBox) that don't take the default ContextMenu-Style by default. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 24d25f848..7930ba019 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -44,7 +44,7 @@ private readonly Dictionary< /// public virtual bool Navigate(Type pageType, object? dataContext = null) { - if (PageTypeNavigationViewsDictionary.TryGetValue(pageType, out INavigationViewItem navigationViewItem)) + if (PageTypeNavigationViewsDictionary.TryGetValue(pageType, out INavigationViewItem? navigationViewItem)) { return NavigateInternal(navigationViewItem, dataContext); } @@ -55,7 +55,7 @@ public virtual bool Navigate(Type pageType, object? dataContext = null) /// public virtual bool Navigate(string pageIdOrTargetTag, object? dataContext = null) { - if (PageIdOrTargetTagNavigationViewsDictionary.TryGetValue(pageIdOrTargetTag, out INavigationViewItem navigationViewItem)) + if (PageIdOrTargetTagNavigationViewsDictionary.TryGetValue(pageIdOrTargetTag, out INavigationViewItem? navigationViewItem)) { return NavigateInternal(navigationViewItem, dataContext); } @@ -398,7 +398,7 @@ private void UpdateCurrentNavigationStackItem(INavigationViewItem viewItem) private void RecreateNavigationStackFromHistory(INavigationViewItem item) { - List historyList; + List? historyList; if (!_complexNavigationStackHistory.TryGetValue(item, out historyList) || historyList.Count == 0) { return; @@ -445,7 +445,7 @@ private void AddToNavigationStackHistory(INavigationViewItem viewItem) startIndex = 0; } - List historyList; + List? historyList; if (!_complexNavigationStackHistory.TryGetValue(lastItem, out historyList)) { historyList = new List(5); diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs index 8521bb04f..9f7053096 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewActivator.cs @@ -135,16 +135,11 @@ internal static class NavigationViewActivator private static FrameworkElement? InvokeElementConstructor(Type tPage, object? dataContext) { - ConstructorInfo ctor = dataContext is null + ConstructorInfo? ctor = dataContext is null ? tPage.GetConstructor(Type.EmptyTypes) - : tPage.GetConstructor(new[] { dataContext!.GetType() }); + : tPage.GetConstructor(new[] { dataContext.GetType() }); - if (ctor != null) - { - return ctor.Invoke(new[] { dataContext }) as FrameworkElement; - } - - return null; + return ctor?.Invoke(new[] { dataContext }) as FrameworkElement; } private static ConstructorInfo? FindParameterlessConstructor(Type? tPage) diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs index 336baf80b..8d2e4aac4 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.cs @@ -18,7 +18,7 @@ public class SplitButton : Wpf.Ui.Controls.Button /// /// Template element represented by the ToggleButton name. /// - private const string TemplateElementToggleButton = "ToggleButton"; + private const string TemplateElementToggleButton = "PART_ToggleButton"; private ContextMenu? _contextMenu; diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml b/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml index eefd17936..609d86275 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml @@ -126,7 +126,7 @@ CornerRadius="{TemplateBinding CornerRadius, Converter={StaticResource RightSplitCornerRadiusConverter}}"> . /// /// of the page. - /// DataContext + /// DataContext /// if the operation succeeds. otherwise. bool Navigate(Type pageType, object? dataContext); @@ -39,7 +39,7 @@ public interface INavigationService /// Lets you navigate to the selected page based on it's tag. Should be used with . /// /// Id or tag of the page. - /// DataContext + /// DataContext /// if the operation succeeds. otherwise. bool Navigate(string pageIdOrTargetTag, object? dataContext); @@ -54,7 +54,7 @@ public interface INavigationService /// Synchronously adds an element to the navigation stack and navigates current navigation Frame to the /// /// Type of control to be synchronously added to the navigation stack - /// DataContext + /// DataContext /// if the operation succeeds. otherwise. bool NavigateWithHierarchy(Type pageType, object? dataContext); diff --git a/src/Wpf.Ui/NavigationService.cs b/src/Wpf.Ui/NavigationService.cs index 8115fa2b0..fbfe7c2b9 100644 --- a/src/Wpf.Ui/NavigationService.cs +++ b/src/Wpf.Ui/NavigationService.cs @@ -23,9 +23,9 @@ public partial class NavigationService : INavigationService private IPageService? _pageService; /// - /// Control representing navigation. + /// Gets or sets the control representing navigation. /// - protected INavigationView? NavigationControl; + protected INavigationView? NavigationControl { get; set; } /// /// Initializes a new instance of the class. From 6459d9cb43b454160bdc80eb84394850ac5b31d7 Mon Sep 17 00:00:00 2001 From: koal44 Date: Sun, 31 Mar 2024 20:32:03 -0700 Subject: [PATCH 20/33] Split ContextMenu style from its loader dictionary There were some issue when having a class called ContextMenu that wasn't actually a contextmenu but a ResourceDictionary --- src/Wpf.Ui.Gallery/GalleryAssembly.cs | 2 +- .../Pages/Navigation/BreadcrumbBarViewModel.cs | 2 +- .../Controls/ContextMenu/ContextMenu.xaml | 4 +--- .../ContextMenu/ContextMenuLoader.xaml | 11 +++++++++++ ...tMenu.xaml.cs => ContextMenuLoader.xaml.cs} | 18 ++++++++++++------ src/Wpf.Ui/Resources/Wpf.Ui.xaml | 2 +- 6 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 src/Wpf.Ui/Controls/ContextMenu/ContextMenuLoader.xaml rename src/Wpf.Ui/Controls/ContextMenu/{ContextMenu.xaml.cs => ContextMenuLoader.xaml.cs} (76%) diff --git a/src/Wpf.Ui.Gallery/GalleryAssembly.cs b/src/Wpf.Ui.Gallery/GalleryAssembly.cs index f4f100121..5173a2183 100644 --- a/src/Wpf.Ui.Gallery/GalleryAssembly.cs +++ b/src/Wpf.Ui.Gallery/GalleryAssembly.cs @@ -5,7 +5,7 @@ namespace Wpf.Ui.Gallery; -internal class GalleryAssembly +public class GalleryAssembly { public static Assembly Asssembly => Assembly.GetExecutingAssembly(); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs index a3a1f61af..2f604a6ee 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs @@ -9,7 +9,7 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation; public partial class BreadcrumbBarViewModel : ObservableObject { - private readonly IEnumerable _baseFoldersCollection = + private readonly Folder[] _baseFoldersCollection = [ new("Home"), new("Folder1"), diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml index a6dbfc78e..d627afdcb 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml @@ -6,10 +6,8 @@ --> + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">