From 4ac96867797267d566b82fbbfcab0c867353afaa Mon Sep 17 00:00:00 2001 From: Bay Eggex <79448667+bayeggex@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:35:18 +0300 Subject: [PATCH 1/8] SystemThemeWatcher Documentation content changes (#1200) --- docs/documentation/system-theme-watcher.md | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/docs/documentation/system-theme-watcher.md b/docs/documentation/system-theme-watcher.md index e69de29bb..c703f7d69 100644 --- a/docs/documentation/system-theme-watcher.md +++ b/docs/documentation/system-theme-watcher.md @@ -0,0 +1,88 @@ +# SystemThemeWatcher + +SystemThemeWatcher automatically updates the application background if the system theme or color changes. This component is used to adapt the application's background effect and theme according to the system theme. + +## Features + + * Automatic Theme Updates: Updates the application's background and theme when the system theme changes. + + * Global Settings: Settings apply globally and cannot be changed for each System.Windows.Window. + + * Supported Backdrop Types: Provides background effects compatible with WindowBackdropType types (e.g., Egg). + + +## Usage + +You can use SystemThemeWatcher to start watching a window's background and theme like this: + +```cs +SystemThemeWatcher.Watch(this as System.Windows.Window); +SystemThemeWatcher.UnWatch(this as System.Windows.Window); +``` + +or +```cs +SystemThemeWatcher.Watch( + _serviceProvider.GetRequiredService() +); +``` + +## Example Usage + +Here's an example of using SystemThemeWatcher in the MainWindow class to start watching the theme when the window is loaded: + +```cs +namespace MyApp; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + + Loaded += (sender, args) => + { + Wpf.Ui.Appearance.SystemThemeWatcher.Watch( + this, // Window class + Wpf.Ui.Controls.WindowBackdropType.Mica, // Background type + true // Whether to change accents automatically + ); + }; + } +} +``` + +## Methods + +### Watch + +Applies the background effect and theme according to the system theme to the observed window. + +```cs +public static void Watch( + Window? window, + WindowBackdropType backdrop = WindowBackdropType.Mica, + bool updateAccents = true +) +``` + +### UnWatch + +Stops watching the window and removes the hook to receive system messages. + +```cs +public static void UnWatch(Window? window) + +``` + +### WndProc + +Listens to system messages on the application windows. + +```cs +private static IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + +``` + +> [!IMPORTANT] +> If UnWatch is called on a window that has not yet loaded, an InvalidOperationException may occur. Ensure that the window is loaded before calling UnWatch. From caf86ab8f160ba4ec36247f159af57dd38dd55f3 Mon Sep 17 00:00:00 2001 From: Glenn Slayden <5589855+glenn-slayden@users.noreply.github.com> Date: Thu, 24 Oct 2024 01:28:02 -0700 Subject: [PATCH 2/8] [getting-started.md] fixed for English grammar and flow (#1210) --- docs/documentation/getting-started.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/documentation/getting-started.md b/docs/documentation/getting-started.md index c22b1cc85..01576cf0e 100644 --- a/docs/documentation/getting-started.md +++ b/docs/documentation/getting-started.md @@ -2,8 +2,7 @@ ## Adding dictionaries -[XAML](https://docs.microsoft.com/en-us/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0), and hence WPF, operate on resource dictionaries. These are HTML-like files that describe the appearance and various aspects of the [controls](https://wpfui.lepo.co/documentation/controls). -**WPF UI** adds its own sets of these files to tell the application how the controls should look like. +[XAML](https://docs.microsoft.com/en-us/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0), and hence WPF, operate on resource dictionaries. These are HTML-like files that describe the appearance and various aspects of the [controls](https://wpfui.lepo.co/documentation/controls). **WPF UI** adds its own sets of these files to tell the application how the controls should look. There should be a file called `App.xaml` in your new application. Add new dictionaries to it using **WPF UI** `ControlsDictionary` and `ThemesDictionary` classes: @@ -20,16 +19,13 @@ There should be a file called `App.xaml` in your new application. Add new dictio - ``` -You can choose a color theme here, -`Light` or `Dark`. +Notice that the `ThemeDictionary` lets you choose a color theme, `Light` or `Dark`. ## The main window -There should be a `MainWindow.xaml` file in your newly created application. -It contains the arrangement of the controls used and their parameters. +There should be a `MainWindow.xaml` file in your newly created application. It contains the arrangement of the controls used and their parameters. ```xml ``` -You can add a new namespace to this window to tell the interpreter that you will be using controls from somewhere, like the **WPF UI** library. +Add the **WPF UI** library namespace to this window to tell the XAML compiler that you will be using controls from the library. ```xml Date: Thu, 24 Oct 2024 16:37:06 +0800 Subject: [PATCH 3/8] perf: Exclude the definition of the CanCenterOverWPFOwnerPropertyInfo field in .NET 8 or higher (#1202) Co-authored-by: pomian <13592821+pomianowski@users.noreply.github.com> --- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 0e37bcb1e..1da1681f2 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -236,10 +236,12 @@ public bool IsPrimaryButtonEnabled /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); +#if !NET8_0_OR_GREATER private static readonly PropertyInfo CanCenterOverWPFOwnerPropertyInfo = typeof(Window).GetProperty( "CanCenterOverWPFOwner", BindingFlags.NonPublic | BindingFlags.Instance )!; +#endif /// /// Initializes a new instance of the class. From e98881c51dc50bb61003d55b02f189efb4145771 Mon Sep 17 00:00:00 2001 From: Shavix <54279284+Shavixinio@users.noreply.github.com> Date: Sun, 24 Nov 2024 15:40:22 +0100 Subject: [PATCH 4/8] Remove accidentally added characters (#1282) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce430b6fe..93206830f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Support the development of WPF UI and other innovative projects by becoming a sp [Sponsor WPF UI on GitHub](https://github.com/sponsors/lepoco) ## 🚀 Getting started -ąś + For a starter guide see our [documentation](https://wpfui.lepo.co/documentation/). **WPF UI Gallery** is a free application available in the _Microsoft Store_, with which you can test all functionalities. From f492028e937023abb285354cc998de718ef6e694 Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:15:07 +0100 Subject: [PATCH 5/8] Create top-issues-dashboard.yml (#1286) --- .../workflows/top-issues-dashboard.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/.github/workflows/top-issues-dashboard.yml diff --git a/.github/workflows/.github/workflows/top-issues-dashboard.yml b/.github/workflows/.github/workflows/top-issues-dashboard.yml new file mode 100644 index 000000000..16185e714 --- /dev/null +++ b/.github/workflows/.github/workflows/top-issues-dashboard.yml @@ -0,0 +1,24 @@ +name: Top issues action. +on: + schedule: + - cron: '0 0 */1 * *' + +jobs: + ShowAndLabelTopIssues: + name: Display and label top issues. + runs-on: ubuntu-latest + steps: + - name: Top Issues action + uses: rickstaa/top-issues-action@v1.3.101 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + top_list_size: 10 + label: true + dashboard: true + dashboard_show_total_reactions: true + top_issues: true + top_bugs: true + top_features: true + feature_label: feature + top_pull_requests: true From 882b2315fe8b50dfb90ebf4ec490bea7918c784f Mon Sep 17 00:00:00 2001 From: Leszek Pomianowski <13592821+pomianowski@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:16:45 +0100 Subject: [PATCH 6/8] Move issues --- .../workflows/{.github/workflows => }/top-issues-dashboard.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{.github/workflows => }/top-issues-dashboard.yml (100%) diff --git a/.github/workflows/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml similarity index 100% rename from .github/workflows/.github/workflows/top-issues-dashboard.yml rename to .github/workflows/top-issues-dashboard.yml From baa55d4aec69df26c8bca325a249110712500389 Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:31:22 +0100 Subject: [PATCH 7/8] Add support for .NET 9 (#1287) --- .devcontainer/devcontainer.json | 2 +- .github/workflows/top-issues-dashboard.yml | 2 +- .github/workflows/wpf-ui-cd-docs.yaml | 4 ++-- .github/workflows/wpf-ui-cd-extension.yaml | 2 +- .github/workflows/wpf-ui-cd-nuget.yaml | 6 ++++-- .github/workflows/wpf-ui-pr-validator.yaml | 4 ++-- Directory.Build.props | 4 ++-- src/Wpf.Ui.Abstractions/Wpf.Ui.Abstractions.csproj | 2 +- .../Wpf.Ui.DependencyInjection.csproj | 4 ++-- src/Wpf.Ui.FontMapper/Wpf.Ui.FontMapper.csproj | 2 +- src/Wpf.Ui.Gallery/Wpf.Ui.Gallery.csproj | 2 +- src/Wpf.Ui.SyntaxHighlight/Wpf.Ui.SyntaxHighlight.csproj | 2 +- .../Wpf.Ui.ToastNotifications.csproj | 2 +- src/Wpf.Ui.Tray/Wpf.Ui.Tray.csproj | 2 +- src/Wpf.Ui/Wpf.Ui.csproj | 2 +- .../Wpf.Ui.Gallery.UnitTests.csproj | 2 +- tests/Wpf.Ui.UnitTests/Wpf.Ui.UnitTests.csproj | 2 +- 17 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0bf4a912c..b9e1e2ce1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "WPF UI Docs Dev Container", - "image": "mcr.microsoft.com/dotnet/sdk:8.0", + "image": "mcr.microsoft.com/dotnet/sdk:9.0", "features": { "ghcr.io/devcontainers/features/node:1": { "version": "20" diff --git a/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml index 16185e714..f1c3ffbf6 100644 --- a/.github/workflows/top-issues-dashboard.yml +++ b/.github/workflows/top-issues-dashboard.yml @@ -1,4 +1,4 @@ -name: Top issues action. +name: wpf-ui-top-issues-dashboard on: schedule: - cron: '0 0 */1 * *' diff --git a/.github/workflows/wpf-ui-cd-docs.yaml b/.github/workflows/wpf-ui-cd-docs.yaml index f6b39b482..1464f4dc6 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 8.x + - name: Setup .NET Core SDK 9.x uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.x + dotnet-version: 9.x - name: Install docfx run: dotnet tool update -g docfx diff --git a/.github/workflows/wpf-ui-cd-extension.yaml b/.github/workflows/wpf-ui-cd-extension.yaml index 6bd56b3c9..2635972b5 100644 --- a/.github/workflows/wpf-ui-cd-extension.yaml +++ b/.github/workflows/wpf-ui-cd-extension.yaml @@ -4,7 +4,7 @@ on: push: branches: [main] paths: - - 'src/Wpf.Ui.Extension**` + - 'src/Wpf.Ui.Extension**' workflow_dispatch: diff --git a/.github/workflows/wpf-ui-cd-nuget.yaml b/.github/workflows/wpf-ui-cd-nuget.yaml index a49cb274e..f47d13215 100644 --- a/.github/workflows/wpf-ui-cd-nuget.yaml +++ b/.github/workflows/wpf-ui-cd-nuget.yaml @@ -3,6 +3,8 @@ name: wpf-ui-cd-nuget on: push: branches: [main] + paths: + - 'src/**' workflow_dispatch: @@ -17,10 +19,10 @@ jobs: - uses: nuget/setup-nuget@v2 with: nuget-api-key: ${{ secrets.NUGET_API_KEY }} - - name: Setup .NET Core SDK 8.x + - name: Setup .NET Core SDK 9.x uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.x + dotnet-version: 9.x - name: Fetch the certificate run: | diff --git a/.github/workflows/wpf-ui-pr-validator.yaml b/.github/workflows/wpf-ui-pr-validator.yaml index c2e4fa698..7a641dcac 100644 --- a/.github/workflows/wpf-ui-pr-validator.yaml +++ b/.github/workflows/wpf-ui-pr-validator.yaml @@ -17,10 +17,10 @@ jobs: - uses: nuget/setup-nuget@v2 with: nuget-api-key: ${{ secrets.NUGET_API_KEY }} - - name: Setup .NET Core SDK 8.x + - name: Setup .NET Core SDK 9.x uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.x + dotnet-version: 9.x - name: Install dependencies run: dotnet restore diff --git a/Directory.Build.props b/Directory.Build.props index f3160f4fa..cf67c770c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,7 +6,7 @@ - 4.0.0-rc.2 + 4.0.0-rc.3 4.0.0 @@ -41,7 +41,7 @@ true - 12.0 + 13.0 enable