diff --git a/.github/workflows/wpf-ui-cd-docs.yaml b/.github/workflows/wpf-ui-cd-docs.yaml index d22faf3c4..8be32dba4 100644 --- a/.github/workflows/wpf-ui-cd-docs.yaml +++ b/.github/workflows/wpf-ui-cd-docs.yaml @@ -33,10 +33,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: 18.x - - name: Setup .NET Core SDK 7.x + - name: Setup .NET Core SDK 8.x uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x + dotnet-version: 8.x - name: Install docfx run: dotnet tool update -g docfx diff --git a/.github/workflows/wpf-ui-cd-nuget.yaml b/.github/workflows/wpf-ui-cd-nuget.yaml index 65427fbe8..10e30b1dd 100644 --- a/.github/workflows/wpf-ui-cd-nuget.yaml +++ b/.github/workflows/wpf-ui-cd-nuget.yaml @@ -17,10 +17,10 @@ jobs: - uses: nuget/setup-nuget@v1 with: nuget-api-key: ${{ secrets.NUGET_API_KEY }} - - name: Setup .NET Core SDK 7.x + - name: Setup .NET Core SDK 8.x uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x + dotnet-version: 8.x - name: Install dependencies run: dotnet restore diff --git a/.github/workflows/wpf-ui-lock.yml b/.github/workflows/wpf-ui-lock.yml index 18a3a1f72..7914cce8f 100644 --- a/.github/workflows/wpf-ui-lock.yml +++ b/.github/workflows/wpf-ui-lock.yml @@ -8,7 +8,7 @@ jobs: lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v4 + - uses: dessant/lock-threads@v5 with: # https://github.com/dessant/lock-threads github-token: ${{ github.token }} diff --git a/.github/workflows/wpf-ui-pr-validator.yaml b/.github/workflows/wpf-ui-pr-validator.yaml index b8f337907..858e1626f 100644 --- a/.github/workflows/wpf-ui-pr-validator.yaml +++ b/.github/workflows/wpf-ui-pr-validator.yaml @@ -19,10 +19,10 @@ jobs: - uses: nuget/setup-nuget@v1 with: nuget-api-key: ${{ secrets.NUGET_API_KEY }} - - name: Setup .NET Core SDK 7.x + - name: Setup .NET Core SDK 8.x uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x + dotnet-version: 8.x - name: Install dependencies run: dotnet restore diff --git a/Directory.Build.props b/Directory.Build.props index c031cf77e..4657315c7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - 3.0.0-preview.9 - 11.0 + 3.0.0-preview.10 + 12.0 true @@ -20,7 +20,7 @@ - net7.0-windows;net6.0-windows;net481;net472;net462 + net8.0-windows;net7.0-windows;net6.0-windows;net481;net472;net462 diff --git a/Directory.Packages.props b/Directory.Packages.props index af80ca323..cddae1f54 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,24 +1,24 @@ - - - - - + + + + + - - - + + + - + - + - - + + diff --git a/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj b/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj index 8b5051d0f..e61101205 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj +++ b/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows10.0.22621.0 + net8.0-windows10.0.22621.0 10.0.17763.0 enable enable diff --git a/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj b/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj index 4a2e8ef82..964b9e2d9 100644 --- a/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj +++ b/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows10.0.22621.0 + net8.0-windows10.0.22621.0 10.0.17763.0 enable true diff --git a/src/Wpf.Ui.FontMapper/Wpf.Ui.FontMapper.csproj b/src/Wpf.Ui.FontMapper/Wpf.Ui.FontMapper.csproj index 70403cb84..a372ae4ac 100644 --- a/src/Wpf.Ui.FontMapper/Wpf.Ui.FontMapper.csproj +++ b/src/Wpf.Ui.FontMapper/Wpf.Ui.FontMapper.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable 10.0 diff --git a/src/Wpf.Ui.Gallery/Wpf.Ui.Gallery.csproj b/src/Wpf.Ui.Gallery/Wpf.Ui.Gallery.csproj index 424a9cd7d..ac8e882a0 100644 --- a/src/Wpf.Ui.Gallery/Wpf.Ui.Gallery.csproj +++ b/src/Wpf.Ui.Gallery/Wpf.Ui.Gallery.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows10.0.22621.0 + net8.0-windows10.0.22621.0 enable enable true diff --git a/src/Wpf.Ui/Appearance/ResourceDictionaryManager.cs b/src/Wpf.Ui/Appearance/ResourceDictionaryManager.cs index 832f82338..5f4b2fd2b 100644 --- a/src/Wpf.Ui/Appearance/ResourceDictionaryManager.cs +++ b/src/Wpf.Ui/Appearance/ResourceDictionaryManager.cs @@ -13,7 +13,7 @@ namespace Wpf.Ui.Appearance; internal class ResourceDictionaryManager { /// - /// Namespace, e.g. the library the resource is being searched for. + /// Gets the namespace, e.g. the library the resource is being searched for. /// public string SearchNamespace { get; } diff --git a/src/Wpf.Ui/Appearance/SystemTheme.cs b/src/Wpf.Ui/Appearance/SystemTheme.cs index e04ecc7ee..23cee95c1 100644 --- a/src/Wpf.Ui/Appearance/SystemTheme.cs +++ b/src/Wpf.Ui/Appearance/SystemTheme.cs @@ -51,22 +51,22 @@ public enum SystemTheme HC2, /// - /// First custom, kinda purple Windows 11 theme. + /// Dark theme: Glow /// Glow, /// - /// Second custom, kinda red Windows 11 theme. + /// Dark theme: Captured Motion /// CapturedMotion, /// - /// Third custom, kinda washed off cyan Windows 11 theme. + /// Light theme: Sunrise /// Sunrise, /// - /// Fourth custom, kinda gray Windows 11 theme. + /// Light theme: Flow /// Flow } diff --git a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs index fba0fa750..944e984f1 100644 --- a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs +++ b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs @@ -11,6 +11,16 @@ namespace Wpf.Ui.Appearance; /// /// Facilitates the management of the window background. /// +/// +/// +/// WindowBackgroundManager.UpdateBackground( +/// observedWindow.RootVisual, +/// currentApplicationTheme, +/// observedWindow.Backdrop, +/// observedWindow.ForceBackgroundReplace +/// ); +/// +/// public static class WindowBackgroundManager { /// @@ -70,11 +80,12 @@ bool forceBackground { backdrop = WindowBackdropType.None; } - else - { - _ = WindowBackdrop.RemoveBackground(window); - } + // This was required to update the background when moving from a HC theme to light/dark theme. However, this breaks theme proper light/dark theme changing on Windows 10. + // else + // { + // _ = WindowBackdrop.RemoveBackground(window); + // } _ = WindowBackdrop.ApplyBackdrop(window, backdrop); if (applicationTheme is ApplicationTheme.Dark) { diff --git a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs index a2da2b312..a4f6dc739 100644 --- a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs +++ b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +// 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. + using System.Windows.Automation; using System.Windows.Automation.Peers; using Wpf.Ui.Controls; @@ -17,7 +16,7 @@ internal class CardControlAutomationPeer : FrameworkElementAutomationPeer public CardControlAutomationPeer(CardControl owner) : base(owner) { - this._owner = owner; + _owner = owner; } protected override string GetClassNameCore() @@ -42,7 +41,7 @@ public override object GetPattern(PatternInterface patternInterface) protected override AutomationPeer GetLabeledByCore() { - if (this._owner.Header is UIElement element) + if (_owner.Header is UIElement element) { return CreatePeerForElement(element); } @@ -52,19 +51,19 @@ protected override AutomationPeer GetLabeledByCore() protected override string GetNameCore() { - string result = base.GetNameCore() ?? String.Empty; + var result = base.GetNameCore() ?? String.Empty; if (result == String.Empty) { - result = AutomationProperties.GetName(this._owner); + result = AutomationProperties.GetName(_owner); } - if (result == String.Empty && this._owner.Header is DependencyObject d) + if (result == String.Empty && _owner.Header is DependencyObject d) { result = AutomationProperties.GetName(d); } - if (result == String.Empty && this._owner.Header is string s) + if (result == String.Empty && _owner.Header is string s) { result = s; } diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs index 6d5e325df..0b4117c0c 100644 --- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs +++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs @@ -677,12 +677,13 @@ protected virtual void OnLoaded() private Size GetNewDialogSize(Size desiredSize) { var paddingWidth = Padding.Left + Padding.Right; + var paddingHeight = Padding.Top + Padding.Bottom; var marginHeight = DialogMargin.Bottom + DialogMargin.Top; var marginWidth = DialogMargin.Left + DialogMargin.Right; var width = desiredSize.Width - marginWidth + paddingWidth; - var height = desiredSize.Height - marginHeight; + var height = desiredSize.Height - marginHeight + paddingHeight; return new Size(width, height); } diff --git a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs index 5cef3edc7..86c6a2fd0 100644 --- a/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs +++ b/src/Wpf.Ui/Controls/TextBlock/TextBlock.cs @@ -14,13 +14,6 @@ namespace Wpf.Ui.Controls; /// public class TextBlock : System.Windows.Controls.TextBlock { - static TextBlock() - { - TextElement - .FontSizeProperty - .OverrideMetadata(typeof(System.Windows.Controls.TextBlock), new FrameworkPropertyMetadata(14.0)); - } - /// /// Property for . /// diff --git a/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml b/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml index 8493f372d..b655bdf11 100644 --- a/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml +++ b/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml @@ -14,6 +14,7 @@ + diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.xaml b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.xaml index 91b243178..680cdcf17 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.xaml +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.xaml @@ -15,8 +15,6 @@ - - diff --git a/src/Wpf.Ui/Converters/IconSourceElementConverter.cs b/src/Wpf.Ui/Converters/IconSourceElementConverter.cs index c787d5d09..58e30de06 100644 --- a/src/Wpf.Ui/Converters/IconSourceElementConverter.cs +++ b/src/Wpf.Ui/Converters/IconSourceElementConverter.cs @@ -8,18 +8,43 @@ namespace Wpf.Ui.Converters; +/// +/// Converts an to an . +/// public class IconSourceElementConverter : IValueConverter { + /// + /// Converts a value to an . + /// + /// The value to convert. + /// The type of the binding target property. + /// The converter parameter. + /// The culture to use in the converter. + /// The converted . public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { return ConvertToIconElement(value); } + /// + /// Converts an back to an IconSourceElement. + /// + /// The value to convert. + /// The type of the binding target property. + /// The converter parameter. + /// The culture to use in the converter. + /// The converted IconSourceElement. public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { 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); diff --git a/src/Wpf.Ui/Extensions/NavigationServiceExtensions.cs b/src/Wpf.Ui/Extensions/NavigationServiceExtensions.cs index 63524b073..61fcecc73 100644 --- a/src/Wpf.Ui/Extensions/NavigationServiceExtensions.cs +++ b/src/Wpf.Ui/Extensions/NavigationServiceExtensions.cs @@ -12,6 +12,12 @@ namespace Wpf.Ui.Extensions; /// public static class NavigationServiceExtensions { + /// + /// Sets the pane display mode of the navigation service. + /// + /// The navigation service. + /// The pane display mode. + /// Same so multiple calls can be chained. public static INavigationService SetPaneDisplayMode( this INavigationService navigationService, NavigationViewPaneDisplayMode paneDisplayMode diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index 380f466f3..2a706aa93 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -37,15 +37,19 @@ public static bool ApplyWindowCornerPreference(Window window, WindowCornerPrefer public static bool ApplyWindowCornerPreference(IntPtr handle, WindowCornerPreference cornerPreference) { if (handle == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(handle)) + { return false; + } int pvAttribute = (int)UnsafeReflection.Cast(cornerPreference); // TODO: Validate HRESULT - Dwmapi.DwmSetWindowAttribute( + _ = Dwmapi.DwmSetWindowAttribute( handle, Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE, ref pvAttribute, @@ -71,19 +75,25 @@ public static bool RemoveWindowDarkMode(Window? window) => public static bool RemoveWindowDarkMode(IntPtr handle) { if (handle == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(handle)) + { return false; + } var pvAttribute = 0x0; // Disable var dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; if (!Win32.Utilities.IsOSWindows11Insider1OrNewer) + { dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DMWA_USE_IMMERSIVE_DARK_MODE_OLD; + } // TODO: Validate HRESULT - Dwmapi.DwmSetWindowAttribute(handle, dwAttribute, ref pvAttribute, Marshal.SizeOf(typeof(int))); + _ = Dwmapi.DwmSetWindowAttribute(handle, dwAttribute, ref pvAttribute, Marshal.SizeOf(typeof(int))); return true; } @@ -104,19 +114,25 @@ public static bool ApplyWindowDarkMode(Window? window) => public static bool ApplyWindowDarkMode(IntPtr handle) { if (handle == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(handle)) + { return false; + } var pvAttribute = 0x1; // Enable var dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; if (!Win32.Utilities.IsOSWindows11Insider1OrNewer) + { dwAttribute = Dwmapi.DWMWINDOWATTRIBUTE.DMWA_USE_IMMERSIVE_DARK_MODE_OLD; + } // TODO: Validate HRESULT - Dwmapi.DwmSetWindowAttribute(handle, dwAttribute, ref pvAttribute, Marshal.SizeOf(typeof(int))); + _ = Dwmapi.DwmSetWindowAttribute(handle, dwAttribute, ref pvAttribute, Marshal.SizeOf(typeof(int))); return true; } @@ -129,10 +145,14 @@ public static bool ApplyWindowDarkMode(IntPtr handle) public static bool RemoveWindowTitlebarContents(Window? window) { if (window == null) + { return false; + } if (window.IsLoaded) + { return GetHandle(window, out IntPtr windowHandle) && RemoveWindowTitlebarContents(windowHandle); + } window.Loaded += (sender, _) => { @@ -151,17 +171,21 @@ public static bool RemoveWindowTitlebarContents(Window? window) public static bool RemoveWindowTitlebarContents(IntPtr handle) { if (handle == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(handle)) + { return false; + } var windowStyleLong = User32.GetWindowLong(handle, User32.GWL.GWL_STYLE); windowStyleLong &= ~(int)User32.WS.SYSMENU; - var result = User32.SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong); + var result = SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong); - return result > 0x0; + return result.ToInt64() > 0x0; } /// @@ -173,18 +197,24 @@ public static bool RemoveWindowTitlebarContents(IntPtr handle) public static bool ApplyWindowBackdrop(IntPtr handle, WindowBackdropType backgroundType) { if (handle == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(handle)) + { return false; + } var backdropPvAttribute = (int)UnsafeReflection.Cast(backgroundType); if (backdropPvAttribute == (int)Dwmapi.DWMSBT.DWMSBT_DISABLE) + { return false; + } // TODO: Validate HRESULT - Dwmapi.DwmSetWindowAttribute( + _ = Dwmapi.DwmSetWindowAttribute( handle, Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, ref backdropPvAttribute, @@ -202,11 +232,13 @@ public static bool ApplyWindowBackdrop(IntPtr handle, WindowBackdropType backgro public static bool IsWindowHasBackdrop(IntPtr handle, WindowBackdropType backdropType) { if (!User32.IsWindow(handle)) + { return false; + } var pvAttribute = 0x0; - Dwmapi.DwmGetWindowAttribute( + _ = Dwmapi.DwmGetWindowAttribute( handle, Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, ref pvAttribute, @@ -230,11 +262,13 @@ public static bool IsWindowHasLegacyMica(Window? window) => public static bool IsWindowHasLegacyMica(IntPtr handle) { if (!User32.IsWindow(handle)) + { return false; + } var pvAttribute = 0x0; - Dwmapi.DwmGetWindowAttribute( + _ = Dwmapi.DwmGetWindowAttribute( handle, Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_MICA_EFFECT, ref pvAttribute, @@ -262,12 +296,12 @@ public static bool ApplyWindowLegacyMicaEffect(IntPtr handle) var backdropPvAttribute = 0x1; //Enable // TODO: Validate HRESULT - Dwmapi.DwmSetWindowAttribute( - handle, - Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_MICA_EFFECT, - ref backdropPvAttribute, - Marshal.SizeOf(typeof(int)) - ); + _ = Dwmapi.DwmSetWindowAttribute( + handle, + Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_MICA_EFFECT, + ref backdropPvAttribute, + Marshal.SizeOf(typeof(int)) + ); return true; } @@ -305,7 +339,7 @@ public static bool ApplyWindowLegacyAcrylicEffect(IntPtr handle) Data = accentPtr }; - User32.SetWindowCompositionAttribute(handle, ref data); + _ = User32.SetWindowCompositionAttribute(handle, ref data); Marshal.FreeHGlobal(accentPtr); @@ -332,15 +366,21 @@ public static Color GetDwmColor() internal static bool SetTaskbarState(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag) { if (hWnd == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(hWnd)) + { return false; + } var taskbarList = new ShObjIdl.CTaskbarList() as ShObjIdl.ITaskbarList4; if (taskbarList == null) + { return false; + } taskbarList.HrInit(); taskbarList.SetProgressState(hWnd, taskbarFlag); @@ -357,17 +397,22 @@ internal static bool SetTaskbarState(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag) internal static bool SetTaskbarValue(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag, int current, int total) { if (hWnd == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(hWnd)) + { return false; + } // TODO: Get existing taskbar class - var taskbarList = new ShObjIdl.CTaskbarList() as ShObjIdl.ITaskbarList4; - if (taskbarList == null) + if (taskbarList is null) + { return false; + } taskbarList.HrInit(); taskbarList.SetProgressState(hWnd, taskbarFlag); @@ -376,15 +421,19 @@ internal static bool SetTaskbarValue(IntPtr hWnd, ShObjIdl.TBPFLAG taskbarFlag, taskbarFlag != ShObjIdl.TBPFLAG.TBPF_INDETERMINATE && taskbarFlag != ShObjIdl.TBPFLAG.TBPF_NOPROGRESS ) + { taskbarList.SetProgressValue(hWnd, Convert.ToUInt64(current), Convert.ToUInt64(total)); + } return true; } public static bool RemoveWindowCaption(Window window) { - if (window == null) + if (window is null) + { return false; + } var windowHandle = new WindowInteropHelper(window).Handle; @@ -394,10 +443,14 @@ public static bool RemoveWindowCaption(Window window) public static bool RemoveWindowCaption(IntPtr hWnd) { if (hWnd == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(hWnd)) + { return false; + } var wtaOptions = new UxTheme.WTA_OPTIONS() { @@ -417,8 +470,10 @@ public static bool RemoveWindowCaption(IntPtr hWnd) public static bool ExtendClientAreaIntoTitleBar(Window window) { - if (window == null) + if (window is null) + { return false; + } var windowHandle = new WindowInteropHelper(window).Handle; @@ -433,10 +488,14 @@ public static bool ExtendClientAreaIntoTitleBar(IntPtr hWnd) // WinRt has ExtendContentIntoTitlebar, but it needs some digging if (hWnd == IntPtr.Zero) + { return false; + } if (!User32.IsWindow(hWnd)) + { return false; + } // #1 Remove titlebar elements var wtaOptions = new UxTheme.WTA_OPTIONS() @@ -454,10 +513,10 @@ public static bool ExtendClientAreaIntoTitleBar(IntPtr hWnd) (uint)Marshal.SizeOf(typeof(UxTheme.WTA_OPTIONS)) ); - var windowDpi = DpiHelper.GetWindowDpi(hWnd); + DisplayDpi windowDpi = DpiHelper.GetWindowDpi(hWnd); // #2 Extend glass frame - var deviceGlassThickness = DpiHelper.LogicalThicknessToDevice( + Thickness deviceGlassThickness = DpiHelper.LogicalThicknessToDevice( new Thickness(-1, -1, -1, -1), windowDpi.DpiScaleX, windowDpi.DpiScaleY @@ -484,10 +543,9 @@ public static bool ExtendClientAreaIntoTitleBar(IntPtr hWnd) /// /// Checks whether the DWM composition is enabled. /// - /// public static bool IsCompositionEnabled() { - Dwmapi.DwmIsCompositionEnabled(out var isEnabled); + _ = Dwmapi.DwmIsCompositionEnabled(out var isEnabled); return isEnabled == 0x1; } @@ -503,12 +561,10 @@ public static bool IsValidWindow(IntPtr hWnd) /// /// Tries to get the pointer to the window handle. /// - /// - /// /// if the handle is not . private static bool GetHandle(Window? window, out IntPtr windowHandle) { - if (window == null) + if (window is null) { windowHandle = IntPtr.Zero; @@ -519,4 +575,14 @@ private static bool GetHandle(Window? window, out IntPtr windowHandle) return windowHandle != IntPtr.Zero; } + + private static IntPtr SetWindowLong(IntPtr handle, User32.GWL nIndex, long windowStyleLong) + { + if (IntPtr.Size == 4) + { + return new IntPtr(User32.SetWindowLong(handle, (int)nIndex, (int)windowStyleLong)); + } + + return User32.SetWindowLongPtr(handle, (int)nIndex, (IntPtr)windowStyleLong); + } } diff --git a/src/Wpf.Ui/Interop/User32.cs b/src/Wpf.Ui/Interop/User32.cs index 3ab2bf49d..bb08a8f1e 100644 --- a/src/Wpf.Ui/Interop/User32.cs +++ b/src/Wpf.Ui/Interop/User32.cs @@ -1308,6 +1308,12 @@ [In] IntPtr lParam [DllImport(Libraries.User32, CharSet = CharSet.Auto)] public static extern IntPtr SetWindowLongPtr([In] IntPtr hWnd, [In] int nIndex, [In] IntPtr dwNewLong); + /// + /// Changes an attribute of the specified window. + /// + [DllImport(Libraries.User32, CharSet = CharSet.Auto, SetLastError = true)] + public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + /// /// Destroys an icon and frees any memory the icon occupied. /// diff --git a/src/Wpf.Ui/Markup/SymbolIconExtension.cs b/src/Wpf.Ui/Markup/SymbolIconExtension.cs index 1cc719f43..90ae2ea86 100644 --- a/src/Wpf.Ui/Markup/SymbolIconExtension.cs +++ b/src/Wpf.Ui/Markup/SymbolIconExtension.cs @@ -37,6 +37,11 @@ public SymbolIconExtension(SymbolRegular symbol) Symbol = symbol; } + public SymbolIconExtension(string symbol) + { + Symbol = (SymbolRegular)Enum.Parse(typeof(SymbolRegular), symbol); + } + public SymbolIconExtension(SymbolRegular symbol, bool filled) : this(symbol) { diff --git a/src/Wpf.Ui/Resources/Theme/HC1.xaml b/src/Wpf.Ui/Resources/Theme/HC1.xaml index 32244999b..e49d98e8c 100644 --- a/src/Wpf.Ui/Resources/Theme/HC1.xaml +++ b/src/Wpf.Ui/Resources/Theme/HC1.xaml @@ -32,7 +32,7 @@ #A6A6A6 - #FFFAEF + #2D3236 diff --git a/src/Wpf.Ui/Resources/Theme/HC2.xaml b/src/Wpf.Ui/Resources/Theme/HC2.xaml index 18ebade4b..48d2cf1e9 100644 --- a/src/Wpf.Ui/Resources/Theme/HC2.xaml +++ b/src/Wpf.Ui/Resources/Theme/HC2.xaml @@ -31,7 +31,7 @@ #8080FF #A6A6A6 - #FFFAEF + #000000 diff --git a/src/Wpf.Ui/Resources/Theme/HCBlack.xaml b/src/Wpf.Ui/Resources/Theme/HCBlack.xaml index 8cd3859ba..c75cb3c72 100644 --- a/src/Wpf.Ui/Resources/Theme/HCBlack.xaml +++ b/src/Wpf.Ui/Resources/Theme/HCBlack.xaml @@ -31,7 +31,7 @@ #75E9FC #A6A6A6 - #FFFAEF + #202020 diff --git a/tests/Wpf.Ui.Gallery.UnitTests/Wpf.Ui.Gallery.UnitTests.csproj b/tests/Wpf.Ui.Gallery.UnitTests/Wpf.Ui.Gallery.UnitTests.csproj index 53962977c..540ff06e2 100644 --- a/tests/Wpf.Ui.Gallery.UnitTests/Wpf.Ui.Gallery.UnitTests.csproj +++ b/tests/Wpf.Ui.Gallery.UnitTests/Wpf.Ui.Gallery.UnitTests.csproj @@ -1,7 +1,7 @@ - net7.0-windows10.0.22621.0 + net8.0-windows10.0.22621.0 enable enable