From 71c801aeda1407f26d9b45fa9d7b81f94c99c8a3 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Thu, 7 Dec 2023 11:41:22 +0530 Subject: [PATCH 001/185] Setup win11 theme project --- Documentation/projects-and-assemblies.md | 5 +- Microsoft.Dotnet.Wpf.sln | 38 +++++++++++ eng/WpfArcadeSdk/tools/GenApi.props | 1 + eng/WpfArcadeSdk/tools/ShippingProjects.props | 4 ++ .../tools/WpfProjectReference.targets | 2 +- .../OtherAssemblyAttrs.cs | 2 +- .../src/Shared/RefAssemblyAttrs.cs | 1 + .../PresentationFramework.Win11.csproj | 66 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 21 ++++++ .../PresentationFramework.Win11-ref.csproj | 66 +++++++++++++++++++ .../ref/PresentationFramework.Win11.cs | 7 ++ .../src/WindowsBase/OtherAssemblyAttrs.cs | 1 + 12 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11-ref.csproj create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11.cs diff --git a/Documentation/projects-and-assemblies.md b/Documentation/projects-and-assemblies.md index 446221d517f..a4267e5d860 100644 --- a/Documentation/projects-and-assemblies.md +++ b/Documentation/projects-and-assemblies.md @@ -121,6 +121,8 @@ The following assemblies are being produced today: | PresentationFramework.pdb | PresentationFramework.Royale.dll | PresentationFramework.Royale.pdb + | PresentationFramework.Win11.dll + | PresentationFramework.Win11.pdb | PresentationUI.dll | PresentationUI.pdb | ReachFramework.dll @@ -452,7 +454,8 @@ src\Themes\PresentationFramework.Luna\PresentationFramework.Luna.csproj src\Themes\PresentationFramework.Luna\ref\PresentationFramework.Luna-ref.csproj src\Themes\PresentationFramework.Royale\PresentationFramework.Royale.csproj src\Themes\PresentationFramework.Royale\ref\PresentationFramework.Royale-ref.csproj - +src\Themes\PresentationFramework.Win11\PresentationFramework.Win11.csproj +src\Themes\PresentationFramework.Win11\ref\PresentationFramework.Win11-ref.csproj src\UIAutomation\UIAutomationClient\UIAutomationClient.csproj src\UIAutomation\UIAutomationClient\ref\UIAutomationClient-ref.csproj src\UIAutomation\UIAutomationClientSideProviders\UIAutomationClientSideProviders.csproj diff --git a/Microsoft.Dotnet.Wpf.sln b/Microsoft.Dotnet.Wpf.sln index f7c6af628b8..5bf62f20218 100644 --- a/Microsoft.Dotnet.Wpf.sln +++ b/Microsoft.Dotnet.Wpf.sln @@ -249,6 +249,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Xaml.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Xaml.Tests\System.Xaml.Tests.csproj", "{B2F2A89C-55C9-41B1-A645-0948609BD8BE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationFramework.Win11", "src\Microsoft.DotNet.Wpf\src\Themes\PresentationFramework.Win11\PresentationFramework.Win11.csproj", "{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationFramework.Win11-ref", "src\Microsoft.DotNet.Wpf\src\Themes\PresentationFramework.Win11\ref\PresentationFramework.Win11-ref.csproj", "{3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1942,6 +1946,38 @@ Global {B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x86.ActiveCfg = Release|Win32 {B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x86.Build.0 = Release|Win32 {B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Release|x86.Deploy.0 = Release|Win32 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|ARM64.ActiveCfg = Debug|arm64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|ARM64.Build.0 = Debug|arm64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|x64.ActiveCfg = Debug|x64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|x64.Build.0 = Debug|x64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|x86.ActiveCfg = Debug|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Debug|x86.Build.0 = Debug|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|Any CPU.Build.0 = Release|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|ARM64.ActiveCfg = Release|arm64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|ARM64.Build.0 = Release|arm64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|x64.ActiveCfg = Release|x64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|x64.Build.0 = Release|x64 + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|x86.ActiveCfg = Release|Any CPU + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}.Release|x86.Build.0 = Release|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|ARM64.ActiveCfg = Debug|arm64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|ARM64.Build.0 = Debug|arm64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|x64.ActiveCfg = Debug|x64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|x64.Build.0 = Debug|x64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|x86.ActiveCfg = Debug|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Debug|x86.Build.0 = Debug|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|Any CPU.Build.0 = Release|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|ARM64.ActiveCfg = Release|arm64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|ARM64.Build.0 = Release|arm64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x64.ActiveCfg = Release|x64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x64.Build.0 = Release|x64 + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x86.ActiveCfg = Release|Any CPU + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2062,6 +2098,8 @@ Global {34B64A4A-7C83-4F92-8C47-80E9FA10D660} = {C9ECC1A1-917F-43D3-B340-2035B4938507} {A48B585E-6AB0-4F8D-8484-77F37CB44437} = {34B64A4A-7C83-4F92-8C47-80E9FA10D660} {B2F2A89C-55C9-41B1-A645-0948609BD8BE} = {A48B585E-6AB0-4F8D-8484-77F37CB44437} + {3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9} = {5ACFB055-649D-4A01-98C2-B0BFE7E543D6} + {3C43C553-2C1F-4EB9-8BF8-371D4A42E0FD} = {60F4058B-D35B-42D2-B276-D44B3AC579BD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567} diff --git a/eng/WpfArcadeSdk/tools/GenApi.props b/eng/WpfArcadeSdk/tools/GenApi.props index e32dacd3df0..1bc67e55322 100644 --- a/eng/WpfArcadeSdk/tools/GenApi.props +++ b/eng/WpfArcadeSdk/tools/GenApi.props @@ -10,6 +10,7 @@ PresentationFramework.Classic; PresentationFramework.Luna; PresentationFramework.Royale; + PresentationFramework.Win11; ReachFramework; System.Windows.Controls.Ribbon; System.Windows.Input.Manipulations; diff --git a/eng/WpfArcadeSdk/tools/ShippingProjects.props b/eng/WpfArcadeSdk/tools/ShippingProjects.props index 4cff4856c0f..682ddade50e 100644 --- a/eng/WpfArcadeSdk/tools/ShippingProjects.props +++ b/eng/WpfArcadeSdk/tools/ShippingProjects.props @@ -28,6 +28,7 @@ PresentationFramework.Classic; PresentationFramework.Luna; PresentationFramework.Royale; + PresentationFramework.Win11; WindowsFormsIntegration; PenImc; wpfgfx; @@ -98,6 +99,7 @@ PresentationFramework.Classic-ref; PresentationFramework.Luna-ref; PresentationFramework.Royale-ref; + PresentationFramework.Win11; PresentationUI-ref; System.Printing-ref; System.Windows.Controls.Ribbon-ref; @@ -136,6 +138,8 @@ PresentationFramework.Luna-ref; PresentationFramework.Royale; PresentationFramework.Royale-ref; + PresentationFramework.Win11; + PresentationFramework.Win11-ref; PresentationUI; ReachFramework; ReachFramework-ref; diff --git a/eng/WpfArcadeSdk/tools/WpfProjectReference.targets b/eng/WpfArcadeSdk/tools/WpfProjectReference.targets index 46afb993625..a90652db067 100644 --- a/eng/WpfArcadeSdk/tools/WpfProjectReference.targets +++ b/eng/WpfArcadeSdk/tools/WpfProjectReference.targets @@ -47,7 +47,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/OtherAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/OtherAssemblyAttrs.cs index ba1c3db6d8d..3304e63c92e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/OtherAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/OtherAssemblyAttrs.cs @@ -37,7 +37,7 @@ [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkSystemCore)] [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkSystemXml)] [assembly:InternalsVisibleTo(BuildInfo.SystemWindowsControlsRibbon)] - +[assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkWin11)] [assembly:DependencyAttribute("mscorlib,", LoadHint.Always)] [assembly:DependencyAttribute("System,", LoadHint.Always)] [assembly:DependencyAttribute("WindowsBase,", LoadHint.Always)] diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs index 39b1fce8eb1..1e8717b8883 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs @@ -51,6 +51,7 @@ internal static class BuildInfo internal const string PresentationFrameworkAero2 = "PresentationFramework.Aero2, PublicKey=" + WCP_PUBLIC_KEY_STRING; internal const string PresentationFrameworkAeroLite = "PresentationFramework.AeroLite, PublicKey=" + WCP_PUBLIC_KEY_STRING; internal const string PresentationFrameworkClassic = "PresentationFramework.Classic, PublicKey=" + WCP_PUBLIC_KEY_STRING; + internal const string PresentationFrameworkWin11 = "PresentationFramework.Win11, PublicKey=" + WCP_PUBLIC_KEY_STRING; internal const string PresentationFrameworkSystemCore = "PresentationFramework-SystemCore, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; internal const string PresentationFrameworkSystemData = "PresentationFramework-SystemData, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; internal const string PresentationFrameworkSystemDrawing = "PresentationFramework-SystemDrawing, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj new file mode 100644 index 00000000000..ce5ba2ae74b --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -0,0 +1,66 @@ + + + + + + Wpf.Ui-ref + $(TargetGroup)-$(PackageId)/ + + None + AnyCPU;x64;arm64 + false + + + $(DefineConstants);THEME_WIN11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..8b7b2fae999 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Markup; + +[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) +)] + + +[assembly: XmlnsPrefix("http://schemas.wpfmui.com/2019", "mui")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11.Controls")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11.Controls.Primitives")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11.DesignTime")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11.Markup")] +[assembly: XmlnsDefinition("http://schemas.wpfmui.com/2019", "PresentationFramework.Win11.Media.Animation")] \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11-ref.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11-ref.csproj new file mode 100644 index 00000000000..acd1706a7f2 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11-ref.csproj @@ -0,0 +1,66 @@ + + + + + PresentationFramework.Win11 + PresentationFramework.Win11-ref + $(TargetGroup)-$(PackageId)/ + + None + AnyCPU;x64;arm64 + false + + + $(DefineConstants);THEME_WIN11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11.cs new file mode 100644 index 00000000000..ddf844e3a19 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/ref/PresentationFramework.Win11.cs @@ -0,0 +1,7 @@ +// 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. + +namespace Microsoft.Windows.Themes +{ +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs index 2ba2d259deb..25c540b0245 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs @@ -28,6 +28,7 @@ [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkAero2)] [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkAeroLite)] [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkClassic)] +[assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkWin11)] [assembly:InternalsVisibleTo(BuildInfo.ReachFramework)] [assembly:InternalsVisibleTo(BuildInfo.SystemWindowsPresentation)] [assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkSystemCore)] From ca1f5f73d2a3b3ff826d12e42cbb4c0e6e8e0671 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Mon, 11 Dec 2023 14:39:48 +0530 Subject: [PATCH 002/185] Create dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/dotnet-desktop.yml diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml new file mode 100644 index 00000000000..1b49bd21c84 --- /dev/null +++ b/.github/workflows/dotnet-desktop.yml @@ -0,0 +1,49 @@ +name: Build WPF + +on: [push] + +jobs: + BuildDebug: + + runs-on: [self-hosted, VSPreview] + + steps: + - uses: actions/checkout@v1 + # - name: Install Nuget + # uses: nuget/setup-nuget@v1 + # with: + # nuget-version: '5.x' + - name: Build + run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86 + - name: Build CustomWPF + run: dotnet build CustomWpf + - name: Pack CustomWPF + run: dotnet pack CustomWpf --no-build + - name: Push + uses: actions/upload-artifact@v1 + with: + name: WPF_Debug + path: ./artifacts/packages/Debug/NonShipping + - name: Push + uses: actions/upload-artifact@v1 + with: + name: WPF_Debug_Nuget + path: ./CustomWpf/bin + + BuildRelease: + + runs-on: [self-hosted, VSPreview] + + steps: + - uses: actions/checkout@v1 + - name: Build + run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86 + - name: Build CustomWPF + run: dotnet build CustomWpf -c Release + - name: Pack CustomWPF + run: dotnet pack CustomWpf --no-build -c Release + - name: Push + uses: actions/upload-artifact@v1 + with: + name: WPF_Release_Nuget + path: ./CustomWpf/bin From 6450a8fb79f38d5602b73478797569bca47e3ef4 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Mon, 11 Dec 2023 14:44:21 +0530 Subject: [PATCH 003/185] Update dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index 1b49bd21c84..795cd4948ba 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -5,7 +5,7 @@ on: [push] jobs: BuildDebug: - runs-on: [self-hosted, VSPreview] + runs-on: windows-latest steps: - uses: actions/checkout@v1 From 719ae1d428411334966c05940456f5b842b87463 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Mon, 11 Dec 2023 15:07:46 +0530 Subject: [PATCH 004/185] Update dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index 795cd4948ba..1d56b07ffe9 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -5,7 +5,7 @@ on: [push] jobs: BuildDebug: - runs-on: windows-latest + runs-on: windows-2022 steps: - uses: actions/checkout@v1 From 38d8528f7009abbfe04736e4d37b0f72aa330604 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Wed, 13 Dec 2023 11:24:16 +0530 Subject: [PATCH 005/185] Styling Xamls for pallette, accent, Colors, Typography and Themes --- .../Resources/Accent.xaml | 47 ++ .../Resources/DefaultContextMenu.xaml | 16 + .../Resources/DefaultFocusVisualStyle.xaml | 27 + .../Resources/Fonts.xaml | 16 + .../Resources/Palette.xaml | 57 ++ .../PresentationFramework.Win11.xaml | 19 + .../Resources/StaticColors.xaml | 46 ++ .../Resources/Theme/Dark.xaml | 672 +++++++++++++++++ .../Resources/Theme/HC1.xaml | 674 ++++++++++++++++++ .../Resources/Theme/HC2.xaml | 673 +++++++++++++++++ .../Resources/Theme/HCBlack.xaml | 673 +++++++++++++++++ .../Resources/Theme/HCWhite.xaml | 673 +++++++++++++++++ .../Resources/Theme/Light.xaml | 672 +++++++++++++++++ .../Resources/Typography.xaml | 72 ++ .../Resources/Variables.xaml | 52 ++ 15 files changed, 4389 insertions(+) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Accent.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultContextMenu.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultFocusVisualStyle.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Fonts.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Palette.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/StaticColors.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Dark.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC1.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC2.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCBlack.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCWhite.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Typography.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Variables.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Accent.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Accent.xaml new file mode 100644 index 00000000000..1cd063de398 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Accent.xaml @@ -0,0 +1,47 @@ + + + + + + #3379d9 + + + + + #559ce4 + + #80b9ee + + #add8ff + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultContextMenu.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultContextMenu.xaml new file mode 100644 index 00000000000..3b0eb1c9188 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultContextMenu.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultFocusVisualStyle.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultFocusVisualStyle.xaml new file mode 100644 index 00000000000..5347117e4d4 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/DefaultFocusVisualStyle.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Variables.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Variables.xaml new file mode 100644 index 00000000000..45a92734297 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Variables.xaml @@ -0,0 +1,52 @@ + + + + 16 + + 14 + 4,4,4,4 + 4,4,4,4 + 8,8,8,8 + + + + 1 + 2 + 10,8,10,7 + + 14 + 24 + 0 + 32 + 24 + 24 + 0 + 0 + + 0,1,0,2 + 0,1,0,2 + 9,0,0,1 + 10,0,30,0 + + 24 + 12,1,0,3 + 32 + + From 06e077875d953d038b0e78ff28f0cab14199a258 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Wed, 13 Dec 2023 15:03:19 +0530 Subject: [PATCH 006/185] Fix Style Resources not getting embedded. --- .../PresentationFramework.Win11.csproj | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj index ce5ba2ae74b..ed7b9b4a717 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -12,12 +12,54 @@ $(DefineConstants);THEME_WIN11 - + + false + + + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4778edbe36d831bb4e4cf23e624c4f6106413b24 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Singh Date: Wed, 13 Dec 2023 17:40:38 +0530 Subject: [PATCH 007/185] Fix build errors to properly locate the resource files --- .../Common/DpiScale2.cs | 23 + .../Common/ResourceAccessor.cs | 185 ++++++ .../Controls/ContentControlEx.cs | 46 ++ .../Controls/ContentPresenterEx.cs | 286 ++++++++ .../Controls/FontIconFallback.cs | 35 + .../Controls/Primitives/ControlHelper.cs | 349 ++++++++++ .../Controls/Primitives/FocusVisualHelper.cs | 617 ++++++++++++++++++ .../Controls/Primitives/TextBoxHelper.cs | 169 +++++ .../Controls/Primitives/ValidationHelper.cs | 46 ++ .../Controls/RatingItemFontInfo.cs | 176 +++++ .../Controls/RatingItemInfo.cs | 26 + .../Controls/RatingItemPathInfo.cs | 119 ++++ .../Helpers/Helper.cs | 120 ++++ .../Helpers/ThemeResourceHelper.cs | 24 + .../Markup/DynamicColorExtension.cs | 67 ++ .../Markup/KeyTimeExtension.cs | 21 + .../Markup/StaticColorExtension.cs | 32 + .../Markup/StaticResourceExtension.cs | 13 + .../Markup/ThemeResourceExtension.cs | 95 +++ .../PresentationFramework.Win11.csproj | 57 +- .../Styles/Button.xaml | 127 ++++ .../Styles/TextBox.xaml | 234 +++++++ 22 files changed, 2823 insertions(+), 44 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/DpiScale2.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/ResourceAccessor.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentControlEx.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentPresenterEx.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/FontIconFallback.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ControlHelper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/FocusVisualHelper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/TextBoxHelper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ValidationHelper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemFontInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemPathInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/Helper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/ThemeResourceHelper.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/DynamicColorExtension.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/KeyTimeExtension.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticColorExtension.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticResourceExtension.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/ThemeResourceExtension.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/DpiScale2.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/DpiScale2.cs new file mode 100644 index 00000000000..1275ea0381d --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/DpiScale2.cs @@ -0,0 +1,23 @@ +using System.Windows; + +namespace PresentationFramework.Win11 +{ + internal readonly record struct DpiScale2 + { + public DpiScale2(double dpiScaleX, double dpiScaleY) + { + DpiScaleX = dpiScaleX; + DpiScaleY = dpiScaleY; + } + +#if NET462_OR_NEWER + public DpiScale2(DpiScale dpiScale) + : this(dpiScale.DpiScaleX, dpiScale.DpiScaleY) + { + } +#endif + + public double DpiScaleX { get; } + public double DpiScaleY { get; } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/ResourceAccessor.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/ResourceAccessor.cs new file mode 100644 index 00000000000..32514785087 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Common/ResourceAccessor.cs @@ -0,0 +1,185 @@ +using System; +using System.Resources; + +namespace PresentationFramework.Win11 +{ + internal class ResourceAccessor + { + #region Resource Keys + + public const string SR_BasicRatingString = "BasicRatingString"; + public const string SR_CommunityRatingString = "CommunityRatingString"; + public const string SR_RatingsControlName = "RatingsControlName"; + public const string SR_RatingControlName = "RatingControlName"; + public const string SR_RatingUnset = "RatingUnset"; + public const string SR_NavigationButtonClosedName = "NavigationButtonClosedName"; + public const string SR_NavigationButtonOpenName = "NavigationButtonOpenName"; + public const string SR_NavigationViewItemDefaultControlName = "NavigationViewItemDefaultControlName"; + public const string SR_NavigationBackButtonName = "NavigationBackButtonName"; + public const string SR_NavigationBackButtonToolTip = "NavigationBackButtonToolTip"; + public const string SR_NavigationCloseButtonName = "NavigationCloseButtonName"; + public const string SR_NavigationOverflowButtonName = "NavigationOverflowButtonName"; + public const string SR_NavigationOverflowButtonText = "NavigationOverflowButtonText"; + public const string SR_NavigationOverflowButtonToolTip = "NavigationOverflowButtonToolTip"; + public const string SR_SettingsButtonName = "SettingsButtonName"; + public const string SR_NavigationViewSearchButtonName = "NavigationViewSearchButtonName"; + public const string SR_TextAlphaLabel = "TextAlphaLabel"; + public const string SR_AutomationNameAlphaSlider = "AutomationNameAlphaSlider"; + public const string SR_AutomationNameAlphaTextBox = "AutomationNameAlphaTextBox"; + public const string SR_AutomationNameHueSlider = "AutomationNameHueSlider"; + public const string SR_AutomationNameSaturationSlider = "AutomationNameSaturationSlider"; + public const string SR_AutomationNameValueSlider = "AutomationNameValueSlider"; + public const string SR_TextBlueLabel = "TextBlueLabel"; + public const string SR_AutomationNameBlueTextBox = "AutomationNameBlueTextBox"; + public const string SR_AutomationNameColorModelComboBox = "AutomationNameColorModelComboBox"; + public const string SR_AutomationNameColorSpectrum = "AutomationNameColorSpectrum"; + public const string SR_TextGreenLabel = "TextGreenLabel"; + public const string SR_AutomationNameGreenTextBox = "AutomationNameGreenTextBox"; + public const string SR_HelpTextColorSpectrum = "HelpTextColorSpectrum"; + public const string SR_AutomationNameHexTextBox = "AutomationNameHexTextBox"; + public const string SR_ContentHSVComboBoxItem = "ContentHSVComboBoxItem"; + public const string SR_TextHueLabel = "TextHueLabel"; + public const string SR_AutomationNameHueTextBox = "AutomationNameHueTextBox"; + public const string SR_LocalizedControlTypeColorSpectrum = "LocalizedControlTypeColorSpectrum"; + public const string SR_TextRedLabel = "TextRedLabel"; + public const string SR_AutomationNameRedTextBox = "AutomationNameRedTextBox"; + public const string SR_ContentRGBComboBoxItem = "ContentRGBComboBoxItem"; + public const string SR_TextSaturationLabel = "TextSaturationLabel"; + public const string SR_AutomationNameSaturationTextBox = "AutomationNameSaturationTextBox"; + public const string SR_TextValueLabel = "TextValueLabel"; + public const string SR_ValueStringColorSpectrumWithColorName = "ValueStringColorSpectrumWithColorName"; + public const string SR_ValueStringColorSpectrumWithoutColorName = "ValueStringColorSpectrumWithoutColorName"; + public const string SR_ValueStringHueSliderWithColorName = "ValueStringHueSliderWithColorName"; + public const string SR_ValueStringHueSliderWithoutColorName = "ValueStringHueSliderWithoutColorName"; + public const string SR_ValueStringSaturationSliderWithColorName = "ValueStringSaturationSliderWithColorName"; + public const string SR_ValueStringSaturationSliderWithoutColorName = "ValueStringSaturationSliderWithoutColorName"; + public const string SR_ValueStringValueSliderWithColorName = "ValueStringValueSliderWithColorName"; + public const string SR_ValueStringValueSliderWithoutColorName = "ValueStringValueSliderWithoutColorName"; + public const string SR_AutomationNameValueTextBox = "AutomationNameValueTextBox"; + public const string SR_ToolTipStringAlphaSlider = "ToolTipStringAlphaSlider"; + public const string SR_ToolTipStringHueSliderWithColorName = "ToolTipStringHueSliderWithColorName"; + public const string SR_ToolTipStringHueSliderWithoutColorName = "ToolTipStringHueSliderWithoutColorName"; + public const string SR_ToolTipStringSaturationSliderWithColorName = "ToolTipStringSaturationSliderWithColorName"; + public const string SR_ToolTipStringSaturationSliderWithoutColorName = "ToolTipStringSaturationSliderWithoutColorName"; + public const string SR_ToolTipStringValueSliderWithColorName = "ToolTipStringValueSliderWithColorName"; + public const string SR_ToolTipStringValueSliderWithoutColorName = "ToolTipStringValueSliderWithoutColorName"; + public const string SR_AutomationNameMoreButtonCollapsed = "AutomationNameMoreButtonCollapsed"; + public const string SR_AutomationNameMoreButtonExpanded = "AutomationNameMoreButtonExpanded"; + public const string SR_HelpTextMoreButton = "HelpTextMoreButton"; + public const string SR_TextMoreButtonLabelCollapsed = "TextMoreButtonLabelCollapsed"; + public const string SR_TextMoreButtonLabelExpanded = "TextMoreButtonLabelExpanded"; + public const string SR_BadgeItemPlural1 = "BadgeItemPlural1"; + public const string SR_BadgeItemPlural2 = "BadgeItemPlural2"; + public const string SR_BadgeItemPlural3 = "BadgeItemPlural3"; + public const string SR_BadgeItemPlural4 = "BadgeItemPlural4"; + public const string SR_BadgeItemPlural5 = "BadgeItemPlural5"; + public const string SR_BadgeItemPlural6 = "BadgeItemPlural6"; + public const string SR_BadgeItemPlural7 = "BadgeItemPlural7"; + public const string SR_BadgeItemSingular = "BadgeItemSingular"; + public const string SR_BadgeItemTextOverride = "BadgeItemTextOverride"; + public const string SR_BadgeIcon = "BadgeIcon"; + public const string SR_BadgeIconTextOverride = "BadgeIconTextOverride"; + public const string SR_PersonName = "PersonName"; + public const string SR_GroupName = "GroupName"; + public const string SR_CancelDraggingString = "CancelDraggingString"; + public const string SR_DefaultItemString = "DefaultItemString"; + public const string SR_DropIntoNodeString = "DropIntoNodeString"; + public const string SR_FallBackPlaceString = "FallBackPlaceString"; + public const string SR_PagerControlPageTextName = "PagerControlPageText"; + public const string SR_PagerControlPrefixTextName = "PagerControlPrefixText"; + public const string SR_PagerControlSuffixTextName = "PagerControlPrefixText"; + public const string SR_PagerControlFirstPageButtonTextName = "PagerControlFirstPageButtonText"; + public const string SR_PagerControlPreviousPageButtonTextName = "PagerControlPreviousPageButtonText"; + public const string SR_PagerControlNextPageButtonTextName = "PagerControlNextPageButtonText"; + public const string SR_PagerControlLastPageButtonTextName = "PagerControlLastPageButtonText"; + public const string SR_PipsPagerNameText = "PipsPagerNameText"; + public const string SR_PipsPagerNextPageButtonText = "PipsPagerNextPageButtonText"; + public const string SR_PipsPagerPreviousPageButtonText = "PipsPagerPreviousPageButtonText"; + public const string SR_PipsPagerPageText = "PipsPagerPageText"; + public const string SR_PlaceAfterString = "PlaceAfterString"; + public const string SR_PlaceBeforeString = "PlaceBeforeString"; + public const string SR_PlaceBetweenString = "PlaceBetweenString"; + public const string SR_ProgressRingName = "ProgressRingName"; + public const string SR_ProgressRingIndeterminateStatus = "ProgressRingIndeterminateStatus"; + public const string SR_ProgressBarIndeterminateStatus = "ProgressBarIndeterminateStatus"; + public const string SR_ProgressBarPausedStatus = "ProgressBarPausedStatus"; + public const string SR_ProgressBarErrorStatus = "ProgressBarErrorStatus"; + public const string SR_RatingLocalizedControlType = "RatingLocalizedControlType"; + public const string SR_SplitButtonSecondaryButtonName = "SplitButtonSecondaryButtonName"; + public const string SR_ProofingMenuItemLabel = "ProofingMenuItemLabel"; + public const string SR_TextCommandLabelCut = "TextCommandLabelCut"; + public const string SR_TextCommandLabelCopy = "TextCommandLabelCopy"; + public const string SR_TextCommandLabelPaste = "TextCommandLabelPaste"; + public const string SR_TextCommandLabelSelectAll = "TextCommandLabelSelectAll"; + public const string SR_TextCommandLabelBold = "TextCommandLabelBold"; + public const string SR_TextCommandLabelItalic = "TextCommandLabelItalic"; + public const string SR_TextCommandLabelUnderline = "TextCommandLabelUnderline"; + public const string SR_TextCommandLabelUndo = "TextCommandLabelUndo"; + public const string SR_TextCommandLabelRedo = "TextCommandLabelRedo"; + public const string SR_TextCommandDescriptionCut = "TextCommandDescriptionCut"; + public const string SR_TextCommandDescriptionCopy = "TextCommandDescriptionCopy"; + public const string SR_TextCommandDescriptionPaste = "TextCommandDescriptionPaste"; + public const string SR_TextCommandDescriptionSelectAll = "TextCommandDescriptionSelectAll"; + public const string SR_TextCommandDescriptionBold = "TextCommandDescriptionBold"; + public const string SR_TextCommandDescriptionItalic = "TextCommandDescriptionItalic"; + public const string SR_TextCommandDescriptionUnderline = "TextCommandDescriptionUnderline"; + public const string SR_TextCommandDescriptionUndo = "TextCommandDescriptionUndo"; + public const string SR_TextCommandDescriptionRedo = "TextCommandDescriptionRedo"; + public const string SR_TextCommandKeyboardAcceleratorKeyCut = "TextCommandKeyboardAcceleratorKeyCut"; + public const string SR_TextCommandKeyboardAcceleratorKeyCopy = "TextCommandKeyboardAcceleratorKeyCopy"; + public const string SR_TextCommandKeyboardAcceleratorKeyPaste = "TextCommandKeyboardAcceleratorKeyPaste"; + public const string SR_TextCommandKeyboardAcceleratorKeySelectAll = "TextCommandKeyboardAcceleratorKeySelectAll"; + public const string SR_TextCommandKeyboardAcceleratorKeyBold = "TextCommandKeyboardAcceleratorKeyBold"; + public const string SR_TextCommandKeyboardAcceleratorKeyItalic = "TextCommandKeyboardAcceleratorKeyItalic"; + public const string SR_TextCommandKeyboardAcceleratorKeyUnderline = "TextCommandKeyboardAcceleratorKeyUnderline"; + public const string SR_TextCommandKeyboardAcceleratorKeyUndo = "TextCommandKeyboardAcceleratorKeyUndo"; + public const string SR_TextCommandKeyboardAcceleratorKeyRedo = "TextCommandKeyboardAcceleratorKeyRedo"; + public const string SR_TeachingTipAlternateCloseButtonName = "TeachingTipAlternateCloseButtonName"; + public const string SR_TeachingTipAlternateCloseButtonTooltip = "TeachingTipAlternateCloseButtonTooltip"; + public const string SR_TeachingTipCustomLandmarkName = "TeachingTipCustomLandmarkName"; + public const string SR_TeachingTipNotification = "TeachingTipNotification"; + public const string SR_TeachingTipNotificationWithoutAppName = "TeachingTipNotificationWithoutAppName"; + public const string SR_TabViewAddButtonName = "TabViewAddButtonName"; + public const string SR_TabViewAddButtonTooltip = "TabViewAddButtonTooltip"; + public const string SR_TabViewCloseButtonName = "TabViewCloseButtonName"; + public const string SR_TabViewCloseButtonTooltip = "TabViewCloseButtonTooltip"; + public const string SR_TabViewCloseButtonTooltipWithKA = "TabViewCloseButtonTooltipWithKA"; + public const string SR_TabViewScrollDecreaseButtonTooltip = "TabViewScrollDecreaseButtonTooltip"; + public const string SR_TabViewScrollIncreaseButtonTooltip = "TabViewScrollIncreaseButtonTooltip"; + public const string SR_NumberBoxUpSpinButtonName = "NumberBoxUpSpinButtonName"; + public const string SR_NumberBoxDownSpinButtonName = "NumberBoxDownSpinButtonName"; + public const string SR_ExpanderDefaultControlName = "ExpanderDefaultControlName"; + + public const string SR_InfoBarCloseButtonName = "InfoBarCloseButtonName"; + public const string SR_InfoBarOpenedNotification = "InfoBarOpenedNotification"; + public const string SR_InfoBarClosedNotification = "InfoBarClosedNotification"; + public const string SR_InfoBarCustomLandmarkName = "InfoBarCustomLandmarkName"; + public const string SR_InfoBarCloseButtonTooltip = "InfoBarCloseButtonTooltip"; + + public const string IR_NoiseAsset_256X256_PNG = "NoiseAsset_256X256_PNG"; + + #endregion + + private readonly Type _controlType; + private ResourceManager _resourceManager; + + public ResourceAccessor(Type controlType) + { + _controlType = controlType ?? throw new ArgumentNullException(nameof(controlType)); + } + + public string GetLocalizedStringResource(string resourceName) + { + if (_resourceManager is null) + { + var assembly = _controlType.Assembly; + var assemblyName = assembly.GetName().Name; + var controlName = _controlType.Name; + var baseName = $"{assemblyName}.{controlName}.Strings.Resources"; + _resourceManager = new ResourceManager(baseName, assembly); + } + + return _resourceManager.GetString(resourceName); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentControlEx.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentControlEx.cs new file mode 100644 index 00000000000..f31c36ab65d --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentControlEx.cs @@ -0,0 +1,46 @@ +using System.Windows; +using System.Windows.Controls; +using PresentationFramework.Win11.Controls.Primitives; + +namespace PresentationFramework.Win11.Controls +{ + public class ContentControlEx : ContentControl + { + static ContentControlEx() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(ContentControlEx), new FrameworkPropertyMetadata(typeof(ContentControlEx))); + HorizontalContentAlignmentProperty.OverrideMetadata(typeof(ContentControlEx), new FrameworkPropertyMetadata(HorizontalAlignment.Stretch)); + VerticalContentAlignmentProperty.OverrideMetadata(typeof(ContentControlEx), new FrameworkPropertyMetadata(VerticalAlignment.Stretch)); + } + + #region CornerRadius + + public static readonly DependencyProperty CornerRadiusProperty = + ControlHelper.CornerRadiusProperty.AddOwner(typeof(ContentControlEx)); + + public CornerRadius CornerRadius + { + get => (CornerRadius)GetValue(CornerRadiusProperty); + set => SetValue(CornerRadiusProperty, value); + } + + #endregion + + #region RecognizesAccessKey + + public static readonly DependencyProperty RecognizesAccessKeyProperty = + DependencyProperty.Register( + nameof(RecognizesAccessKey), + typeof(bool), + typeof(ContentControlEx), + new FrameworkPropertyMetadata(false)); + + public bool RecognizesAccessKey + { + get => (bool)GetValue(RecognizesAccessKeyProperty); + set => SetValue(RecognizesAccessKeyProperty, value); + } + + #endregion + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentPresenterEx.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentPresenterEx.cs new file mode 100644 index 00000000000..58f1518da84 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ContentPresenterEx.cs @@ -0,0 +1,286 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Controls +{ + /// + /// ContentPresenter is used within the template of a content control to denote the + /// place in the control's visual tree (control template) where the content + /// is to be added. + /// + public class ContentPresenterEx : ContentPresenter + { + #region Public Properties + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty FontFamilyProperty = + TextElement.FontFamilyProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The FontFamily property specifies the name of font family. + /// + [Localizability(LocalizationCategory.Font)] + public FontFamily FontFamily + { + get { return (FontFamily)GetValue(FontFamilyProperty); } + set { SetValue(FontFamilyProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty FontStyleProperty = + TextElement.FontStyleProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The FontStyle property requests normal, italic, and oblique faces within a font family. + /// + public FontStyle FontStyle + { + get { return (FontStyle)GetValue(FontStyleProperty); } + set { SetValue(FontStyleProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty FontWeightProperty = + TextElement.FontWeightProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The FontWeight property specifies the weight of the font. + /// + public FontWeight FontWeight + { + get { return (FontWeight)GetValue(FontWeightProperty); } + set { SetValue(FontWeightProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty FontStretchProperty = + TextElement.FontStretchProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The FontStretch property selects a normal, condensed, or extended face from a font family. + /// + public FontStretch FontStretch + { + get { return (FontStretch)GetValue(FontStretchProperty); } + set { SetValue(FontStretchProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty FontSizeProperty = + TextElement.FontSizeProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The FontSize property specifies the size of the font. + /// + [TypeConverter(typeof(FontSizeConverter))] + [Localizability(LocalizationCategory.None)] + public double FontSize + { + get { return (double)GetValue(FontSizeProperty); } + set { SetValue(FontSizeProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty ForegroundProperty = + TextElement.ForegroundProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The Foreground property specifies the foreground brush of an element's text content. + /// + public Brush Foreground + { + get { return (Brush)GetValue(ForegroundProperty); } + set { SetValue(ForegroundProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty LineHeightProperty = + Block.LineHeightProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The LineHeight property specifies the height of each generated line box. + /// + [TypeConverter(typeof(LengthConverter))] + public double LineHeight + { + get { return (double)GetValue(LineHeightProperty); } + set { SetValue(LineHeightProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty LineStackingStrategyProperty = + Block.LineStackingStrategyProperty.AddOwner(typeof(ContentPresenterEx)); + + /// + /// The LineStackingStrategy property specifies how lines are placed + /// + public LineStackingStrategy LineStackingStrategy + { + get { return (LineStackingStrategy)GetValue(LineStackingStrategyProperty); } + set { SetValue(LineStackingStrategyProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty TextWrappingProperty = + TextBlock.TextWrappingProperty.AddOwner( + typeof(ContentPresenterEx), + new FrameworkPropertyMetadata( + TextWrapping.NoWrap, + new PropertyChangedCallback(OnTextWrappingChanged))); + + /// + /// The TextWrapping property controls whether or not text wraps + /// when it reaches the flow edge of its containing block box. + /// + public TextWrapping TextWrapping + { + get { return (TextWrapping)GetValue(TextWrappingProperty); } + set { SetValue(TextWrappingProperty, value); } + } + + private static void OnTextWrappingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var ctrl = (ContentPresenterEx)d; + if (ctrl.TextBlock != null) + { + ctrl.TextBlock.TextWrapping = (TextWrapping)e.NewValue; + } + else if (ctrl.AccessText != null) + { + ctrl.AccessText.TextWrapping = (TextWrapping)e.NewValue; + } + } + + #endregion + + #region Private Properties + + private bool IsUsingDefaultTemplate { get; set; } + + private TextBlock _textBlock; + private TextBlock TextBlock + { + get => _textBlock; + set + { + if (_textBlock != null) + { + _textBlock.ClearValue(TextBlock.TextWrappingProperty); + } + + _textBlock = value; + + if (_textBlock != null) + { + _textBlock.TextWrapping = TextWrapping; + } + } + } + + private AccessText _accessText; + private AccessText AccessText + { + get => _accessText; + set + { + if (_accessText != null) + { + _accessText.ClearValue(AccessText.TextWrappingProperty); + } + + _accessText = value; + + if (_accessText != null) + { + _accessText.TextWrapping = TextWrapping; + } + } + } + + #endregion + + #region Protected Methods + + protected override DataTemplate ChooseTemplate() + { + DataTemplate template = null; + object content = Content; + + // ContentTemplate has first stab + template = ContentTemplate; + + // no ContentTemplate set, try ContentTemplateSelector + if (template == null) + { + if (ContentTemplateSelector != null) + { + template = ContentTemplateSelector.SelectTemplate(content, this); + } + } + + // if that failed, try the default TemplateSelector + if (template == null) + { + template = base.ChooseTemplate(); + IsUsingDefaultTemplate = true; + } + else + { + IsUsingDefaultTemplate = false; + } + + return template; + } + + protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) + { + base.OnVisualChildrenChanged(visualAdded, visualRemoved); + + if (visualAdded != null && IsUsingDefaultTemplate) + { + if (visualAdded is TextBlock textBlock) + { + TextBlock = textBlock; + } + else if (visualAdded is AccessText accessText) + { + AccessText = accessText; + } + } + else if (visualRemoved != null) + { + if (visualRemoved == TextBlock) + { + TextBlock = null; + } + else if (visualRemoved == AccessText) + { + AccessText = null; + } + } + } + + #endregion + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/FontIconFallback.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/FontIconFallback.cs new file mode 100644 index 00000000000..1f1a4554278 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/FontIconFallback.cs @@ -0,0 +1,35 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Controls +{ + // TODO: Use font icon if available + [EditorBrowsable(EditorBrowsableState.Never)] + public class FontIconFallback : Control + { + static FontIconFallback() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(FontIconFallback), new FrameworkPropertyMetadata(typeof(FontIconFallback))); + FocusableProperty.OverrideMetadata(typeof(FontIconFallback), new FrameworkPropertyMetadata(false)); + } + + #region Data + + public static readonly DependencyProperty DataProperty = + DependencyProperty.Register( + nameof(Data), + typeof(Geometry), + typeof(FontIconFallback), + null); + + public Geometry Data + { + get => (Geometry)GetValue(DataProperty); + set => SetValue(DataProperty, value); + } + + #endregion + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ControlHelper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ControlHelper.cs new file mode 100644 index 00000000000..2c7b2494624 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ControlHelper.cs @@ -0,0 +1,349 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Controls.Primitives +{ + public static class ControlHelper + { + #region CornerRadius + + /// + /// Gets the radius for the corners of the control's border. + /// + /// The element from which to read the property value. + /// + /// The degree to which the corners are rounded, expressed as values of the CornerRadius + /// structure. + /// + public static CornerRadius GetCornerRadius(Control control) + { + return (CornerRadius)control.GetValue(CornerRadiusProperty); + } + + /// + /// Sets the radius for the corners of the control's border. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetCornerRadius(Control control, CornerRadius value) + { + control.SetValue(CornerRadiusProperty, value); + } + + /// + /// Identifies the CornerRadius dependency property. + /// + public static readonly DependencyProperty CornerRadiusProperty = + DependencyProperty.RegisterAttached( + "CornerRadius", + typeof(CornerRadius), + typeof(ControlHelper), + null); + + #endregion + + #region Header + + /// + /// Identifies the Header dependency property. + /// + public static readonly DependencyProperty HeaderProperty = + DependencyProperty.RegisterAttached( + "Header", + typeof(object), + typeof(ControlHelper), + new FrameworkPropertyMetadata(OnHeaderChanged)); + + /// + /// Gets the content for the control's header. + /// + /// The element from which to read the property value. + /// The content of the control's header. The default is **null**. + public static object GetHeader(Control control) + { + return control.GetValue(HeaderProperty); + } + + /// + /// Sets the content for the control's header. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetHeader(Control control, object value) + { + control.SetValue(HeaderProperty, value); + } + + private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + UpdateHeaderVisibility((Control)d); + } + + #endregion + + #region HeaderTemplate + + /// + /// Identifies the HeaderTemplate dependency property. + /// + public static readonly DependencyProperty HeaderTemplateProperty = + DependencyProperty.RegisterAttached( + "HeaderTemplate", + typeof(DataTemplate), + typeof(ControlHelper), + new FrameworkPropertyMetadata(OnHeaderTemplateChanged)); + + /// + /// Gets the DataTemplate used to display the content of the control's header. + /// + /// The element from which to read the property value. + /// + /// The template that specifies the visualization of the header object. The default + /// is **null**. + /// + public static DataTemplate GetHeaderTemplate(Control control) + { + return (DataTemplate)control.GetValue(HeaderTemplateProperty); + } + + /// + /// Sets the DataTemplate used to display the content of the control's header. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetHeaderTemplate(Control control, DataTemplate value) + { + control.SetValue(HeaderTemplateProperty, value); + } + + private static void OnHeaderTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + UpdateHeaderVisibility((Control)d); + } + + #endregion + + #region HeaderVisibility + + private static readonly DependencyPropertyKey HeaderVisibilityPropertyKey = + DependencyProperty.RegisterAttachedReadOnly( + "HeaderVisibility", + typeof(Visibility), + typeof(ControlHelper), + new FrameworkPropertyMetadata(Visibility.Collapsed)); + + public static readonly DependencyProperty HeaderVisibilityProperty = + HeaderVisibilityPropertyKey.DependencyProperty; + + public static Visibility GetHeaderVisibility(Control control) + { + return (Visibility)control.GetValue(HeaderVisibilityProperty); + } + + private static void SetHeaderVisibility(Control control, Visibility value) + { + control.SetValue(HeaderVisibilityPropertyKey, value); + } + + private static void UpdateHeaderVisibility(Control control) + { + Visibility visibility; + + if (GetHeaderTemplate(control) != null) + { + visibility = Visibility.Visible; + } + else + { + visibility = IsNullOrEmptyString(GetHeader(control)) ? Visibility.Collapsed : Visibility.Visible; + } + + SetHeaderVisibility(control, visibility); + } + + #endregion + + #region PlaceholderText + + /// + /// Gets the text that is displayed in the control until the value is changed + /// by a user action or some other operation. + /// + /// The element from which to read the property value. + /// + /// The text that is displayed in the control when no value is entered. The default + /// is an empty string (""). + /// + public static string GetPlaceholderText(Control control) + { + return (string)control.GetValue(PlaceholderTextProperty); + } + + /// + /// Sets the text that is displayed in the control until the value is changed + /// by a user action or some other operation. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetPlaceholderText(Control control, string value) + { + control.SetValue(PlaceholderTextProperty, value); + } + + /// + /// Identifies the PlaceholderText dependency property. + /// + public static readonly DependencyProperty PlaceholderTextProperty = + DependencyProperty.RegisterAttached( + "PlaceholderText", + typeof(string), + typeof(ControlHelper), + new FrameworkPropertyMetadata(string.Empty, OnPlaceholderTextChanged)); + + private static void OnPlaceholderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + UpdatePlaceholderTextVisibility((Control)d); + } + + #endregion + + #region PlaceholderTextVisibility + + public static Visibility GetPlaceholderTextVisibility(Control control) + { + return (Visibility)control.GetValue(PlaceholderTextVisibilityProperty); + } + + private static void SetPlaceholderTextVisibility(Control control, Visibility value) + { + control.SetValue(PlaceholderTextVisibilityPropertyKey, value); + } + + private static readonly DependencyPropertyKey PlaceholderTextVisibilityPropertyKey = + DependencyProperty.RegisterAttachedReadOnly( + "PlaceholderTextVisibility", + typeof(Visibility), + typeof(ControlHelper), + new FrameworkPropertyMetadata(Visibility.Collapsed)); + + public static readonly DependencyProperty PlaceholderTextVisibilityProperty = + PlaceholderTextVisibilityPropertyKey.DependencyProperty; + + private static void UpdatePlaceholderTextVisibility(Control control) + { + SetPlaceholderTextVisibility(control, string.IsNullOrEmpty(GetPlaceholderText(control)) ? Visibility.Collapsed : Visibility.Visible); + } + + #endregion + + #region PlaceholderForeground + + /// + /// Gets a brush that describes the color of placeholder text. + /// + /// The element from which to read the property value. + /// The brush that describes the color of placeholder text. + public static Brush GetPlaceholderForeground(Control control) + { + return (Brush)control.GetValue(PlaceholderForegroundProperty); + } + + /// + /// Sets a brush that describes the color of placeholder text. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetPlaceholderForeground(Control control, Brush value) + { + control.SetValue(PlaceholderForegroundProperty, value); + } + + /// + /// Identifies the PlaceholderForeground dependency property. + /// + public static readonly DependencyProperty PlaceholderForegroundProperty = + DependencyProperty.RegisterAttached( + "PlaceholderForeground", + typeof(Brush), + typeof(ControlHelper), + null); + + #endregion + + #region Description + + /// + /// Gets content that is shown below the control. The content should provide + /// guidance about the input expected by the control. + /// + /// The element from which to read the property value. + /// The content to be displayed below the control. The default is **null**. + public static object GetDescription(Control control) + { + return control.GetValue(DescriptionProperty); + } + + /// + /// Sets content that is shown below the control. The content should provide + /// guidance about the input expected by the control. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetDescription(Control control, object value) + { + control.SetValue(DescriptionProperty, value); + } + + /// + /// Identifies the Description dependency property. + /// + public static readonly DependencyProperty DescriptionProperty = + DependencyProperty.RegisterAttached( + "Description", + typeof(object), + typeof(ControlHelper), + new FrameworkPropertyMetadata(OnDescriptionChanged)); + + private static void OnDescriptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + UpdateDescriptionVisibility((Control)d); + } + + #endregion + + #region DescriptionVisibility + + private static readonly DependencyPropertyKey DescriptionVisibilityPropertyKey = + DependencyProperty.RegisterAttachedReadOnly( + "DescriptionVisibility", + typeof(Visibility), + typeof(ControlHelper), + new FrameworkPropertyMetadata(Visibility.Collapsed)); + + public static readonly DependencyProperty DescriptionVisibilityProperty = + DescriptionVisibilityPropertyKey.DependencyProperty; + + public static Visibility GetDescriptionVisibility(Control control) + { + return (Visibility)control.GetValue(DescriptionVisibilityProperty); + } + + private static void SetDescriptionVisibility(Control control, Visibility value) + { + control.SetValue(DescriptionVisibilityPropertyKey, value); + } + + private static void UpdateDescriptionVisibility(Control control) + { + SetDescriptionVisibility(control, IsNullOrEmptyString(GetDescription(control)) ? Visibility.Collapsed : Visibility.Visible); + } + + #endregion + + internal static bool IsNullOrEmptyString(object obj) + { + return obj == null || obj is string s && string.IsNullOrEmpty(s); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/FocusVisualHelper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/FocusVisualHelper.cs new file mode 100644 index 00000000000..3c51bcf09fa --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/FocusVisualHelper.cs @@ -0,0 +1,617 @@ +// 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; +using System.ComponentModel; +using System.Diagnostics; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Controls.Primitives +{ + public static class FocusVisualHelper + { + #region FocusVisualPrimaryBrush + + /// + /// Gets the brush used to draw the outer border of a HighVisibility focus + /// visual for a FrameworkElement. + /// + /// The element from which to read the property value. + /// The brush used to draw the outer border of a HighVisibility focus visual. + public static Brush GetFocusVisualPrimaryBrush(FrameworkElement element) + { + return (Brush)element.GetValue(FocusVisualPrimaryBrushProperty); + } + + /// + /// Sets the brush used to draw the outer border of a HighVisibility focus + /// visual for a FrameworkElement. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetFocusVisualPrimaryBrush(FrameworkElement element, Brush value) + { + element.SetValue(FocusVisualPrimaryBrushProperty, value); + } + + /// + /// Identifies the FocusVisualPrimaryBrush dependency property. + /// + public static readonly DependencyProperty FocusVisualPrimaryBrushProperty = + DependencyProperty.RegisterAttached( + "FocusVisualPrimaryBrush", + typeof(Brush), + typeof(FocusVisualHelper)); + + #endregion + + #region FocusVisualSecondaryBrush + + /// + /// Gets the brush used to draw the inner border of a HighVisibility focus + /// visual for a FrameworkElement. + /// + /// The element from which to read the property value. + /// The brush used to draw the inner border of a HighVisibility focus visual. + public static Brush GetFocusVisualSecondaryBrush(FrameworkElement element) + { + return (Brush)element.GetValue(FocusVisualSecondaryBrushProperty); + } + + /// + /// Sets the brush used to draw the inner border of a HighVisibility focus + /// visual for a FrameworkElement. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetFocusVisualSecondaryBrush(FrameworkElement element, Brush value) + { + element.SetValue(FocusVisualSecondaryBrushProperty, value); + } + + /// + /// Identifies the FocusVisualSecondaryBrush dependency property. + /// + public static readonly DependencyProperty FocusVisualSecondaryBrushProperty = + DependencyProperty.RegisterAttached( + "FocusVisualSecondaryBrush", + typeof(Brush), + typeof(FocusVisualHelper)); + + #endregion + + #region FocusVisualPrimaryThickness + + /// + /// Gets the thickness of the outer border of a HighVisibility focus visual + /// for a FrameworkElement. + /// + /// The element from which to read the property value. + /// + /// The thickness of the outer border of a HighVisibility focus visual. The default + /// value is 2. + /// + public static Thickness GetFocusVisualPrimaryThickness(FrameworkElement element) + { + return (Thickness)element.GetValue(FocusVisualPrimaryThicknessProperty); + } + + /// + /// Sets the thickness of the outer border of a HighVisibility focus visual + /// for a FrameworkElement. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetFocusVisualPrimaryThickness(FrameworkElement element, Thickness value) + { + element.SetValue(FocusVisualPrimaryThicknessProperty, value); + } + + /// + /// Identifies the FocusVisualPrimaryThickness dependency property. + /// + public static readonly DependencyProperty FocusVisualPrimaryThicknessProperty = + DependencyProperty.RegisterAttached( + "FocusVisualPrimaryThickness", + typeof(Thickness), + typeof(FocusVisualHelper), + new FrameworkPropertyMetadata(new Thickness(2))); + + #endregion + + #region FocusVisualSecondaryThickness + + /// + /// Gets the thickness of the inner border of a HighVisibility focus visual + /// for a FrameworkElement. + /// + /// The element from which to read the property value. + /// + /// The thickness of the inner border of a HighVisibility focus visual. The default + /// value is 1. + /// + public static Thickness GetFocusVisualSecondaryThickness(FrameworkElement element) + { + return (Thickness)element.GetValue(FocusVisualSecondaryThicknessProperty); + } + + /// + /// Sets the thickness of the inner border of a HighVisibility focus visual + /// for a FrameworkElement. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetFocusVisualSecondaryThickness(FrameworkElement element, Thickness value) + { + element.SetValue(FocusVisualSecondaryThicknessProperty, value); + } + + /// + /// Identifies the FocusVisualSecondaryThickness dependency property. + /// + public static readonly DependencyProperty FocusVisualSecondaryThicknessProperty = + DependencyProperty.RegisterAttached( + "FocusVisualSecondaryThickness", + typeof(Thickness), + typeof(FocusVisualHelper), + new FrameworkPropertyMetadata(new Thickness(1))); + + #endregion + + #region FocusVisualMargin + + /// + /// Gets the outer margin of the focus visual for a FrameworkElement. + /// + /// The element from which to read the property value. + /// + /// Provides margin values for the focus visual. The default value is a default Thickness + /// with all properties (dimensions) equal to 0. + /// + public static Thickness GetFocusVisualMargin(FrameworkElement element) + { + return (Thickness)element.GetValue(FocusVisualMarginProperty); + } + + /// + /// Sets the outer margin of the focus visual for a FrameworkElement. + /// + /// The element on which to set the attached property. + /// The property value to set. + public static void SetFocusVisualMargin(FrameworkElement element, Thickness value) + { + element.SetValue(FocusVisualMarginProperty, value); + } + + /// + /// Identifies the FocusVisualMargin dependency property. + /// + public static readonly DependencyProperty FocusVisualMarginProperty = + DependencyProperty.RegisterAttached( + "FocusVisualMargin", + typeof(Thickness), + typeof(FocusVisualHelper), + new FrameworkPropertyMetadata(new Thickness())); + + #endregion + + #region UseSystemFocusVisuals + + /// + /// Identifies the UseSystemFocusVisuals dependency property. + /// + public static readonly DependencyProperty UseSystemFocusVisualsProperty = + DependencyProperty.RegisterAttached( + "UseSystemFocusVisuals", + typeof(bool), + typeof(FocusVisualHelper), + new PropertyMetadata(false)); + + /// + /// Gets a value that indicates whether the control uses focus visuals that + /// are drawn by the system or those defined in the control template. + /// + /// The object from which the property value is read. + /// + /// **true** if the control uses focus visuals drawn by the system; **false** if + /// the control uses focus visuals defined in the ControlTemplate. The default is + /// **false**; see Remarks. + /// + public static bool GetUseSystemFocusVisuals(Control control) + { + return (bool)control.GetValue(UseSystemFocusVisualsProperty); + } + + /// + /// Sets a value that indicates whether the control uses focus visuals that + /// are drawn by the system or those defined in the control template. + /// + /// The object to which the property value is written. + /// The value to set. + public static void SetUseSystemFocusVisuals(Control control, bool value) + { + control.SetValue(UseSystemFocusVisualsProperty, value); + } + + #endregion + + #region IsTemplateFocusTarget + + /// + /// Identifies the Control.IsTemplateFocusTarget XAML attached property. + /// + public static readonly DependencyProperty IsTemplateFocusTargetProperty = + DependencyProperty.RegisterAttached( + "IsTemplateFocusTarget", + typeof(bool), + typeof(FocusVisualHelper), + new PropertyMetadata(OnIsTemplateFocusTargetChanged)); + + /// + /// Gets the value of the Control.IsTemplateFocusTarget XAML attached property for + /// the target element. + /// + /// The object from which the property value is read. + /// + /// The Control.IsTemplateFocusTarget XAML attached property value of the specified + /// object. + /// + public static bool GetIsTemplateFocusTarget(FrameworkElement element) + { + return (bool)element.GetValue(IsTemplateFocusTargetProperty); + } + + /// + /// Sets the value of the Control.IsTemplateFocusTarget XAML attached property for + /// a target element. + /// + /// The object to which the property value is written. + /// The value to set. + public static void SetIsTemplateFocusTarget(FrameworkElement element, bool value) + { + element.SetValue(IsTemplateFocusTargetProperty, value); + } + + private static void OnIsTemplateFocusTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var element = (FrameworkElement)d; + if (element.TemplatedParent is Control control) + { + if ((bool)e.NewValue) + { + SetTemplateFocusTarget(control, element); + } + else + { + control.ClearValue(TemplateFocusTargetProperty); + } + } + } + + #endregion + + #region IsSystemFocusVisual + + public static bool GetIsSystemFocusVisual(Control control) + { + return (bool)control.GetValue(IsSystemFocusVisualProperty); + } + + public static void SetIsSystemFocusVisual(Control control, bool value) + { + control.SetValue(IsSystemFocusVisualProperty, value); + } + + public static readonly DependencyProperty IsSystemFocusVisualProperty = + DependencyProperty.RegisterAttached( + "IsSystemFocusVisual", + typeof(bool), + typeof(FocusVisualHelper), + new PropertyMetadata(OnIsSystemFocusVisualChanged)); + + private static void OnIsSystemFocusVisualChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = (Control)d; + if ((bool)e.NewValue) + { + control.IsVisibleChanged += OnFocusVisualIsVisibleChanged; + } + else + { + control.IsVisibleChanged -= OnFocusVisualIsVisibleChanged; + } + } + + #endregion + + #region ShowFocusVisual + + public static bool GetShowFocusVisual(FrameworkElement element) + { + return (bool)element.GetValue(ShowFocusVisualProperty); + } + + private static void SetShowFocusVisual(FrameworkElement element, bool value) + { + element.SetValue(ShowFocusVisualPropertyKey, value); + } + + private static readonly DependencyPropertyKey ShowFocusVisualPropertyKey = + DependencyProperty.RegisterAttachedReadOnly( + "ShowFocusVisual", + typeof(bool), + typeof(FocusVisualHelper), + new PropertyMetadata(OnShowFocusVisualChanged)); + + public static readonly DependencyProperty ShowFocusVisualProperty = + ShowFocusVisualPropertyKey.DependencyProperty; + + private static void OnShowFocusVisualChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is Control control && GetTemplateFocusTarget(control) is { } target) + { + if ((bool)e.NewValue) + { + bool shouldShowFocusVisual = true; + if (target is Control targetAsControl) + { + shouldShowFocusVisual = GetUseSystemFocusVisuals(targetAsControl); + } + + if (shouldShowFocusVisual) + { + ShowFocusVisual(control, target); + } + } + else + { + HideFocusVisual(); + } + } + + static void HideFocusVisual() + { + // Remove the existing focus visual + if (_focusVisualAdornerCache != null) + { + AdornerLayer adornerlayer = VisualTreeHelper.GetParent(_focusVisualAdornerCache) as AdornerLayer; + Debug.Assert(adornerlayer != null); + if (adornerlayer != null) + { + adornerlayer.Remove(_focusVisualAdornerCache); + } + _focusVisualAdornerCache = null; + } + } + + static void ShowFocusVisual(Control control, FrameworkElement target) + { + HideFocusVisual(); + + AdornerLayer adornerlayer = AdornerLayer.GetAdornerLayer(target); + if (adornerlayer == null) + return; + + Style fvs = target.FocusVisualStyle; + + if (fvs != null && fvs.BasedOn == null && fvs.Setters.Count == 0) + { + fvs = target.TryFindResource(SystemParameters.FocusVisualStyleKey) as Style; + } + + if (fvs != null) + { + _focusVisualAdornerCache = new FocusVisualAdorner(control, target, fvs); + adornerlayer.Add(_focusVisualAdornerCache); + + // Hide the focus visual when IsVisible changes to avoid an internal WPF exception + control.IsVisibleChanged += OnControlIsVisibleChanged; + } + } + + static void OnControlIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + ((Control)sender).IsVisibleChanged -= OnControlIsVisibleChanged; + Debug.Assert((bool)e.NewValue == false); + if (_focusVisualAdornerCache != null && _focusVisualAdornerCache.FocusedElement == sender) + { + HideFocusVisual(); + } + } + } + + #endregion + + #region FocusedElement + + private static FrameworkElement GetFocusedElement(Control focusVisual) + { + return (FrameworkElement)focusVisual.GetValue(FocusedElementProperty); + } + + private static void SetFocusedElement(Control focusVisual, FrameworkElement value) + { + focusVisual.SetValue(FocusedElementProperty, value); + } + + private static readonly DependencyProperty FocusedElementProperty = + DependencyProperty.RegisterAttached( + "FocusedElement", + typeof(FrameworkElement), + typeof(FocusVisualHelper)); + + #endregion + + #region TemplateFocusTarget + + private static readonly DependencyProperty TemplateFocusTargetProperty = + DependencyProperty.RegisterAttached( + "TemplateFocusTarget", + typeof(FrameworkElement), + typeof(FocusVisualHelper)); + + private static FrameworkElement GetTemplateFocusTarget(Control control) + { + return (FrameworkElement)control.GetValue(TemplateFocusTargetProperty); + } + + private static void SetTemplateFocusTarget(Control control, FrameworkElement value) + { + control.SetValue(TemplateFocusTargetProperty, value); + } + + #endregion + + private static void OnFocusVisualIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + var focusVisual = (Control)sender; + if ((bool)e.NewValue) + { + if ((VisualTreeHelper.GetParent(focusVisual) as Adorner)?.AdornedElement is FrameworkElement focusedElement) + { + SetShowFocusVisual(focusedElement, true); + + if (focusedElement is Control focusedControl && + (!GetUseSystemFocusVisuals(focusedControl) || GetTemplateFocusTarget(focusedControl) != null)) + { + focusVisual.Template = null; + } + else + { + TransferValue(focusedElement, focusVisual, FocusVisualPrimaryBrushProperty); + TransferValue(focusedElement, focusVisual, FocusVisualPrimaryThicknessProperty); + TransferValue(focusedElement, focusVisual, FocusVisualSecondaryBrushProperty); + TransferValue(focusedElement, focusVisual, FocusVisualSecondaryThicknessProperty); + focusVisual.Margin = GetFocusVisualMargin(focusedElement); + } + + SetFocusedElement(focusVisual, focusedElement); + } + } + else + { + FrameworkElement focusedElement = GetFocusedElement(focusVisual); + if (focusedElement != null) + { + focusedElement.ClearValue(ShowFocusVisualPropertyKey); + focusVisual.ClearValue(FocusVisualPrimaryBrushProperty); + focusVisual.ClearValue(FocusVisualPrimaryThicknessProperty); + focusVisual.ClearValue(FocusVisualSecondaryBrushProperty); + focusVisual.ClearValue(FocusVisualSecondaryThicknessProperty); + focusVisual.ClearValue(FrameworkElement.MarginProperty); + focusVisual.ClearValue(Control.TemplateProperty); + focusVisual.ClearValue(FocusedElementProperty); + } + } + } + + private static void TransferValue(DependencyObject source, DependencyObject target, DependencyProperty dp) + { + // if (!Helper.HasDefaultValue(source, dp)) + // { + // target.SetValue(dp, source.GetValue(dp)); + // } + } + + private sealed class FocusVisualAdorner : Adorner + { + public FocusVisualAdorner(Control focusedElement, UIElement adornedElement, Style focusVisualStyle) : base(adornedElement) + { + Debug.Assert(focusedElement != null, "focusedElement should not be null"); + Debug.Assert(adornedElement != null, "adornedElement should not be null"); + Debug.Assert(focusVisualStyle != null, "focusVisual should not be null"); + + FocusedElement = focusedElement; + + Control control = new Control(); + SetIsSystemFocusVisual(control, false); + control.Style = focusVisualStyle; + control.Margin = GetFocusVisualMargin(focusedElement); + TransferValue(focusedElement, control, FocusVisualPrimaryBrushProperty); + TransferValue(focusedElement, control, FocusVisualPrimaryThicknessProperty); + TransferValue(focusedElement, control, FocusVisualSecondaryBrushProperty); + TransferValue(focusedElement, control, FocusVisualSecondaryThicknessProperty); + _adorderChild = control; + IsClipEnabled = true; + IsHitTestVisible = false; + IsEnabled = false; + AddVisualChild(_adorderChild); + } + + public Control FocusedElement { get; } + + /// + /// Measure adorner. Default behavior is to size to match the adorned element. + /// + protected override Size MeasureOverride(Size constraint) + { + Size desiredSize = AdornedElement.RenderSize; + + // Measure the child + ((UIElement)GetVisualChild(0)).Measure(desiredSize); + + return desiredSize; + } + + /// + /// Default control arrangement is to only arrange + /// the first visual child. No transforms will be applied. + /// + protected override Size ArrangeOverride(Size size) + { + Size finalSize = base.ArrangeOverride(size); + + ((UIElement)GetVisualChild(0)).Arrange(new Rect(new Point(), finalSize)); + + return finalSize; + } + + /// + /// Derived classes override this property to enable the Visual code to enumerate + /// the Visual children. Derived classes need to return the number of children + /// from this method. + /// + /// By default a Visual does not have any children. + /// + /// Remark: + /// During this virtual method the Visual tree must not be modified. + /// + protected override int VisualChildrenCount + { + get + { + return 1; // _adorderChild created in ctor. + } + } + + /// + /// Derived class must implement to support Visual children. The method must return + /// the child at the specified index. Index must be between 0 and GetVisualChildrenCount-1. + /// + /// By default a Visual does not have any children. + /// + /// Remark: + /// During this virtual call it is not valid to modify the Visual tree. + /// + protected override Visual GetVisualChild(int index) + { + if (index == 0) + { + return _adorderChild; + } + else + { + throw new ArgumentOutOfRangeException("index"); + } + } + + private UIElement _adorderChild; + } + + private static FocusVisualAdorner _focusVisualAdornerCache = null; + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/TextBoxHelper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/TextBoxHelper.cs new file mode 100644 index 00000000000..36e84882d6c --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/TextBoxHelper.cs @@ -0,0 +1,169 @@ +using System.Windows; +using System.Windows.Controls; + +namespace PresentationFramework.Win11.Controls.Primitives +{ + public static class TextBoxHelper + { + private const string ButtonStatesGroup = "ButtonStates"; + private const string ButtonVisibleState = "ButtonVisible"; + private const string ButtonCollapsedState = "ButtonCollapsed"; + + #region IsEnabled + + public static bool GetIsEnabled(TextBox textBox) + { + return (bool)textBox.GetValue(IsEnabledProperty); + } + + public static void SetIsEnabled(TextBox textBox, bool value) + { + textBox.SetValue(IsEnabledProperty, value); + } + + public static readonly DependencyProperty IsEnabledProperty = + DependencyProperty.RegisterAttached( + "IsEnabled", + typeof(bool), + typeof(TextBoxHelper), + new PropertyMetadata(OnIsEnabledChanged)); + + private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var textBox = (TextBox)d; + + if ((bool)e.NewValue) + { + textBox.Loaded += OnLoaded; + textBox.TextChanged += OnTextChanged; + UpdateHasText(textBox); + + } + else + { + textBox.Loaded -= OnLoaded; + textBox.TextChanged -= OnTextChanged; + textBox.ClearValue(HasTextPropertyKey); + } + } + + #endregion + + #region HasText + + private static readonly DependencyPropertyKey HasTextPropertyKey = + DependencyProperty.RegisterAttachedReadOnly( + "HasText", + typeof(bool), + typeof(TextBoxHelper), + null); + + public static readonly DependencyProperty HasTextProperty = + HasTextPropertyKey.DependencyProperty; + + public static bool GetHasText(TextBox textBox) + { + return (bool)textBox.GetValue(HasTextProperty); + } + + private static void SetHasText(TextBox textBox, bool value) + { + textBox.SetValue(HasTextPropertyKey, value); + } + + private static void UpdateHasText(TextBox textBox) + { + SetHasText(textBox, !string.IsNullOrEmpty(textBox.Text)); + } + + #endregion + + #region IsDeleteButton + + public static bool GetIsDeleteButton(Button button) + { + return (bool)button.GetValue(IsDeleteButtonProperty); + } + + public static void SetIsDeleteButton(Button button, bool value) + { + button.SetValue(IsDeleteButtonProperty, value); + } + + public static readonly DependencyProperty IsDeleteButtonProperty = + DependencyProperty.RegisterAttached( + "IsDeleteButton", + typeof(bool), + typeof(TextBoxHelper), + new PropertyMetadata(OnIsDeleteButtonChanged)); + + private static void OnIsDeleteButtonChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var button = (Button)d; + + if ((bool)e.OldValue) + { + button.Click -= OnDeleteButtonClick; + } + + if ((bool)e.NewValue) + { + button.Click += OnDeleteButtonClick; + } + } + + #endregion + + #region IsDeleteButtonVisible + + public static readonly DependencyProperty IsDeleteButtonVisibleProperty = + DependencyProperty.RegisterAttached( + "IsDeleteButtonVisible", + typeof(bool), + typeof(TextBoxHelper), + new PropertyMetadata(OnIsDeleteButtonVisibleChanged)); + + public static bool GetIsDeleteButtonVisible(TextBox textBox) + { + return (bool)textBox.GetValue(IsDeleteButtonVisibleProperty); + } + + public static void SetIsDeleteButtonVisible(TextBox textBox, bool value) + { + textBox.SetValue(IsDeleteButtonVisibleProperty, value); + } + + private static void OnIsDeleteButtonVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + UpdateVisualStates((TextBox)d, (bool)e.NewValue); + } + + #endregion + + private static void OnLoaded(object sender, RoutedEventArgs e) + { + var textBox = (TextBox)sender; + UpdateVisualStates(textBox, GetIsDeleteButtonVisible(textBox)); + } + + private static void OnTextChanged(object sender, TextChangedEventArgs e) + { + var textBox = (TextBox)sender; + UpdateHasText(textBox); + } + + private static void OnDeleteButtonClick(object sender, RoutedEventArgs e) + { + var button = (Button)sender; + if (button.TemplatedParent is TextBox textBox) + { + textBox.SetCurrentValue(TextBox.TextProperty, null); + } + } + + private static void UpdateVisualStates(TextBox textBox, bool isDeleteButtonVisible) + { + VisualStateManager.GoToState(textBox, isDeleteButtonVisible ? ButtonVisibleState : ButtonCollapsedState, true); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ValidationHelper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ValidationHelper.cs new file mode 100644 index 00000000000..01d526fe1d5 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/Primitives/ValidationHelper.cs @@ -0,0 +1,46 @@ +using System.Diagnostics; +using System.Windows; +using System.Windows.Controls; + +namespace PresentationFramework.Win11.Controls.Primitives +{ + public static class ValidationHelper + { + #region IsTemplateValidationAdornerSite + + public static readonly DependencyProperty IsTemplateValidationAdornerSiteProperty = + DependencyProperty.RegisterAttached( + "IsTemplateValidationAdornerSite", + typeof(bool), + typeof(ValidationHelper), + new PropertyMetadata(OnIsTemplateValidationAdornerSiteChanged)); + + public static bool GetIsTemplateValidationAdornerSite(FrameworkElement element) + { + return (bool)element.GetValue(IsTemplateValidationAdornerSiteProperty); + } + + public static void SetIsTemplateValidationAdornerSite(FrameworkElement element, bool value) + { + element.SetValue(IsTemplateValidationAdornerSiteProperty, value); + } + + private static void OnIsTemplateValidationAdornerSiteChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var element = (FrameworkElement)d; + if ((bool)e.NewValue) + { + Debug.Assert(element.TemplatedParent != null); + Validation.SetErrorTemplate(element, null); + Validation.SetValidationAdornerSiteFor(element, element.TemplatedParent); + } + else + { + element.ClearValue(Validation.ErrorTemplateProperty); + element.ClearValue(Validation.ValidationAdornerSiteForProperty); + } + } + + #endregion + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemFontInfo.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemFontInfo.cs new file mode 100644 index 00000000000..7bb398af191 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemFontInfo.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Windows; + +namespace PresentationFramework.Win11.Controls +{ + /// + /// Represents information about the visual states of font elements that represent + /// a rating. + /// + public class RatingItemFontInfo : RatingItemInfo + { + /// + /// Initializes a new instance of the RatingItemFontInfo class. + /// + public RatingItemFontInfo() + { + } + + #region DisabledGlyph + + /// + /// Identifies the DisabledGlyph dependency property. + /// + public static readonly DependencyProperty DisabledGlyphProperty = + DependencyProperty.Register( + nameof(DisabledGlyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// that is disabled. + /// + /// The hexadecimal character code for the rating element glyph. + public string DisabledGlyph + { + get => (string)GetValue(DisabledGlyphProperty); + set => SetValue(DisabledGlyphProperty, value); + } + + #endregion + + #region Glyph + + /// + /// Identifies the Glyph dependency property. + /// + public static readonly DependencyProperty GlyphProperty = + DependencyProperty.Register( + nameof(Glyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// that has been set by the user. + /// + /// The hexadecimal character code for the rating element glyph. + public string Glyph + { + get => (string)GetValue(GlyphProperty); + set => SetValue(GlyphProperty, value); + } + + #endregion + + #region PlaceholderGlyph + + /// + /// Identifies the PlaceholderGlyph dependency property. + /// + public static readonly DependencyProperty PlaceholderGlyphProperty = + DependencyProperty.Register( + nameof(PlaceholderGlyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// that is showing a placeholder value. + /// + /// The hexadecimal character code for the rating element glyph. + public string PlaceholderGlyph + { + get => (string)GetValue(PlaceholderGlyphProperty); + set => SetValue(PlaceholderGlyphProperty, value); + } + + #endregion + + #region PointerOverGlyph + + /// + /// Identifies the PointerOverGlyph dependency property. + /// + public static readonly DependencyProperty PointerOverGlyphProperty = + DependencyProperty.Register( + nameof(PointerOverGlyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// that has the pointer over it. + /// + /// The hexadecimal character code for the rating element glyph. + public string PointerOverGlyph + { + get => (string)GetValue(PointerOverGlyphProperty); + set => SetValue(PointerOverGlyphProperty, value); + } + + #endregion + + #region PointerOverPlaceholderGlyph + + /// + /// Identifies the PointerOverPlaceholderGlyph dependency property. + /// + public static readonly DependencyProperty PointerOverPlaceholderGlyphProperty = + DependencyProperty.Register( + nameof(PointerOverPlaceholderGlyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// showing a placeholder value with the pointer over it. + /// + /// The hexadecimal character code for the rating element glyph. + public string PointerOverPlaceholderGlyph + { + get => (string)GetValue(PointerOverPlaceholderGlyphProperty); + set => SetValue(PointerOverPlaceholderGlyphProperty, value); + } + + #endregion + + #region UnsetGlyph + + /// + /// Identifies the UnsetGlyph dependency property. + /// + public static readonly DependencyProperty UnsetGlyphProperty = + DependencyProperty.Register( + nameof(UnsetGlyph), + typeof(string), + typeof(RatingItemFontInfo), + new PropertyMetadata(string.Empty)); + + /// + /// Gets or sets a Segoe MDL2 Assets font glyph that represents a rating element + /// that has not been set. + /// + /// The hexadecimal character code for the rating element glyph. + public string UnsetGlyph + { + get => (string)GetValue(UnsetGlyphProperty); + set => SetValue(UnsetGlyphProperty, value); + } + + #endregion + + protected override Freezable CreateInstanceCore() + { + return new RatingItemFontInfo(); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemInfo.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemInfo.cs new file mode 100644 index 00000000000..bec8d951dca --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemInfo.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Windows; + +namespace PresentationFramework.Win11.Controls +{ + /// + /// Represents information about the visual states of the elements that represent + /// a rating. + /// + public class RatingItemInfo : Freezable + { + /// + /// Initializes a new instance of the RatingItemInfo class. + /// + public RatingItemInfo() + { + } + + protected override Freezable CreateInstanceCore() + { + return new RatingItemInfo(); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemPathInfo.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemPathInfo.cs new file mode 100644 index 00000000000..aa194263d61 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/RatingItemPathInfo.cs @@ -0,0 +1,119 @@ +using System.Windows; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Controls +{ + public class RatingItemPathInfo : RatingItemInfo + { + public RatingItemPathInfo() + { + } + + #region DisabledData + + public static readonly DependencyProperty DisabledDataProperty = + DependencyProperty.Register( + nameof(DisabledData), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry DisabledData + { + get => (Geometry)GetValue(DisabledDataProperty); + set => SetValue(DisabledDataProperty, value); + } + + #endregion + + #region Data + + public static readonly DependencyProperty DataProperty = + DependencyProperty.Register( + nameof(Data), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry Data + { + get => (Geometry)GetValue(DataProperty); + set => SetValue(DataProperty, value); + } + + #endregion + + #region PlaceholderData + + public static readonly DependencyProperty PlaceholderDataProperty = + DependencyProperty.Register( + nameof(PlaceholderData), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry PlaceholderData + { + get => (Geometry)GetValue(PlaceholderDataProperty); + set => SetValue(PlaceholderDataProperty, value); + } + + #endregion + + #region PointerOverData + + public static readonly DependencyProperty PointerOverDataProperty = + DependencyProperty.Register( + nameof(PointerOverData), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry PointerOverData + { + get => (Geometry)GetValue(PointerOverDataProperty); + set => SetValue(PointerOverDataProperty, value); + } + + #endregion + + #region PointerOverPlaceholderData + + public static readonly DependencyProperty PointerOverPlaceholderDataProperty = + DependencyProperty.Register( + nameof(PointerOverPlaceholderData), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry PointerOverPlaceholderData + { + get => (Geometry)GetValue(PointerOverPlaceholderDataProperty); + set => SetValue(PointerOverPlaceholderDataProperty, value); + } + + #endregion + + #region UnsetData + + public static readonly DependencyProperty UnsetDataProperty = + DependencyProperty.Register( + nameof(UnsetData), + typeof(Geometry), + typeof(RatingItemPathInfo), + null); + + public Geometry UnsetData + { + get => (Geometry)GetValue(UnsetDataProperty); + set => SetValue(UnsetDataProperty, value); + } + + #endregion + + protected override Freezable CreateInstanceCore() + { + return new RatingItemPathInfo(); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/Helper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/Helper.cs new file mode 100644 index 00000000000..d64b82d7b2f --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/Helper.cs @@ -0,0 +1,120 @@ +using System; +using System.Diagnostics; +using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; + +namespace PresentationFramework.Win11 +{ + internal static class Helper + { + public static bool IsAnimationsEnabled => SystemParameters.ClientAreaAnimation && + RenderCapability.Tier > 0; + + public static bool TryGetTransformToDevice(Visual visual, out Matrix value) + { + var presentationSource = PresentationSource.FromVisual(visual); + if (presentationSource != null) + { + value = presentationSource.CompositionTarget.TransformToDevice; + return true; + } + + value = default; + return false; + } + + public static Vector GetOffset( + UIElement element1, + InterestPoint interestPoint1, + UIElement element2, + InterestPoint interestPoint2, + Rect element2Bounds) + { + Point point = element1.TranslatePoint(GetPoint(element1, interestPoint1), element2); + if (element2Bounds.IsEmpty) + { + return point - GetPoint(element2, interestPoint2); + } + else + { + return point - GetPoint(element2Bounds, interestPoint2); + } + } + + private static Point GetPoint(UIElement element, InterestPoint interestPoint) + { + return GetPoint(new Rect(element.RenderSize), interestPoint); + } + + private static Point GetPoint(Rect rect, InterestPoint interestPoint) + { + switch (interestPoint) + { + case InterestPoint.TopLeft: + return rect.TopLeft; + case InterestPoint.TopRight: + return rect.TopRight; + case InterestPoint.BottomLeft: + return rect.BottomLeft; + case InterestPoint.BottomRight: + return rect.BottomRight; + case InterestPoint.Center: + return new Point(rect.Left + rect.Width / 2, + rect.Top + rect.Height / 2); + default: + throw new ArgumentOutOfRangeException(nameof(interestPoint)); + } + } + + public static bool HasDefaultValue(this DependencyObject d, DependencyProperty dp) + { + return DependencyPropertyHelper.GetValueSource(d, dp).BaseValueSource == BaseValueSource.Default; + } + + // return true if there is a local or style-supplied value for the dp + public static bool HasNonDefaultValue(this DependencyObject d, DependencyProperty dp) + { + return !HasDefaultValue(d, dp); + } + + public static bool HasLocalValue(this DependencyObject d, DependencyProperty dp) + { + return d.ReadLocalValue(dp) != DependencyProperty.UnsetValue; + } + + public static DpiScale2 GetDpi(this Window window) + { + if (window is null) + { + throw new ArgumentNullException(nameof(window)); + } + +#if NET462_OR_NEWER + return new DpiScale2(VisualTreeHelper.GetDpi(window)); +#else + var hwnd = new WindowInteropHelper(window).Handle; + var hwndSource = HwndSource.FromHwnd(hwnd); + if (hwndSource != null) + { + Matrix transformToDevice = hwndSource.CompositionTarget.TransformToDevice; + return new DpiScale2(transformToDevice.M11, transformToDevice.M22); + } + else + { + Debug.Fail("Should not reach here"); + return new DpiScale2(1, 1); + } +#endif + } + } + + internal enum InterestPoint + { + TopLeft = 0, + TopRight = 1, + BottomLeft = 2, + BottomRight = 3, + Center = 4, + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/ThemeResourceHelper.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/ThemeResourceHelper.cs new file mode 100644 index 00000000000..01b3479eb8a --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Helpers/ThemeResourceHelper.cs @@ -0,0 +1,24 @@ +using System.Windows; +using System.Windows.Media; + +namespace PresentationFramework.Win11 +{ + internal static class ThemeResourceHelper + { + private static readonly DependencyProperty ColorKeyProperty = + DependencyProperty.RegisterAttached( + "ColorKey", + typeof(object), + typeof(ThemeResourceHelper)); + + internal static object GetColorKey(SolidColorBrush element) + { + return element.GetValue(ColorKeyProperty); + } + + internal static void SetColorKey(SolidColorBrush element, object value) + { + element.SetValue(ColorKeyProperty, value); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/DynamicColorExtension.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/DynamicColorExtension.cs new file mode 100644 index 00000000000..299895e4274 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/DynamicColorExtension.cs @@ -0,0 +1,67 @@ +using System; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.Globalization; +using System.Windows; +using System.Windows.Markup; +using System.Windows.Media; +namespace PresentationFramework.Win11.Markup +{ + [TypeConverter(typeof(DynamicColorExtensionConverter))] + public class DynamicColorExtension : DynamicResourceExtension + { + public DynamicColorExtension() + { + } + + public DynamicColorExtension(object resourceKey) : base(resourceKey) + { + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + object value = base.ProvideValue(serviceProvider); + + if (serviceProvider?.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget) + { + if (provideValueTarget.TargetObject is SolidColorBrush solidColorBrush) + { + ThemeResourceHelper.SetColorKey(solidColorBrush, ResourceKey); + } + } + + return value; + } + } + + public class DynamicColorExtensionConverter : TypeConverter + { + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } + return base.CanConvertTo(context, destinationType); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(InstanceDescriptor)) + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + DynamicColorExtension dynamicResource = value as DynamicColorExtension; + + if (dynamicResource == null) + + throw new ArgumentException($"{value} must be of type {nameof(DynamicColorExtension)}", nameof(value)); + + return new InstanceDescriptor(typeof(DynamicColorExtension).GetConstructor(new Type[] { typeof(object) }), + new object[] { dynamicResource.ResourceKey }); + } + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/KeyTimeExtension.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/KeyTimeExtension.cs new file mode 100644 index 00000000000..4323db92540 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/KeyTimeExtension.cs @@ -0,0 +1,21 @@ +using System; +using System.Windows.Markup; +using System.Windows.Media.Animation; + +namespace ModernWpf.Markup +{ + [MarkupExtensionReturnType(typeof(KeyTime))] + public class KeyTimeExtension : MarkupExtension + { + public KeyTimeExtension() + { + } + + public TimeSpan TimeSpan { get; set; } = TimeSpan.Zero; + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return KeyTime.FromTimeSpan(TimeSpan); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticColorExtension.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticColorExtension.cs new file mode 100644 index 00000000000..fdac0bd9b61 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticColorExtension.cs @@ -0,0 +1,32 @@ +using System; +using System.Windows.Markup; +using System.Windows.Media; + +namespace PresentationFramework.Win11.Markup +{ + public class StaticColorExtension : System.Windows.StaticResourceExtension + { + public StaticColorExtension() + { + } + + public StaticColorExtension(object resourceKey) : base(resourceKey) + { + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + object value = base.ProvideValue(serviceProvider); + + if (serviceProvider?.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget) + { + if (provideValueTarget.TargetObject is SolidColorBrush solidColorBrush) + { + ThemeResourceHelper.SetColorKey(solidColorBrush, ResourceKey); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticResourceExtension.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticResourceExtension.cs new file mode 100644 index 00000000000..fe44b5a494e --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/StaticResourceExtension.cs @@ -0,0 +1,13 @@ +namespace PresentationFramework.Win11.Markup +{ + public class StaticResourceExtension : System.Windows.StaticResourceExtension + { + public StaticResourceExtension() + { + } + + public StaticResourceExtension(object resourceKey) : base(resourceKey) + { + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/ThemeResourceExtension.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/ThemeResourceExtension.cs new file mode 100644 index 00000000000..269a0f7e587 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Markup/ThemeResourceExtension.cs @@ -0,0 +1,95 @@ +using System; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; + +namespace ModernWpf.Markup +{ + [TypeConverter(typeof(ThemeResouceExtensionConverter))] + public class ThemeResourceExtension : DynamicResourceExtension + { + public ThemeResourceExtension() + { + } + + public ThemeResourceExtension(object resourceKey) : base(resourceKey) + { + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (ResourceKey is string key && key.StartsWith("SystemColor", StringComparison.Ordinal)) + { + var binding = new Binding(key) { Source = SystemColorsSource.Current }; + return binding.ProvideValue(serviceProvider); + } + + return base.ProvideValue(serviceProvider); + } + + private class SystemColorsSource : INotifyPropertyChanged + { + private SystemColorsSource() + { + SystemParameters.StaticPropertyChanged += OnSystemParametersPropertyChanged; + } + + public static SystemColorsSource Current { get; } = new SystemColorsSource(); + + public Color SystemColorButtonFaceColor => SystemColors.ControlColor; + public Color SystemColorButtonTextColor => SystemColors.ControlTextColor; + public Color SystemColorGrayTextColor => SystemColors.GrayTextColor; + public Color SystemColorHighlightColor => SystemColors.HighlightColor; + public Color SystemColorHighlightTextColor => SystemColors.HighlightTextColor; + public Color SystemColorHotlightColor => SystemColors.HotTrackColor; + public Color SystemColorWindowColor => SystemColors.WindowColor; + public Color SystemColorWindowTextColor => SystemColors.WindowTextColor; + public Color SystemColorActiveCaptionColor => SystemColors.ActiveCaptionColor; + public Color SystemColorInactiveCaptionTextColor => SystemColors.InactiveCaptionTextColor; + + public event PropertyChangedEventHandler PropertyChanged; + + private void OnSystemParametersPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(SystemParameters.HighContrast) && SystemParameters.HighContrast) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null)); + } + } + } + } + + public class ThemeResouceExtensionConverter : TypeConverter + { + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } + return base.CanConvertTo(context, destinationType); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(InstanceDescriptor)) + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + ThemeResourceExtension dynamicResource = value as ThemeResourceExtension; + + if (dynamicResource == null) + + throw new ArgumentException($"{value} must be of type {nameof(ThemeResourceExtension)}", nameof(value)); + + return new InstanceDescriptor(typeof(ThemeResourceExtension).GetConstructor(new Type[] { typeof(object) }), + new object[] { dynamicResource.ResourceKey }); + } + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj index ed7b9b4a717..f370431afda 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -2,10 +2,6 @@ - - Wpf.Ui-ref - $(TargetGroup)-$(PackageId)/ - None AnyCPU;x64;arm64 false @@ -14,52 +10,23 @@ $(DefineConstants);THEME_WIN11 false + + + true + true + false + - - - - + MSBuild:Compile - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -69,6 +36,9 @@ + + false + @@ -89,7 +59,6 @@ - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml new file mode 100644 index 00000000000..00397f1bb0f --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml @@ -0,0 +1,127 @@ + + + + 11,5,11,6 + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml new file mode 100644 index 00000000000..a07efe88142 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -0,0 +1,234 @@ + + + + 0,0,0,4 + 0,4,4,4 + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 13a597c8248c531f32bccbdb03822b91f19d6d7e Mon Sep 17 00:00:00 2001 From: Anjali Date: Wed, 3 Jan 2024 19:58:43 +0530 Subject: [PATCH 046/185] Fixed win11 theming changes for ListView and ListViewItem (#8629) * Added win11 styles for ListView and ListViewItem * Updated header information and namespace for controls : Calendar, DataGrid, DatePicker, Expander, MenuItem, RichTextBox, ScrollBar, ScrollViewer, Separator --- .../Styles/Calendar.xaml | 25 +- .../Styles/DataGrid.xaml | 38 +- .../Styles/DatePicker.xaml | 11 +- .../Styles/Expander.xaml | 21 +- .../Styles/ListView.xaml | 95 ++-- .../Styles/ListViewItem.xaml | 407 ++---------------- .../Styles/MenuItem.xaml | 17 +- .../Styles/RichTextBox.xaml | 19 +- .../Styles/ScrollBar.xaml | 21 +- .../Styles/ScrollViewer.xaml | 10 +- .../Styles/Separator.xaml | 11 +- 11 files changed, 173 insertions(+), 502 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml index 7e7e917db41..4230081784a 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml @@ -7,8 +7,7 @@ + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml index 0f8b7d1fef9..b838d412538 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml @@ -1,17 +1,23 @@ - - - + + @@ -726,9 +732,9 @@ - + - + @@ -752,7 +758,7 @@ - + #FFFF0000 @@ -809,7 +815,7 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding Border.CornerRadius}"> - - + - - + + @@ -907,13 +913,13 @@ - - - - + + From 598a981eee501dea167853557cc7277dd6cfe471 Mon Sep 17 00:00:00 2001 From: hmishra Date: Fri, 22 Dec 2023 15:41:58 +0530 Subject: [PATCH 047/185] Fixing Api Compat Failure Removing unwanted references --- .../PresentationFramework-ref.baseline.txt | 3 +- .../PresentationFramework.csproj | 1 - .../Windows/Controls/BrushToColorConverter.cs | 42 ------------------- .../Styles/ListBoxItem.xaml | 5 +-- 4 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/BrushToColorConverter.cs diff --git a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt index 4a62c93adfc..28cfcce0c89 100644 --- a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt +++ b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt @@ -82,6 +82,7 @@ MembersMustExist : Member 'internal System.Collections.Generic.List - diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/BrushToColorConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/BrushToColorConverter.cs deleted file mode 100644 index ff229d31249..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/BrushToColorConverter.cs +++ /dev/null @@ -1,42 +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. - -using System.Globalization; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Media; -using System.Windows.Shapes; - -namespace System.Windows.Controls; - -public class BrushToColorConverter : IValueConverter -{ - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is SolidColorBrush brush) - { - return brush.Color; - } - - if (value is Color) - { - return value; - } - - // We draw red to visibly see an invalid bind in the UI. - return new Color - { - A = 255, - R = 255, - G = 0, - B = 0 - }; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ListBoxItem.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ListBoxItem.xaml index 1b34eff4807..e505aaa890a 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ListBoxItem.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ListBoxItem.xaml @@ -7,10 +7,7 @@ - - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - + --> + + + + + + + From 0759d47107016c57e67bb0fbb3cbc6b159e48ae4 Mon Sep 17 00:00:00 2001 From: Anjali Date: Thu, 11 Jan 2024 14:28:34 +0530 Subject: [PATCH 062/185] Adding win11 styles to PasswordBox (#8612) * Added TextBox styles Todo: Clear button not showing up * Added styles for PasswordBox Todo: Reveal button functionality not supported --- .../PresentationFramework-ref.baseline.txt | 15 +- .../PresentationFramework.csproj | 1 + .../System/Windows/Controls/PasswordBox.cs | 80 ++++- .../System/Windows/ElementPlacement.cs | 24 ++ .../Styles/PasswordBox.xaml | 281 ++++++++++++++++++ .../Styles/TextBox.xaml | 2 +- 6 files changed, 399 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ElementPlacement.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml diff --git a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt index 7d0b04ebe0e..ebb1d41a9db 100644 --- a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt +++ b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt @@ -7,6 +7,7 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DataTrigger.Binding' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.DataTrigger.Setters' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DataTrigger.Value' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation. +TypesMustExist : Type 'System.Windows.ElementPlacement' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.EventTrigger.Actions' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. @@ -193,8 +194,20 @@ CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'S CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Panel' changed from '[LocalizabilityAttribute(16)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Ignore)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.Panel.Children' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. TypesMustExist : Type 'System.Windows.Controls.PassiveScrollViewer' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.IconPlacementProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.IconProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.PlaceholderEnabledProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.PlaceholderTextProperty' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.PasswordBox.Password' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.PasswordBox.SecurePassword' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. +MembersMustExist : Member 'public System.Windows.Controls.IconElement System.Windows.Controls.PasswordBox.Icon.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.Icon.set(System.Windows.Controls.IconElement)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Controls.ElementPlacement System.Windows.Controls.PasswordBox.IconPlacement.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.IconPlacement.set(System.Windows.Controls.ElementPlacement)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Boolean System.Windows.Controls.PasswordBox.PlaceholderEnabled.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.PlaceholderEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.String System.Windows.Controls.PasswordBox.PlaceholderText.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.PlaceholderText.set(System.String)' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton' changed from '[LocalizabilityAttribute(9)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.RadioButton)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton.GroupName' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RichTextBox' changed from '[LocalizabilityAttribute(15)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Inherit)]' in the implementation. @@ -360,4 +373,4 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi CannotChangeAttribute : Attribute 'System.Windows.Markup.DesignerSerializationOptionsAttribute' on 'System.Windows.Markup.XmlAttributeProperties.GetXmlSpace(System.Windows.DependencyObject)' changed from '[DesignerSerializationOptionsAttribute(1)]' in the contract to '[DesignerSerializationOptionsAttribute(DesignerSerializationOptions.SerializeAsAttribute)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Media.Animation.Storyboard.GetTarget(System.Windows.DependencyObject)' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Shapes.Shape' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation. -Total Issues: 361 +Total Issues: 374 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index da3f94ce4fa..a15f64d9792 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -416,6 +416,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs index 2eb7a6eb5e1..ce8e33e5ed8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs @@ -63,7 +63,7 @@ static PasswordBox() PasswordCharProperty.OverrideMetadata(typeof(PasswordBox), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPasswordCharChanged))); - // Declaree listener for Padding property + // Declare listener for Padding property Control.PaddingProperty.OverrideMetadata(typeof(PasswordBox), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPaddingChanged))); @@ -347,6 +347,82 @@ public bool IsSelectionActive get { return (bool)GetValue(IsSelectionActiveProperty); } } + /// + /// Defines which side the icon should be placed on. + /// + public ElementPlacement IconPlacement + { + get => (ElementPlacement)GetValue(IconPlacementProperty); + set => SetValue(IconPlacementProperty, value); + } + + /// + /// Property for . + /// + public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register( + nameof(IconPlacement), + typeof(ElementPlacement), + typeof(PasswordBox), + new PropertyMetadata(ElementPlacement.Left) + ); + + /// + /// Gets or sets displayed . + /// + public IconElement Icon + { + get => (IconElement)GetValue(IconProperty); + set => SetValue(IconProperty, value); + } + + /// + /// Property for . + /// + public static readonly DependencyProperty IconProperty = DependencyProperty.Register( + nameof(Icon), + typeof(IconElement), + typeof(PasswordBox), + new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) + ); + + /// + /// Gets or sets numbers pattern. + /// + public string PlaceholderText + { + get => (string)GetValue(PlaceholderTextProperty); + set => SetValue(PlaceholderTextProperty, value); + } + + /// + /// Property for . + /// + public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register( + nameof(PlaceholderText), + typeof(string), + typeof(PasswordBox), + new PropertyMetadata(String.Empty) + ); + + /// + /// Gets or sets a value determining whether to display the placeholder. + /// + public bool PlaceholderEnabled + { + get => (bool)GetValue(PlaceholderEnabledProperty); + set => SetValue(PlaceholderEnabledProperty, value); + } + + /// + /// Property for . + /// + public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register( + nameof(PlaceholderEnabled), + typeof(bool), + typeof(PasswordBox), + new PropertyMetadata(true) + ); + /// /// /// @@ -854,7 +930,7 @@ private void Initialize() // PasswordBox only accepts plain text, so change TextEditor's default to that. _textEditor.AcceptsRichContent = false; - // PasswordBox does not accetps tabs. + // PasswordBox does not accepts tabs. _textEditor.AcceptsTab = false; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ElementPlacement.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ElementPlacement.cs new file mode 100644 index 00000000000..2868c81a8a8 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ElementPlacement.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace System.Windows +{ + /// + /// Decides where to put the element. + /// + public enum ElementPlacement + { + /// + /// Puts the control element on the left. + /// + Left, + + /// + /// Puts the control element on the right. + /// + Right + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml new file mode 100644 index 00000000000..fdb759a9799 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml @@ -0,0 +1,281 @@ + + + + + 1,1,1,0 + 0,0,0,1 + 10,8,0,0 + 0,8,10,0 + 0,5,4,0 + 0,0,0,0 + 24 + 14 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml new file mode 100644 index 00000000000..38aa4583a76 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml new file mode 100644 index 00000000000..c320044baf3 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Paragraph.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Paragraph.xaml new file mode 100644 index 00000000000..f833e3de957 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Paragraph.xaml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Underline.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Underline.xaml new file mode 100644 index 00000000000..ed44f08f4dd --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Underline.xaml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file From 8a691d6058a7aa8cefdd7bce124a8587eb7d968b Mon Sep 17 00:00:00 2001 From: hmishra Date: Thu, 18 Jan 2024 10:22:58 +0530 Subject: [PATCH 066/185] Add(Win11Theming): DocumentViewer, Hyperlink, List, ResizeGrip and Thumb Styles --- .../Styles/DocumentViewer.xaml | 84 +++++++++++++++++++ .../Styles/Hyperlink.xaml | 35 ++++++++ .../Styles/List.xaml | 12 +++ .../Styles/ResizeGrip.xaml | 43 ++++++++++ .../Styles/Thumb.xaml | 35 ++++++++ 5 files changed, 209 insertions(+) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ResizeGrip.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Thumb.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml new file mode 100644 index 00000000000..1f6dd062136 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml @@ -0,0 +1,84 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml new file mode 100644 index 00000000000..c1fa27e643b --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml new file mode 100644 index 00000000000..6f9b23a50d2 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ResizeGrip.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ResizeGrip.xaml new file mode 100644 index 00000000000..48b97e8f996 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ResizeGrip.xaml @@ -0,0 +1,43 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Thumb.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Thumb.xaml new file mode 100644 index 00000000000..8a52e9d4b8c --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Thumb.xaml @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file From 8e89ddc0170eb2d61a0799d20442bfe0a8971e61 Mon Sep 17 00:00:00 2001 From: hmishra Date: Thu, 18 Jan 2024 10:34:51 +0530 Subject: [PATCH 067/185] Add(Win11Theming): ContentControl, GridSplitter, GroupBox, GroupItem and HeaderedContentControl Styles --- .../Styles/ContentControl.xaml | 17 ++++ .../Styles/GridSplitter.xaml | 33 +++++++ .../Styles/GroupBox.xaml | 91 +++++++++++++++++++ .../Styles/GroupItem.xaml | 21 +++++ .../Styles/HeaderedContentControl.xaml | 20 ++++ 5 files changed, 182 insertions(+) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContentControl.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContentControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContentControl.xaml new file mode 100644 index 00000000000..024d9706b5a --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContentControl.xaml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml new file mode 100644 index 00000000000..27484c3082f --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml @@ -0,0 +1,33 @@ + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml new file mode 100644 index 00000000000..a8f8d234457 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml @@ -0,0 +1,91 @@ + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml new file mode 100644 index 00000000000..8c53ac65823 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml new file mode 100644 index 00000000000..ec19c931e55 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file From 81dded158ad0d2e8e1a37c4ee756f8a1d60e1fa8 Mon Sep 17 00:00:00 2001 From: hmishra Date: Thu, 18 Jan 2024 11:07:16 +0530 Subject: [PATCH 068/185] Add(Win11Theming): Border, ButtonBase, Control, ItemsControl, TextBoxBase, UserControl Styles --- .../Styles/Border.xaml | 17 +++++ .../Styles/ButtonBase.xaml | 65 ++++++++++++++++ .../Styles/Control.xaml | 27 +++++++ .../Styles/ItemsControl.xaml | 24 ++++++ .../Styles/TextBoxBase.xaml | 75 +++++++++++++++++++ .../Styles/UserControl.xaml | 26 +++++++ 6 files changed, 234 insertions(+) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Control.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBoxBase.xaml create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/UserControl.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml new file mode 100644 index 00000000000..b944b9ea71f --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml new file mode 100644 index 00000000000..c24327c22e0 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Control.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Control.xaml new file mode 100644 index 00000000000..ee184033059 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Control.xaml @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml new file mode 100644 index 00000000000..f657f7fbebb --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBoxBase.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBoxBase.xaml new file mode 100644 index 00000000000..6b15418ffff --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBoxBase.xaml @@ -0,0 +1,75 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/UserControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/UserControl.xaml new file mode 100644 index 00000000000..3a29c93f73a --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/UserControl.xaml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file From 9b514fa219d8ee9e2c37e082d2fdf41b233dc190 Mon Sep 17 00:00:00 2001 From: hmishra Date: Thu, 18 Jan 2024 12:49:04 +0530 Subject: [PATCH 069/185] Add(Win11Theming): NavigationWindow Styles --- .../Microsoft/Windows/Themes/ButtonChrome.cs | 1180 +++++++++++++++++ .../Microsoft/Windows/Themes/ListBoxChrome.cs | 693 ++++++++++ .../PresentationFramework.Win11.csproj | 1 + .../PresentationFramework.Win11.xaml | 22 + .../Styles/ButtonBase.xaml | 4 +- .../Styles/DocumentViewer.xaml | 4 +- .../Styles/NavigationWindow.xaml | 546 ++++++++ .../Styles/ResizeGrip.xaml | 14 + .../Styles/TextBoxBase.xaml | 4 +- 9 files changed, 2465 insertions(+), 3 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs new file mode 100644 index 00000000000..f63188cd8a4 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs @@ -0,0 +1,1180 @@ +// 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.Windows.Shapes; +using System.Windows.Controls; +using System.Diagnostics; +using System.Threading; + +using System.ComponentModel; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Animation; +using MS.Internal; + +using System; + +using System.Runtime.InteropServices; +using System.Security; + +namespace Microsoft.Windows.Themes +{ + /// + /// The ButtonChrome element + /// This element is a theme-specific type that is used as an optimization + /// for a common complex rendering used in Windows 11 themes + /// + /// + public sealed class ButtonChrome : Decorator + { + #region Constructors + + static ButtonChrome() + { + IsEnabledProperty.OverrideMetadata(typeof(ButtonChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); + } + + /// + /// Instantiates a new instance of a ButtonChrome with no parent element. + /// + /// + public ButtonChrome() + { + } + + #endregion Constructors + + #region Dynamic Properties + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty BackgroundProperty = + Control.BackgroundProperty.AddOwner( + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + null, + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// The Background property defines the brush used to fill the background of the button. + /// + public Brush Background + { + get { return (Brush) GetValue(BackgroundProperty); } + set { SetValue(BackgroundProperty, value); } + } + + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty BorderBrushProperty = + Border.BorderBrushProperty.AddOwner( + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + null, + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// The BorderBrush property defines the brush used to draw the outer border. + /// + public Brush BorderBrush + { + get { return (Brush) GetValue(BorderBrushProperty); } + set { SetValue(BorderBrushProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RenderDefaultedProperty = + DependencyProperty.Register("RenderDefaulted", + typeof(bool), + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + false, + new PropertyChangedCallback(OnRenderDefaultedChanged))); + + /// + /// When true the chrome renders with a mouse over look. + /// + public bool RenderDefaulted + { + get { return (bool)GetValue(RenderDefaultedProperty); } + set { SetValue(RenderDefaultedProperty, value); } + } + + private static void OnRenderDefaultedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + ButtonChrome chrome = ((ButtonChrome)o); + + if (chrome.Animates) + { + if (((bool)e.NewValue)) + { + if (chrome._localResources == null) + { + chrome._localResources = new LocalResources(); + chrome.InvalidateVisual(); + } + + Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); + + ColorAnimation ca = new ColorAnimation(Color.FromArgb(0xF9, 0x00, 0xCC, 0xFF), duration); + GradientStopCollection gsc = ((LinearGradientBrush)chrome.InnerBorderPen.Brush).GradientStops; + gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); + + if (!chrome.RenderPressed) + { + // Create a repeating animation like: + // __/ \__/ \__/ \__... + DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames(); + daukf.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.5))); + daukf.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.75))); + daukf.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(2.0))); + daukf.RepeatBehavior = RepeatBehavior.Forever; + DoubleAnimationUsingKeyFrames.SetDesiredFrameRate(daukf, 10); + + chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, daukf); + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, daukf); + } + } + else if (chrome._localResources == null) + { + if (!chrome.RenderPressed) + { + chrome.InvalidateVisual(); + } + } + else + { + Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); + + if (!chrome.RenderPressed) + { + DoubleAnimation da = new DoubleAnimation(); + da.Duration = duration; + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + } + + ColorAnimation ca = new ColorAnimation(); + ca.Duration = duration; + GradientStopCollection gsc = ((LinearGradientBrush)chrome.InnerBorderPen.Brush).GradientStops; + gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); + } + } + else + { + chrome._localResources = null; + chrome.InvalidateVisual(); + } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RenderMouseOverProperty = + DependencyProperty.Register("RenderMouseOver", + typeof(bool), + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + false, + new PropertyChangedCallback(OnRenderMouseOverChanged))); + + /// + /// When true the chrome renders with a mouse over look. + /// + public bool RenderMouseOver + { + get { return (bool)GetValue(RenderMouseOverProperty); } + set { SetValue(RenderMouseOverProperty, value); } + } + + private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + ButtonChrome chrome = ((ButtonChrome)o); + + if (chrome.Animates) + { + if (!chrome.RenderPressed) + { + if (((bool)e.NewValue)) + { + if (chrome._localResources == null) + { + chrome._localResources = new LocalResources(); + chrome.InvalidateVisual(); + } + + Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); + + DoubleAnimation da = new DoubleAnimation(1, duration); + + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + } + else if (chrome._localResources == null) + { + chrome.InvalidateVisual(); + } + else + { + if (chrome.RenderDefaulted) + { + // Since the mouse was over the button the opacity should be 1.0 + // Create a repeating animation like: + // \__/ \__/ \__/ \_... + // But if the user quickly mouses over a button, the opacity may not be 1 yet + // so the first keyframe brings the opacity to 1 + double currentOpacity = chrome.BackgroundOverlay.Opacity; + + // This is the time needed to complete the animation to 1: + double to1 = (1.0 - currentOpacity) * 0.5; + + DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames(); + daukf.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(to1))); + daukf.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(to1 + 0.25))); + daukf.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(to1 + 1.5))); + daukf.KeyFrames.Add(new LinearDoubleKeyFrame(currentOpacity, TimeSpan.FromSeconds(2))); + daukf.RepeatBehavior = RepeatBehavior.Forever; + DoubleAnimationUsingKeyFrames.SetDesiredFrameRate(daukf, 10); + chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, daukf); + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, daukf); + } + else + { + Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); + + DoubleAnimation da = new DoubleAnimation(); + da.Duration = duration; + + chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); + } + } + } + } + else + { + chrome._localResources = null; + chrome.InvalidateVisual(); + } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RenderPressedProperty = + DependencyProperty.Register("RenderPressed", + typeof(bool), + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + false, + new PropertyChangedCallback(OnRenderPressedChanged))); + + /// + /// When true the chrome renders with a pressed look. + /// + public bool RenderPressed + { + get { return (bool)GetValue(RenderPressedProperty); } + set { SetValue(RenderPressedProperty, value); } + } + + private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + ButtonChrome chrome = ((ButtonChrome)o); + + if (chrome.Animates) + { + if (((bool)e.NewValue)) + { + if (chrome._localResources == null) + { + chrome._localResources = new LocalResources(); + chrome.InvalidateVisual(); + } + + Duration duration = new Duration(TimeSpan.FromSeconds(0.1)); + + DoubleAnimation da = new DoubleAnimation(1, duration); + + chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.LeftDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + chrome.TopDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + + da = new DoubleAnimation(0, duration); + chrome.InnerBorderPen.Brush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + + ColorAnimation ca = new ColorAnimation(Color.FromRgb(0xC2, 0xE4, 0xF6), duration); + GradientStopCollection gsc = ((LinearGradientBrush)chrome.BackgroundOverlay).GradientStops; + gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); + + ca = new ColorAnimation(Color.FromRgb(0xAB, 0xDA, 0xF3), duration); + gsc[2].BeginAnimation(GradientStop.ColorProperty, ca); + + ca = new ColorAnimation(Color.FromRgb(0x90, 0xCB, 0xEB), duration); + gsc[3].BeginAnimation(GradientStop.ColorProperty, ca); + + ca = new ColorAnimation(Color.FromRgb(0x2C, 0x62, 0x8B), duration); + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, ca); + } + else if (chrome._localResources == null) + { + chrome.InvalidateVisual(); + } + else + { + bool renderMouseOver = chrome.RenderMouseOver; + Duration duration = new Duration(TimeSpan.FromSeconds(0.1)); + + DoubleAnimation da = new DoubleAnimation(); + da.Duration = duration; + chrome.LeftDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + chrome.TopDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + chrome.InnerBorderPen.Brush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); + + if (!renderMouseOver) + { + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); + chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); + } + + ColorAnimation ca = new ColorAnimation(); + ca.Duration = duration; + chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, ca); + + GradientStopCollection gsc = ((LinearGradientBrush)chrome.BackgroundOverlay).GradientStops; + gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[2].BeginAnimation(GradientStop.ColorProperty, ca); + gsc[3].BeginAnimation(GradientStop.ColorProperty, ca); + } + } + else + { + chrome._localResources = null; + chrome.InvalidateVisual(); + } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RoundCornersProperty = + DependencyProperty.Register("RoundCorners", + typeof(bool), + typeof(ButtonChrome), + new FrameworkPropertyMetadata( + true, + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// When true, the left border will have round corners, otherwise they will be square. + /// + public bool RoundCorners + { + get { return (bool)GetValue(RoundCornersProperty); } + set { SetValue(RoundCornersProperty, value); } + } + + #endregion Dynamic Properties + + #region Protected Methods + + /// + /// Updates DesiredSize of the ButtonChrome. Called by parent UIElement. This is the first pass of layout. + /// + /// + /// ButtonChrome basically inflates the desired size of its one child by 2 on all four sides + /// + /// Available size is an "upper limit" that the return value should not exceed. + /// The ButtonChrome's desired size. + protected override Size MeasureOverride(Size availableSize) + { + Size desired; + UIElement child = Child; + if (child != null) + { + Size childConstraint = new Size(); + bool isWidthTooSmall = (availableSize.Width < 4.0); + bool isHeightTooSmall = (availableSize.Height < 4.0); + + if (!isWidthTooSmall) + { + childConstraint.Width = availableSize.Width - 4.0; + } + if (!isHeightTooSmall) + { + childConstraint.Height = availableSize.Height - 4.0; + } + + child.Measure(childConstraint); + + desired = child.DesiredSize; + + if (!isWidthTooSmall) + { + desired.Width += 4.0; + } + if (!isHeightTooSmall) + { + desired.Height += 4.0; + } + } + else + { + desired = new Size(Math.Min(4.0, availableSize.Width), Math.Min(4.0, availableSize.Height)); + } + + return desired; + } + + /// + /// ButtonChrome computes the position of its single child inside child's Margin and calls Arrange + /// on the child. + /// + /// + /// ButtonChrome basically inflates the desired size of its one child by 2 on all four sides + /// + /// Size the ContentPresenter will assume. + protected override Size ArrangeOverride(Size finalSize) + { + Rect childArrangeRect = new Rect(); + + childArrangeRect.Width = Math.Max(0d, finalSize.Width - 4.0); + childArrangeRect.Height = Math.Max(0d, finalSize.Height - 4.0); + childArrangeRect.X = (finalSize.Width - childArrangeRect.Width) * 0.5; + childArrangeRect.Y = (finalSize.Height - childArrangeRect.Height) * 0.5; + + UIElement child = Child; + if (child != null) + { + child.Arrange(childArrangeRect); + } + + return finalSize; + } + + + /// + /// Render callback. + /// + protected override void OnRender(DrawingContext drawingContext) + { + Rect bounds = new Rect(0, 0, ActualWidth, ActualHeight); + + // Draw Background + DrawBackground(drawingContext, ref bounds); + + // Draw Border dropshadows + DrawDropShadows(drawingContext, ref bounds); + + // Draw outer border + DrawBorder(drawingContext, ref bounds); + + // Draw innerborder + DrawInnerBorder(drawingContext, ref bounds); + } + + + private void DrawBackground(DrawingContext dc, ref Rect bounds) + { + if (!IsEnabled && !RoundCorners) + return; + + Brush fill = Background; + if ((bounds.Width > 4.0) && (bounds.Height > 4.0)) + { + Rect backgroundRect = new Rect(bounds.Left + 1.0, + bounds.Top + 1.0, + bounds.Width - 2.0, + bounds.Height - 2.0); + + // Draw Background + if (fill != null) + dc.DrawRectangle(fill, null, backgroundRect); + + // Draw BackgroundOverlay + fill = BackgroundOverlay; + if( fill != null) + dc.DrawRectangle(fill, null, backgroundRect); + } + } + + // Draw the Pressed dropshadows + private void DrawDropShadows(DrawingContext dc, ref Rect bounds) + { + if ((bounds.Width > 4.0) && (bounds.Height > 4.0)) + { + Brush leftShadow = LeftDropShadowBrush; + + if (leftShadow != null) + { + dc.DrawRectangle(leftShadow, null, new Rect(1.0, 1.0, 2.0, bounds.Bottom - 2.0)); + } + + Brush topShadow = TopDropShadowBrush; + + if (topShadow != null) + { + dc.DrawRectangle(topShadow, null, new Rect(1.0, 1.0, bounds.Right - 2.0, 2.0)); + } + } + } + + // Draw the main border + private void DrawBorder(DrawingContext dc, ref Rect bounds) + { + if ((bounds.Width >= 5.0) && (bounds.Height >= 5.0)) + { + Brush border = BorderBrush; + Pen pen = null; + + if (border != null) + { + if (_commonBorderPen == null) // Common case, if non-null, avoid the lock + { + lock (_resourceAccess ) // If non-null, lock to create the pen for thread safety + { + if (_commonBorderPen == null) // Check again in case _pen was created within the last line + { + // Assume that the first render of Button uses the most common brush for the app. + // This breaks down if (a) the first Button is disabled, (b) the first Button is + // customized, or (c) ButtonChrome becomes more broadly used than just on Button. + // + // If these cons sufficiently weaken the effectiveness of this cache, then we need + // to build a larger brush-to-pen mapping cache. + + // If the brush is not already frozen, we need to create our own + // copy. Otherwise we will inadvertently freeze the user's + // BorderBrush when we freeze the pen below. + if (!border.IsFrozen && border.CanFreeze) + { + border = border.Clone(); + border.Freeze(); + } + + Pen commonPen = new Pen(border, 1); + if (commonPen.CanFreeze) + { + // Only save frozen pens, some brushes such as VisualBrush + // can not be frozen + commonPen.Freeze(); + _commonBorderPen = commonPen; + } + } + } + } + + if (_commonBorderPen != null && border == _commonBorderPen.Brush) + { + + pen = _commonBorderPen; + } + else + { + if (!border.IsFrozen && border.CanFreeze) + { + border = border.Clone(); + border.Freeze(); + } + + pen = new Pen(border, 1); + if (pen.CanFreeze) + { + pen.Freeze(); + } + } + } + + + Pen overlayPen = BorderOverlayPen; + + if (pen != null || overlayPen != null) + { + if (RoundCorners) + { + Rect rect = new Rect(bounds.Left + 0.5, + bounds.Top + 0.5, + bounds.Width - 1.0, + bounds.Height - 1.0); + + if (IsEnabled && pen != null) + dc.DrawRoundedRectangle(null, pen, rect, 2.75, 2.75); + + if (overlayPen != null) + dc.DrawRoundedRectangle(null, overlayPen, rect, 2.75, 2.75); + } + else + { + // Left side is flat, have to generate a geometry because + // DrawRoundedRectangle does not let you specify per corner radii + PathFigure borderFigure = new PathFigure(); + + borderFigure.StartPoint = new Point(0.5, 0.5); + borderFigure.Segments.Add(new LineSegment(new Point(0.5, bounds.Bottom - 0.5), true)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 2.5, bounds.Bottom - 0.5), true)); + borderFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 0.5, bounds.Bottom - 2.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 0.5, bounds.Top + 2.5), true)); + borderFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 2.5, bounds.Top + 0.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true)); + borderFigure.IsClosed = true; + + PathGeometry borderGeometry = new PathGeometry(); + borderGeometry.Figures.Add(borderFigure); + + if (IsEnabled && pen != null) + dc.DrawGeometry(null, pen, borderGeometry); + + if (overlayPen != null) + dc.DrawGeometry(null, overlayPen, borderGeometry); + } + } + } + } + + + // Draw the inner border + private void DrawInnerBorder(DrawingContext dc, ref Rect bounds) + { + if (!IsEnabled && !RoundCorners) + return; + + if ((bounds.Width >= 4.0) && (bounds.Height >= 4.0)) + { + Pen innerBorder = InnerBorderPen; + + if (innerBorder != null) + { + dc.DrawRoundedRectangle(null, innerBorder, new Rect(bounds.Left + 1.5, bounds.Top + 1.5, bounds.Width - 3.0, bounds.Height - 3.0), 1.75, 1.75); + } + } + } + + #endregion + + #region Private Properties + + // + // This property + // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject + // 2. This is a performance optimization + // + internal override int EffectiveValuesInitialSize + { + get { return 9; } + } + + private bool Animates + { + get + { + return SystemParameters.PowerLineStatus == PowerLineStatus.Online && + SystemParameters.ClientAreaAnimation && + RenderCapability.Tier > 0 && + IsEnabled; + } + } + + + private static LinearGradientBrush CommonHoverBackgroundOverlay + { + get + { + if (_commonHoverBackgroundOverlay == null) + { + lock (_resourceAccess) + { + if (_commonHoverBackgroundOverlay == null) + { + LinearGradientBrush temp = new LinearGradientBrush(); + temp.StartPoint = new Point(0, 0); + temp.EndPoint = new Point(0, 1); + + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEA, 0xF6, 0xFD), 0)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xD9, 0xF0, 0xFC), 0.5)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBE, 0xE6, 0xFD), 0.5)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA7, 0xD9, 0xF5), 1)); + + temp.Freeze(); + + // Static field must not be set until the local has been frozen + _commonHoverBackgroundOverlay = temp; + } + } + } + return _commonHoverBackgroundOverlay; + } + } + + private static LinearGradientBrush CommonPressedBackgroundOverlay + { + get + { + if (_commonPressedBackgroundOverlay == null) + { + lock (_resourceAccess) + { + if (_commonPressedBackgroundOverlay == null) + { + LinearGradientBrush temp = new LinearGradientBrush(); + temp.StartPoint = new Point(0, 0); + temp.EndPoint = new Point(0, 1); + + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC2, 0xE4, 0xF6), 0.5)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAB, 0xDA, 0xF3), 0.5)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x90, 0xCB, 0xEB), 1)); + + temp.Freeze(); + _commonPressedBackgroundOverlay = temp; + } + } + } + return _commonPressedBackgroundOverlay; + } + } + + private static SolidColorBrush CommonDisabledBackgroundOverlay + { + get + { + if (_commonDisabledBackgroundOverlay == null) + { + lock (_resourceAccess) + { + if (_commonDisabledBackgroundOverlay == null) + { + SolidColorBrush temp = new SolidColorBrush(Color.FromRgb(0xF4, 0xF4, 0xF4)); + temp.Freeze(); + _commonDisabledBackgroundOverlay = temp; + } + } + } + return _commonDisabledBackgroundOverlay; + } + } + + private Brush BackgroundOverlay + { + get + { + if (!IsEnabled) + { + return CommonDisabledBackgroundOverlay; + } + + if (!Animates) + { + if (RenderPressed) + { + return CommonPressedBackgroundOverlay; + } + else if (RenderMouseOver) + { + return CommonHoverBackgroundOverlay; + } + else + { + return null; + } + } + + if (_localResources != null) + { + if (_localResources.BackgroundOverlay == null) + { + _localResources.BackgroundOverlay = CommonHoverBackgroundOverlay.Clone(); + _localResources.BackgroundOverlay.Opacity = 0; + } + return _localResources.BackgroundOverlay; + } + else + { + return null; + } + } + } + + private static Pen CommonHoverBorderOverlay + { + get + { + if (_commonHoverBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonHoverBorderOverlay == null) + { + Pen temp = new Pen(); + temp.Thickness = 1; + temp.Brush = new SolidColorBrush(Color.FromRgb(0x3C, 0x7F, 0xB1)); + temp.Freeze(); + _commonHoverBorderOverlay = temp; + } + } + } + return _commonHoverBorderOverlay; + } + } + + private static Pen CommonPressedBorderOverlay + { + get + { + if (_commonPressedBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonPressedBorderOverlay == null) + { + Pen temp = new Pen(); + temp.Thickness = 1; + temp.Brush = new SolidColorBrush(Color.FromRgb(0x2C, 0x62, 0x8B)); + temp.Freeze(); + + _commonPressedBorderOverlay = temp; + } + } + } + return _commonPressedBorderOverlay; + } + } + + private static Pen CommonDisabledBorderOverlay + { + get + { + if (_commonDisabledBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonDisabledBorderOverlay == null) + { + Pen temp = new Pen(); + temp.Thickness = 1; + temp.Brush = new SolidColorBrush(Color.FromRgb(0xAD, 0xB2, 0xB5)); + temp.Freeze(); + _commonDisabledBorderOverlay = temp; + } + } + } + return _commonDisabledBorderOverlay; + } + } + + private Pen BorderOverlayPen + { + get + { + if (!IsEnabled) + { + if (RoundCorners) + { + return CommonDisabledBorderOverlay; + } + else + { + return null; + } + } + + if (!Animates) + { + if (RenderPressed) + { + return CommonPressedBorderOverlay; + } + else if (RenderMouseOver) + { + return CommonHoverBorderOverlay; + } + else + { + return null; + } + } + + if (_localResources != null) + { + if (_localResources.BorderOverlayPen == null) + { + _localResources.BorderOverlayPen = CommonHoverBorderOverlay.Clone(); + _localResources.BorderOverlayPen.Brush.Opacity = 0; + } + return _localResources.BorderOverlayPen; + } + else + { + return null; + } + } + } + + private static Pen CommonInnerBorderPen + { + get + { + if (_commonInnerBorderPen == null) + { + lock (_resourceAccess) + { + if (_commonInnerBorderPen == null) + { + Pen temp = new Pen(); + + temp.Thickness = 1; + + LinearGradientBrush brush = new LinearGradientBrush(); + brush.StartPoint = new Point(0,0); + brush.EndPoint = new Point(0,1); + + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFA,0xFF,0xFF,0xFF), 0)); + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0x85,0xFF,0xFF,0xFF), 1)); + + temp.Brush = brush; + temp.Freeze(); + _commonInnerBorderPen = temp; + } + } + } + return _commonInnerBorderPen; + } + } + + + private static Pen CommonDefaultedInnerBorderPen + { + get + { + if (_commonDefaultedInnerBorderPen == null) + { + lock (_resourceAccess) + { + if (_commonDefaultedInnerBorderPen == null) + { + Pen temp = new Pen(); + temp.Thickness = 1; + temp.Brush = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0xCC, 0xFF)); + temp.Freeze(); + _commonDefaultedInnerBorderPen = temp; + } + } + } + return _commonDefaultedInnerBorderPen; + } + } + + + + private Pen InnerBorderPen + { + get + { + if (!IsEnabled) + { + return CommonInnerBorderPen; + } + + if (!Animates) + { + if (RenderPressed) + { + return null; + } + else if (RenderDefaulted) + { + return CommonDefaultedInnerBorderPen; + } + else + { + return CommonInnerBorderPen; + } + } + + if (_localResources != null) + { + if (_localResources.InnerBorderPen == null) + { + _localResources.InnerBorderPen = CommonInnerBorderPen.Clone(); + } + return _localResources.InnerBorderPen; + } + else + { + return CommonInnerBorderPen; + } + } + } + + private static LinearGradientBrush CommonPressedLeftDropShadowBrush + { + get + { + if (_commonPressedLeftDropShadowBrush == null) + { + lock (_resourceAccess) + { + if (_commonPressedLeftDropShadowBrush == null) + { + LinearGradientBrush temp = new LinearGradientBrush(); + temp.StartPoint = new Point(0, 0); + temp.EndPoint = new Point(1, 0); + + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x80, 0x33, 0x33, 0x33), 0)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0x33, 0x33, 0x33), 1)); + + temp.Freeze(); + _commonPressedLeftDropShadowBrush = temp; + } + } + } + return _commonPressedLeftDropShadowBrush; + } + } + + + private LinearGradientBrush LeftDropShadowBrush + { + get + { + if (!IsEnabled) + { + return null; + } + + if (!Animates) + { + if (RenderPressed) + { + return CommonPressedLeftDropShadowBrush; + } + else + { + return null; + } + } + + if (_localResources != null) + { + if (_localResources.LeftDropShadowBrush == null) + { + _localResources.LeftDropShadowBrush = CommonPressedLeftDropShadowBrush.Clone(); + _localResources.LeftDropShadowBrush.Opacity = 0; + } + return _localResources.LeftDropShadowBrush; + } + else + { + return null; + } + } + } + private static LinearGradientBrush CommonPressedTopDropShadowBrush + { + get + { + if (_commonPressedTopDropShadowBrush == null) + { + lock (_resourceAccess) + { + if (_commonPressedTopDropShadowBrush == null) + { + LinearGradientBrush temp = new LinearGradientBrush(); + temp.StartPoint = new Point(0, 0); + temp.EndPoint = new Point(0, 1); + + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x80, 0x33, 0x33, 0x33), 0)); + temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0x33, 0x33, 0x33), 1)); + + temp.Freeze(); + _commonPressedTopDropShadowBrush = temp; + } + } + } + return _commonPressedTopDropShadowBrush; + } + } + + private LinearGradientBrush TopDropShadowBrush + { + get + { + if (!IsEnabled) + { + return null; + } + + if (!Animates) + { + if (RenderPressed) + { + return CommonPressedTopDropShadowBrush; + } + else + { + return null; + } + } + + if (_localResources != null) + { + if (_localResources.TopDropShadowBrush == null) + { + _localResources.TopDropShadowBrush = CommonPressedTopDropShadowBrush.Clone(); + _localResources.TopDropShadowBrush.Opacity = 0; + } + return _localResources.TopDropShadowBrush; + } + else + { + return null; + } + } + } + + // Common LocalResources + private static Pen _commonBorderPen; + private static Pen _commonInnerBorderPen; + + private static Pen _commonDisabledBorderOverlay; + private static SolidColorBrush _commonDisabledBackgroundOverlay; + + private static Pen _commonDefaultedInnerBorderPen; + + private static LinearGradientBrush _commonHoverBackgroundOverlay; + private static Pen _commonHoverBorderOverlay; + + + private static LinearGradientBrush _commonPressedBackgroundOverlay; + private static Pen _commonPressedBorderOverlay; + + private static LinearGradientBrush _commonPressedLeftDropShadowBrush; + private static LinearGradientBrush _commonPressedTopDropShadowBrush; + + + private static object _resourceAccess = new object(); + + // Per instance resources + + private LocalResources _localResources; + + private class LocalResources + { + public Pen BorderOverlayPen; + public Pen InnerBorderPen; + public LinearGradientBrush BackgroundOverlay; + public LinearGradientBrush LeftDropShadowBrush; + public LinearGradientBrush TopDropShadowBrush; + } + + #endregion + } +} + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs new file mode 100644 index 00000000000..c8cfee99513 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs @@ -0,0 +1,693 @@ +// 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.Windows.Shapes; +using System.Windows.Controls; +using System.Diagnostics; +using System.Threading; + +using System.ComponentModel; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Animation; +using MS.Internal; + +using System; + +namespace Microsoft.Windows.Themes +{ + /// + /// The ListBoxChrome element + /// This element is a theme-specific type that is used as an optimization + /// for a common complex rendering used in Windows 11 themes + /// + /// + public sealed class ListBoxChrome : Decorator + { + #region Constructors + + static ListBoxChrome() + { + IsEnabledProperty.OverrideMetadata(typeof(ListBoxChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); + } + + /// + /// Instantiates a new instance of a ListBoxChrome with no parent element. + /// + /// + public ListBoxChrome() + { + } + + #endregion Constructors + + #region Dynamic Properties + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty BackgroundProperty = + Control.BackgroundProperty.AddOwner( + typeof(ListBoxChrome), + new FrameworkPropertyMetadata( + null, + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// The Background property defines the brush used to fill the background of the button. + /// + public Brush Background + { + get { return (Brush) GetValue(BackgroundProperty); } + set { SetValue(BackgroundProperty, value); } + } + + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty BorderBrushProperty = + Border.BorderBrushProperty.AddOwner( + typeof(ListBoxChrome), + new FrameworkPropertyMetadata( + null, + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// The BorderBrush property defines the brush used to draw the outer border. + /// + public Brush BorderBrush + { + get { return (Brush) GetValue(BorderBrushProperty); } + set { SetValue(BorderBrushProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty BorderThicknessProperty = + Border.BorderThicknessProperty.AddOwner( + typeof(ListBoxChrome), + new FrameworkPropertyMetadata( + new Thickness(1), + FrameworkPropertyMetadataOptions.AffectsRender)); + + /// + /// The BorderThickness property defines the thickness of the border. + /// + public Thickness BorderThickness + { + get { return (Thickness)GetValue(BorderThicknessProperty); } + set { SetValue(BorderThicknessProperty, value); } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RenderMouseOverProperty = + DependencyProperty.Register("RenderMouseOver", + typeof(bool), + typeof(ListBoxChrome), + new FrameworkPropertyMetadata( + false, + new PropertyChangedCallback(OnRenderMouseOverChanged))); + + /// + /// When true the chrome renders with a mouse over look. + /// + public bool RenderMouseOver + { + get { return (bool)GetValue(RenderMouseOverProperty); } + set { SetValue(RenderMouseOverProperty, value); } + } + + private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + ListBoxChrome chrome = ((ListBoxChrome)o); + + if (chrome.RenderFocused) + { + return; + } + + if (chrome.Animates) + { + if (((bool)e.NewValue)) + { + if (chrome._localResources == null) + { + chrome._localResources = new LocalResources(); + chrome.InvalidateVisual(); + } + + Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); + + DoubleAnimation da = new DoubleAnimation(1, duration); + + chrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, da); + } + else if (chrome._localResources == null) + { + chrome.InvalidateVisual(); + } + else + { + Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); + + DoubleAnimation da = new DoubleAnimation(); + da.Duration = duration; + + chrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, da); + } + } + else + { + chrome._localResources = null; + chrome.InvalidateVisual(); + } + } + + /// + /// DependencyProperty for property. + /// + public static readonly DependencyProperty RenderFocusedProperty = + DependencyProperty.Register("RenderFocused", + typeof(bool), + typeof(ListBoxChrome), + new FrameworkPropertyMetadata( + false, + new PropertyChangedCallback(OnRenderFocusedChanged))); + + /// + /// When true the chrome renders with a Focused look. + /// + public bool RenderFocused + { + get { return (bool)GetValue(RenderFocusedProperty); } + set { SetValue(RenderFocusedProperty, value); } + } + + private static void OnRenderFocusedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + ListBoxChrome chrome = ((ListBoxChrome)o); + + chrome._localResources = null; + chrome.InvalidateVisual(); + } + + #endregion Dynamic Properties + + #region Protected Methods + + /// + /// Updates DesiredSize of the ListBoxChrome. Called by parent UIElement. This is the first pass of layout. + /// + /// Available size is an "upper limit" that the return value should not exceed. + /// The ListBoxChrome's desired size. + protected override Size MeasureOverride(Size availableSize) + { + Size desired; + + Thickness border = BorderThickness; + double borderX = border.Left + border.Right; + double borderY = border.Top + border.Bottom; + + // When BorderThickness is 0, draw no border - otherwise add 1 on each side + // for inner border + if (borderX > 0 || borderY > 0) + { + borderX += 2.0; + borderY += 2.0; + } + + UIElement child = Child; + if (child != null) + { + Size childConstraint = new Size(); + bool isWidthTooSmall = (availableSize.Width < borderX); + bool isHeightTooSmall = (availableSize.Height < borderY); + + if (!isWidthTooSmall) + { + childConstraint.Width = availableSize.Width - borderX; + } + if (!isHeightTooSmall) + { + childConstraint.Height = availableSize.Height - borderY; + } + + child.Measure(childConstraint); + + desired = child.DesiredSize; + + if (!isWidthTooSmall) + { + desired.Width += borderX; + } + if (!isHeightTooSmall) + { + desired.Height += borderY; + } + } + else + { + desired = new Size(Math.Min(borderX, availableSize.Width), Math.Min(borderY, availableSize.Height)); + } + + return desired; + } + + /// + /// ListBoxChrome computes the position of its single child inside child's Margin and calls Arrange + /// on the child. + /// + /// + /// ListBoxChrome basically inflates the desired size of its one child by 2 on all four sides + /// + /// Size the ContentPresenter will assume. + protected override Size ArrangeOverride(Size finalSize) + { + Rect childArrangeRect = new Rect(); + + Thickness border = BorderThickness; + double borderX = border.Left + border.Right; + double borderY = border.Top + border.Bottom; + + // When BorderThickness is 0, draw no border - otherwise add 1 on each side + // for inner border + if (borderX > 0 || borderY > 0) + { + border.Left += 1.0; + border.Top += 1.0; + borderX += 2.0; + borderY += 2.0; + } + + if ((finalSize.Width > borderX) && (finalSize.Height > borderY)) + { + childArrangeRect.X = border.Left; + childArrangeRect.Y = border.Top; + childArrangeRect.Width = finalSize.Width - borderX; + childArrangeRect.Height = finalSize.Height - borderY; + } + + if (Child != null) + { + Child.Arrange(childArrangeRect); + } + + return finalSize; + } + + + /// + /// Render callback. + /// + protected override void OnRender(DrawingContext dc) + { + Rect bounds = new Rect(0, 0, ActualWidth, ActualHeight); + + Thickness border = BorderThickness; + double borderX = border.Left + border.Right; + double borderY = border.Top + border.Bottom; + + // ListBoxChrome is rendered with a border of BorderThickness + // Inside this is the Background. Inside the background + // is the Background overlay for disabled controls which + // is offset by 1 px. + + bool isSimpleBorder = border.Left == 1.0 && border.Right == 1.0 && + border.Top == 1.0 && border.Bottom == 1.0; + + double innerBorderThickness = (borderX == 0.0 && borderY == 0.0) ? 0.0 : 1.0; + double innerBorderThickness2 = 2 * innerBorderThickness; + + if ((bounds.Width > borderX) && + (bounds.Height > borderY)) + { + Rect backgroundRect = new Rect(bounds.Left + border.Left, + bounds.Top + border.Top, + bounds.Width - borderX, + bounds.Height - borderY); + + Brush fill = Background; + + // Draw Background + if (fill != null) + dc.DrawRectangle(fill, null, backgroundRect); + + // Draw Background Overlay inset by 1px from edge of main border + if ((bounds.Width > borderX + innerBorderThickness2) && + (bounds.Height > borderY + innerBorderThickness2)) + { + backgroundRect = new Rect(bounds.Left + border.Left + innerBorderThickness, + bounds.Top + border.Top + innerBorderThickness, + bounds.Width - borderX - innerBorderThickness2, + bounds.Height - borderY - innerBorderThickness2); + + // Draw BackgroundOverlay + fill = BackgroundOverlay; + if (fill != null) + dc.DrawRoundedRectangle(fill, null, backgroundRect, 1, 1); + } + } + + // Draw borders + // innerBorderThickness is 0 when the listbox border is 0 + if (innerBorderThickness > 0) + { + // Draw Main border + if ((bounds.Width >= borderX) && + (bounds.Height >= borderY)) + { + if (isSimpleBorder) + { + Rect rect = new Rect(bounds.Left + 0.5, + bounds.Top + 0.5, + bounds.Width - 1.0, + bounds.Height - 1.0); + + Pen pen = GetBorderPen(BorderBrush); + Pen overlayPen = BorderOverlayPen; + + if (pen != null) + dc.DrawRoundedRectangle(null, pen, rect, 1.0, 1.0); + + if (overlayPen != null) + dc.DrawRoundedRectangle(null, overlayPen, rect, 1.0, 1.0); + } + else + { + Geometry geometry = GetBorderGeometry(border, bounds); + + if (BorderBrush != null) + dc.DrawGeometry(BorderBrush, null, geometry); + } + } + } + } + + #endregion + + #region Private Properties + + // + // This property + // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject + // 2. This is a performance optimization + // + internal override int EffectiveValuesInitialSize + { + get { return 9; } + } + + private bool Animates + { + get + { + return SystemParameters.ClientAreaAnimation && + RenderCapability.Tier > 0 && + IsEnabled; + } + } + + private static Pen GetBorderPen(Brush border) + { + Pen pen = null; + + if (border != null) + { + if (_commonBorderPen == null) // Common case, if non-null, avoid the lock + { + lock (_resourceAccess) // If non-null, lock to create the pen for thread safety + { + if (_commonBorderPen == null) // Check again in case _pen was created within the last line + { + // Assume that the first render of Button uses the most common brush for the app. + // This breaks down if (a) the first Button is disabled, (b) the first Button is + // customized, or (c) ListBoxChrome becomes more broadly used than just on Button. + // + // If these cons sufficiently weaken the effectiveness of this cache, then we need + // to build a larger brush-to-pen mapping cache. + + // If the brush is not already frozen, we need to create our own + // copy. Otherwise we will inadvertently freeze the user's + // BorderBrush when we freeze the pen below. + if (!border.IsFrozen && border.CanFreeze) + { + border = border.Clone(); + border.Freeze(); + } + + Pen commonPen = new Pen(border, 1); + if (commonPen.CanFreeze) + { + // Only save frozen pens, some brushes such as VisualBrush + // can not be frozen + commonPen.Freeze(); + _commonBorderPen = commonPen; + } + } + } + } + + if (_commonBorderPen != null && border == _commonBorderPen.Brush) + { + + pen = _commonBorderPen; + } + else + { + if (!border.IsFrozen && border.CanFreeze) + { + border = border.Clone(); + border.Freeze(); + } + + pen = new Pen(border, 1); + if (pen.CanFreeze) + { + pen.Freeze(); + } + } + } + return pen; + } + + private static Geometry GetBorderGeometry(Thickness thickness, Rect bounds) + { + PathFigure borderFigure = new PathFigure(); + + borderFigure.StartPoint = new Point(bounds.Left, bounds.Top); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Left, bounds.Bottom), false)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right, bounds.Bottom), false)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right, bounds.Top), false)); + borderFigure.IsClosed = true; + + PathGeometry borderGeometry = new PathGeometry(); + borderGeometry.Figures.Add(borderFigure); + + borderFigure = new PathFigure(); + + borderFigure.StartPoint = new Point(bounds.Left + thickness.Left, bounds.Top + thickness.Top); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Left + thickness.Left, bounds.Bottom - thickness.Bottom), false)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - thickness.Right, bounds.Bottom - thickness.Bottom), false)); + borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - thickness.Right, bounds.Top + thickness.Top), false)); + borderFigure.IsClosed = true; + + borderGeometry.Figures.Add(borderFigure); + + return borderGeometry; + } + + + private static SolidColorBrush CommonDisabledBackgroundOverlay + { + get + { + if (_commonDisabledBackgroundOverlay == null) + { + lock (_resourceAccess) + { + if (_commonDisabledBackgroundOverlay == null) + { + SolidColorBrush temp = new SolidColorBrush(Color.FromRgb(0xF4, 0xF4, 0xF4)); + temp.Freeze(); + + // Static field must not be set until the local has been frozen + _commonDisabledBackgroundOverlay = temp; + } + } + } + return _commonDisabledBackgroundOverlay; + } + } + + private static Pen CommonHoverBorderOverlay + { + get + { + if (_commonHoverBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonHoverBorderOverlay == null) + { + Pen temp = new Pen(); + + temp.Thickness = 1; + + LinearGradientBrush brush = new LinearGradientBrush(); + brush.StartPoint = new Point(0, 0); + brush.EndPoint = new Point(0, 20); + brush.MappingMode = BrushMappingMode.Absolute; + + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x57, 0x94, 0xBF), 0.05)); + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xD5, 0xEA), 0.07)); + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC7, 0xE2, 0xF1), 1)); + + temp.Brush = brush; + temp.Freeze(); + + _commonHoverBorderOverlay = temp; + } + } + } + return _commonHoverBorderOverlay; + } + } + + private static Pen CommonFocusedBorderOverlay + { + get + { + if (_commonFocusedBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonFocusedBorderOverlay == null) + { + Pen temp = new Pen(); + + + temp.Thickness = 1; + + LinearGradientBrush brush = new LinearGradientBrush(); + brush.StartPoint = new Point(0, 0); + brush.EndPoint = new Point(0, 20); + brush.MappingMode = BrushMappingMode.Absolute; + + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3D, 0x7B, 0xAD), 0.05)); + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA4, 0xC9, 0xE3), 0.07)); + brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xD9, 0xED), 1)); + + temp.Brush = brush; + temp.Freeze(); + + _commonFocusedBorderOverlay = temp; + } + } + } + return _commonFocusedBorderOverlay; + } + } + + private static Pen CommonDisabledBorderOverlay + { + get + { + if (_commonDisabledBorderOverlay == null) + { + lock (_resourceAccess) + { + if (_commonDisabledBorderOverlay == null) + { + Pen temp = new Pen(); + temp.Thickness = 1; + temp.Brush = new SolidColorBrush(Color.FromRgb(0xAD, 0xB2, 0xB5)); + temp.Freeze(); + _commonDisabledBorderOverlay = temp; + } + } + } + return _commonDisabledBorderOverlay; + } + } + + + + + private Brush BackgroundOverlay + { + get + { + if (!IsEnabled) + { + return CommonDisabledBackgroundOverlay; + } + else + { + return null; + } + } + } + + + private Pen BorderOverlayPen + { + get + { + if (!IsEnabled) + { + return CommonDisabledBorderOverlay; + } + + if (_localResources != null) + { + if (_localResources.BorderOverlayPen == null) + { + _localResources.BorderOverlayPen = CommonHoverBorderOverlay.Clone(); + _localResources.BorderOverlayPen.Brush.Opacity = 0; + } + return _localResources.BorderOverlayPen; + } + + if (RenderFocused) + { + return CommonFocusedBorderOverlay; + } + else if (RenderMouseOver) + { + return CommonHoverBorderOverlay; + } + else + { + return null; + } + } + } + + private static SolidColorBrush _commonDisabledBackgroundOverlay; + + private static Pen _commonBorderPen; + + private static Pen _commonDisabledBorderOverlay; + private static Pen _commonHoverBorderOverlay; + private static Pen _commonFocusedBorderOverlay; + + private static object _resourceAccess = new object(); + + // Per instance resources + + private LocalResources _localResources; + + private class LocalResources + { + public Pen BorderOverlayPen; + } + + #endregion + } +} + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj index b99ca4602b7..67c48ef0449 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -22,6 +22,7 @@ MSBuild:Compile + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml index 4585a655534..6ce3e1219e7 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml @@ -14,25 +14,43 @@ + + + + + + + + + + + + + + + + + + @@ -42,11 +60,15 @@ + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml index c24327c22e0..54e93f506d1 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml @@ -4,7 +4,9 @@ See the LICENSE file in the project root for more information. ==================================================================--> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml index 3f608e8aae9..563128f31ee 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -205,9 +205,12 @@ Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" Cursor="Arrow" Foreground="{DynamicResource TextControlButtonForeground}"> - + + + + Date: Fri, 23 Feb 2024 03:05:48 +0530 Subject: [PATCH 093/185] Removing TextBox.Icon property --- .../System/Windows/Controls/TextBox.cs | 38 ------------------- .../Styles/TextBox.xaml | 18 ++++----- 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs index 9234b957d25..596a6bfcbcb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs @@ -965,26 +965,6 @@ public Typography Typography return new Typography(this); } } - - /// - /// Property for . - /// - public static readonly DependencyProperty IconProperty = DependencyProperty.Register( - nameof(Icon), - typeof(IconElement), - typeof(TextBox), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register( - nameof(IconPlacement), - typeof(ElementPlacement), - typeof(TextBox), - new PropertyMetadata(ElementPlacement.Left) - ); /// /// Property for . @@ -1048,24 +1028,6 @@ public Typography Typography #region Properties - /// - /// Gets or sets displayed . - /// - public IconElement Icon - { - get => (IconElement)GetValue(IconProperty); - set => SetValue(IconProperty, value); - } - - /// - /// Defines which side the icon should be placed on. - /// - public ElementPlacement IconPlacement - { - get => (ElementPlacement)GetValue(IconPlacementProperty); - set => SetValue(IconPlacementProperty, value); - } - /// /// Gets or sets numbers pattern. /// diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml index e7e7da18196..e6bbc84095e 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -156,7 +156,7 @@ - + Visibility="Visible" /> --> - + TextElement.Foreground="{TemplateBinding Foreground}" /> --> @@ -242,7 +242,7 @@ - + @@ -280,8 +280,8 @@ - - + + @@ -347,7 +347,7 @@ - + From e31e9c1a8fcb1e6b1cdb877b948d269f1e9a606e Mon Sep 17 00:00:00 2001 From: hmishra Date: Fri, 23 Feb 2024 13:25:23 +0530 Subject: [PATCH 094/185] Enabling High Contrast Switching --- .../Windows/Appearance/WindowBackdrop.cs | 43 +++++++++---------- .../System/Windows/Application.cs | 13 ++++++ .../System/Windows/SystemResources.cs | 20 +++++++++ .../System/Windows/Window.cs | 16 +------ 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs index 4cb478cd9ed..6abd7f62e72 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs @@ -306,29 +306,26 @@ private static bool RestoreContentBackground(IntPtr hWnd) private static Brush GetFallbackBackgroundBrush() { - // if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.HighContrast) - // { - // switch (ApplicationThemeManager.GetSystemTheme()) - // { - // 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)); - // } + if(Application.isThemeHighContrast()) + { + string currentTheme = ThemeColorization.getNewTheme(); + if(currentTheme.Contains("hc1")) + { + return new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x32, 0x36)); + } + else if(currentTheme.Contains("hc2")) + { + return new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)); + } + else if(currentTheme.Contains("hcblack")) + { + return new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)); + } + else + { + return new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFA, 0xEF)); + } + } if(Application.isThemeDark()) { return new SolidColorBrush(Color.FromArgb(0xFF, 0x20, 0x20, 0x20)); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs index 7ef8377e849..d10498910d9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs @@ -1491,6 +1491,19 @@ internal static bool isThemeDark() { currentTheme.Contains("dark.theme"); } + + return false; + } + + internal static bool isThemeHighContrast() + { + string currentTheme = ThemeColorization.getNewTheme(); + + if(currentTheme != null) + { + return currentTheme.Contains("hc"); + } + return false; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs index fe4585e2073..b82ad752ce7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs @@ -1794,6 +1794,26 @@ internal static void ApplyTheme() UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "dark.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.Dark, WindowBackdropType.Mica, false); } + else if(themeToApply.Contains("hcwhite") && Utilities.IsOSWindows11OrNewer) + { + UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hcwhite.xaml", UriKind.Absolute)); + WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); + } + else if(themeToApply.Contains("hcblack") && Utilities.IsOSWindows11OrNewer) + { + UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hcblack.xaml", UriKind.Absolute)); + WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); + } + else if (themeToApply.Contains("hc1") && Utilities.IsOSWindows11OrNewer) + { + UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hc1.xaml", UriKind.Absolute)); + WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); + } + else if (themeToApply.Contains("hc2") && Utilities.IsOSWindows11OrNewer) + { + UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hc2.xaml", UriKind.Absolute)); + WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); + } else if (Utilities.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "light.xaml", UriKind.Absolute)); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs index eeaf0e9a9bf..5bf7fc69a53 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs @@ -2517,22 +2517,8 @@ internal void CreateSourceWindow(bool duringShow) // This is one time initialization that updates the resourcedictionary and // calls WindowBackgroundManager to update its Background based on current SystemTheme - string themeToApply = ThemeColorization.getNewTheme(); - - var window = Application.Current.MainWindow; - - if (themeToApply.Contains("dark.theme") && Utilities.IsOSWindows11OrNewer) - { - ThemeColorization.UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "dark.xaml", UriKind.Absolute)); - WindowBackgroundManager.UpdateBackground(window, ApplicationTheme.Dark, WindowBackdropType.Mica, false); - } - else if (themeToApply.Contains("aero") && Utilities.IsOSWindows11OrNewer) - { - ThemeColorization.UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "light.xaml", UriKind.Absolute)); - WindowBackgroundManager.UpdateBackground(window, ApplicationTheme.Light, WindowBackdropType.Mica, false); - } - DWMColorization.ApplyAccentColors(); + ThemeColorization.ApplyTheme(); } // Sub classes can have different intialization. RBW does very minimalistic From 48595116ef13b52d0b38f72eb6fe2058ceb23838 Mon Sep 17 00:00:00 2001 From: hmishra Date: Fri, 23 Feb 2024 14:27:09 +0530 Subject: [PATCH 095/185] Fix(win11theming): dark theme not working properly --- .../src/PresentationFramework/System/Windows/Application.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs index d10498910d9..b0c92fcdae9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs @@ -1489,7 +1489,7 @@ internal static bool isThemeDark() if (currentTheme != null) { - currentTheme.Contains("dark.theme"); + return currentTheme.Contains("dark.theme"); } return false; From 2c7c23444e0acd45c06970ff9827dd1d819ebc8f Mon Sep 17 00:00:00 2001 From: hmishra Date: Fri, 23 Feb 2024 14:34:26 +0530 Subject: [PATCH 096/185] Update(Win11Theming): Changing access type of non-essential methods to internal --- .../System/Windows/Appearance/WindowBackdrop.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs index 6abd7f62e72..81f71de37ba 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs @@ -15,13 +15,13 @@ namespace System.Windows.Appearance; /// /// Applies the chosen backdrop effect to the selected window. /// -public static class WindowBackdrop +internal static class WindowBackdrop { /// /// Checks whether the selected backdrop type is supported on current platform. /// /// if the selected backdrop type is supported on current platform. - public static bool IsSupported(WindowBackdropType backdropType) + internal static bool IsSupported(WindowBackdropType backdropType) { return backdropType switch { @@ -39,7 +39,7 @@ public static bool IsSupported(WindowBackdropType backdropType) /// /// Selected window. /// if the operation was successfull, otherwise . - public static bool ApplyBackdrop(System.Windows.Window window, WindowBackdropType backdropType) + internal static bool ApplyBackdrop(System.Windows.Window window, WindowBackdropType backdropType) { if (window is null) { @@ -79,7 +79,7 @@ public static bool ApplyBackdrop(System.Windows.Window window, WindowBackdropTyp /// /// Window handle. /// if the operation was successfull, otherwise . - public static bool ApplyBackdrop(IntPtr hWnd, WindowBackdropType backdropType) + internal static bool ApplyBackdrop(IntPtr hWnd, WindowBackdropType backdropType) { if (hWnd == IntPtr.Zero) { @@ -136,7 +136,7 @@ public static bool ApplyBackdrop(IntPtr hWnd, WindowBackdropType backdropType) /// Tries to remove backdrop effects if they have been applied to the . /// /// The window from which the effect should be removed. - public static bool RemoveBackdrop(System.Windows.Window window) + internal static bool RemoveBackdrop(System.Windows.Window window) { if (window is null) { @@ -152,7 +152,7 @@ public static bool RemoveBackdrop(System.Windows.Window window) /// Tries to remove all effects if they have been applied to the hWnd. /// /// Pointer to the window handle. - public static bool RemoveBackdrop(IntPtr hWnd) + internal static bool RemoveBackdrop(IntPtr hWnd) { if (hWnd == IntPtr.Zero) { @@ -196,7 +196,7 @@ public static bool RemoveBackdrop(IntPtr hWnd) /// /// Window to manipulate. /// if operation was successful. - public static bool RemoveBackground(System.Windows.Window window) + internal static bool RemoveBackground(System.Windows.Window window) { if (window is null) { From f2d20f904ac24faf4c9cdc9b9ae1d24bc9f3f973 Mon Sep 17 00:00:00 2001 From: dipeshmsft Date: Fri, 23 Feb 2024 19:41:20 +0530 Subject: [PATCH 097/185] Removed all chromes from Win11 styles --- .../Microsoft/Windows/Themes/ButtonChrome.cs | 1180 ----------------- .../Microsoft/Windows/Themes/ListBoxChrome.cs | 693 ---------- .../PresentationFramework.Win11.xaml | 4 +- .../Styles/Button.xaml | 3 +- .../Styles/ButtonBase.xaml | 67 - .../Styles/TextBox.xaml | 6 +- .../Styles/TextBoxBase.xaml | 77 -- 7 files changed, 7 insertions(+), 2023 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ButtonBase.xaml delete mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBoxBase.xaml diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs deleted file mode 100644 index f63188cd8a4..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ButtonChrome.cs +++ /dev/null @@ -1,1180 +0,0 @@ -// 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.Windows.Shapes; -using System.Windows.Controls; -using System.Diagnostics; -using System.Threading; - -using System.ComponentModel; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Animation; -using MS.Internal; - -using System; - -using System.Runtime.InteropServices; -using System.Security; - -namespace Microsoft.Windows.Themes -{ - /// - /// The ButtonChrome element - /// This element is a theme-specific type that is used as an optimization - /// for a common complex rendering used in Windows 11 themes - /// - /// - public sealed class ButtonChrome : Decorator - { - #region Constructors - - static ButtonChrome() - { - IsEnabledProperty.OverrideMetadata(typeof(ButtonChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); - } - - /// - /// Instantiates a new instance of a ButtonChrome with no parent element. - /// - /// - public ButtonChrome() - { - } - - #endregion Constructors - - #region Dynamic Properties - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty BackgroundProperty = - Control.BackgroundProperty.AddOwner( - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// The Background property defines the brush used to fill the background of the button. - /// - public Brush Background - { - get { return (Brush) GetValue(BackgroundProperty); } - set { SetValue(BackgroundProperty, value); } - } - - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty BorderBrushProperty = - Border.BorderBrushProperty.AddOwner( - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// The BorderBrush property defines the brush used to draw the outer border. - /// - public Brush BorderBrush - { - get { return (Brush) GetValue(BorderBrushProperty); } - set { SetValue(BorderBrushProperty, value); } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RenderDefaultedProperty = - DependencyProperty.Register("RenderDefaulted", - typeof(bool), - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - false, - new PropertyChangedCallback(OnRenderDefaultedChanged))); - - /// - /// When true the chrome renders with a mouse over look. - /// - public bool RenderDefaulted - { - get { return (bool)GetValue(RenderDefaultedProperty); } - set { SetValue(RenderDefaultedProperty, value); } - } - - private static void OnRenderDefaultedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ButtonChrome chrome = ((ButtonChrome)o); - - if (chrome.Animates) - { - if (((bool)e.NewValue)) - { - if (chrome._localResources == null) - { - chrome._localResources = new LocalResources(); - chrome.InvalidateVisual(); - } - - Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); - - ColorAnimation ca = new ColorAnimation(Color.FromArgb(0xF9, 0x00, 0xCC, 0xFF), duration); - GradientStopCollection gsc = ((LinearGradientBrush)chrome.InnerBorderPen.Brush).GradientStops; - gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); - - if (!chrome.RenderPressed) - { - // Create a repeating animation like: - // __/ \__/ \__/ \__... - DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames(); - daukf.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.5))); - daukf.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.75))); - daukf.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(2.0))); - daukf.RepeatBehavior = RepeatBehavior.Forever; - DoubleAnimationUsingKeyFrames.SetDesiredFrameRate(daukf, 10); - - chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, daukf); - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, daukf); - } - } - else if (chrome._localResources == null) - { - if (!chrome.RenderPressed) - { - chrome.InvalidateVisual(); - } - } - else - { - Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); - - if (!chrome.RenderPressed) - { - DoubleAnimation da = new DoubleAnimation(); - da.Duration = duration; - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - } - - ColorAnimation ca = new ColorAnimation(); - ca.Duration = duration; - GradientStopCollection gsc = ((LinearGradientBrush)chrome.InnerBorderPen.Brush).GradientStops; - gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); - } - } - else - { - chrome._localResources = null; - chrome.InvalidateVisual(); - } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RenderMouseOverProperty = - DependencyProperty.Register("RenderMouseOver", - typeof(bool), - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - false, - new PropertyChangedCallback(OnRenderMouseOverChanged))); - - /// - /// When true the chrome renders with a mouse over look. - /// - public bool RenderMouseOver - { - get { return (bool)GetValue(RenderMouseOverProperty); } - set { SetValue(RenderMouseOverProperty, value); } - } - - private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ButtonChrome chrome = ((ButtonChrome)o); - - if (chrome.Animates) - { - if (!chrome.RenderPressed) - { - if (((bool)e.NewValue)) - { - if (chrome._localResources == null) - { - chrome._localResources = new LocalResources(); - chrome.InvalidateVisual(); - } - - Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); - - DoubleAnimation da = new DoubleAnimation(1, duration); - - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - } - else if (chrome._localResources == null) - { - chrome.InvalidateVisual(); - } - else - { - if (chrome.RenderDefaulted) - { - // Since the mouse was over the button the opacity should be 1.0 - // Create a repeating animation like: - // \__/ \__/ \__/ \_... - // But if the user quickly mouses over a button, the opacity may not be 1 yet - // so the first keyframe brings the opacity to 1 - double currentOpacity = chrome.BackgroundOverlay.Opacity; - - // This is the time needed to complete the animation to 1: - double to1 = (1.0 - currentOpacity) * 0.5; - - DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames(); - daukf.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(to1))); - daukf.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(to1 + 0.25))); - daukf.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(to1 + 1.5))); - daukf.KeyFrames.Add(new LinearDoubleKeyFrame(currentOpacity, TimeSpan.FromSeconds(2))); - daukf.RepeatBehavior = RepeatBehavior.Forever; - DoubleAnimationUsingKeyFrames.SetDesiredFrameRate(daukf, 10); - chrome.BackgroundOverlay.BeginAnimation(LinearGradientBrush.OpacityProperty, daukf); - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, daukf); - } - else - { - Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); - - DoubleAnimation da = new DoubleAnimation(); - da.Duration = duration; - - chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); - } - } - } - } - else - { - chrome._localResources = null; - chrome.InvalidateVisual(); - } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RenderPressedProperty = - DependencyProperty.Register("RenderPressed", - typeof(bool), - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - false, - new PropertyChangedCallback(OnRenderPressedChanged))); - - /// - /// When true the chrome renders with a pressed look. - /// - public bool RenderPressed - { - get { return (bool)GetValue(RenderPressedProperty); } - set { SetValue(RenderPressedProperty, value); } - } - - private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ButtonChrome chrome = ((ButtonChrome)o); - - if (chrome.Animates) - { - if (((bool)e.NewValue)) - { - if (chrome._localResources == null) - { - chrome._localResources = new LocalResources(); - chrome.InvalidateVisual(); - } - - Duration duration = new Duration(TimeSpan.FromSeconds(0.1)); - - DoubleAnimation da = new DoubleAnimation(1, duration); - - chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.LeftDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - chrome.TopDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - - da = new DoubleAnimation(0, duration); - chrome.InnerBorderPen.Brush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - - ColorAnimation ca = new ColorAnimation(Color.FromRgb(0xC2, 0xE4, 0xF6), duration); - GradientStopCollection gsc = ((LinearGradientBrush)chrome.BackgroundOverlay).GradientStops; - gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); - - ca = new ColorAnimation(Color.FromRgb(0xAB, 0xDA, 0xF3), duration); - gsc[2].BeginAnimation(GradientStop.ColorProperty, ca); - - ca = new ColorAnimation(Color.FromRgb(0x90, 0xCB, 0xEB), duration); - gsc[3].BeginAnimation(GradientStop.ColorProperty, ca); - - ca = new ColorAnimation(Color.FromRgb(0x2C, 0x62, 0x8B), duration); - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, ca); - } - else if (chrome._localResources == null) - { - chrome.InvalidateVisual(); - } - else - { - bool renderMouseOver = chrome.RenderMouseOver; - Duration duration = new Duration(TimeSpan.FromSeconds(0.1)); - - DoubleAnimation da = new DoubleAnimation(); - da.Duration = duration; - chrome.LeftDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - chrome.TopDropShadowBrush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - chrome.InnerBorderPen.Brush.BeginAnimation(LinearGradientBrush.OpacityProperty, da); - - if (!renderMouseOver) - { - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.OpacityProperty, da); - chrome.BackgroundOverlay.BeginAnimation(SolidColorBrush.OpacityProperty, da); - } - - ColorAnimation ca = new ColorAnimation(); - ca.Duration = duration; - chrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, ca); - - GradientStopCollection gsc = ((LinearGradientBrush)chrome.BackgroundOverlay).GradientStops; - gsc[0].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[1].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[2].BeginAnimation(GradientStop.ColorProperty, ca); - gsc[3].BeginAnimation(GradientStop.ColorProperty, ca); - } - } - else - { - chrome._localResources = null; - chrome.InvalidateVisual(); - } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RoundCornersProperty = - DependencyProperty.Register("RoundCorners", - typeof(bool), - typeof(ButtonChrome), - new FrameworkPropertyMetadata( - true, - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// When true, the left border will have round corners, otherwise they will be square. - /// - public bool RoundCorners - { - get { return (bool)GetValue(RoundCornersProperty); } - set { SetValue(RoundCornersProperty, value); } - } - - #endregion Dynamic Properties - - #region Protected Methods - - /// - /// Updates DesiredSize of the ButtonChrome. Called by parent UIElement. This is the first pass of layout. - /// - /// - /// ButtonChrome basically inflates the desired size of its one child by 2 on all four sides - /// - /// Available size is an "upper limit" that the return value should not exceed. - /// The ButtonChrome's desired size. - protected override Size MeasureOverride(Size availableSize) - { - Size desired; - UIElement child = Child; - if (child != null) - { - Size childConstraint = new Size(); - bool isWidthTooSmall = (availableSize.Width < 4.0); - bool isHeightTooSmall = (availableSize.Height < 4.0); - - if (!isWidthTooSmall) - { - childConstraint.Width = availableSize.Width - 4.0; - } - if (!isHeightTooSmall) - { - childConstraint.Height = availableSize.Height - 4.0; - } - - child.Measure(childConstraint); - - desired = child.DesiredSize; - - if (!isWidthTooSmall) - { - desired.Width += 4.0; - } - if (!isHeightTooSmall) - { - desired.Height += 4.0; - } - } - else - { - desired = new Size(Math.Min(4.0, availableSize.Width), Math.Min(4.0, availableSize.Height)); - } - - return desired; - } - - /// - /// ButtonChrome computes the position of its single child inside child's Margin and calls Arrange - /// on the child. - /// - /// - /// ButtonChrome basically inflates the desired size of its one child by 2 on all four sides - /// - /// Size the ContentPresenter will assume. - protected override Size ArrangeOverride(Size finalSize) - { - Rect childArrangeRect = new Rect(); - - childArrangeRect.Width = Math.Max(0d, finalSize.Width - 4.0); - childArrangeRect.Height = Math.Max(0d, finalSize.Height - 4.0); - childArrangeRect.X = (finalSize.Width - childArrangeRect.Width) * 0.5; - childArrangeRect.Y = (finalSize.Height - childArrangeRect.Height) * 0.5; - - UIElement child = Child; - if (child != null) - { - child.Arrange(childArrangeRect); - } - - return finalSize; - } - - - /// - /// Render callback. - /// - protected override void OnRender(DrawingContext drawingContext) - { - Rect bounds = new Rect(0, 0, ActualWidth, ActualHeight); - - // Draw Background - DrawBackground(drawingContext, ref bounds); - - // Draw Border dropshadows - DrawDropShadows(drawingContext, ref bounds); - - // Draw outer border - DrawBorder(drawingContext, ref bounds); - - // Draw innerborder - DrawInnerBorder(drawingContext, ref bounds); - } - - - private void DrawBackground(DrawingContext dc, ref Rect bounds) - { - if (!IsEnabled && !RoundCorners) - return; - - Brush fill = Background; - if ((bounds.Width > 4.0) && (bounds.Height > 4.0)) - { - Rect backgroundRect = new Rect(bounds.Left + 1.0, - bounds.Top + 1.0, - bounds.Width - 2.0, - bounds.Height - 2.0); - - // Draw Background - if (fill != null) - dc.DrawRectangle(fill, null, backgroundRect); - - // Draw BackgroundOverlay - fill = BackgroundOverlay; - if( fill != null) - dc.DrawRectangle(fill, null, backgroundRect); - } - } - - // Draw the Pressed dropshadows - private void DrawDropShadows(DrawingContext dc, ref Rect bounds) - { - if ((bounds.Width > 4.0) && (bounds.Height > 4.0)) - { - Brush leftShadow = LeftDropShadowBrush; - - if (leftShadow != null) - { - dc.DrawRectangle(leftShadow, null, new Rect(1.0, 1.0, 2.0, bounds.Bottom - 2.0)); - } - - Brush topShadow = TopDropShadowBrush; - - if (topShadow != null) - { - dc.DrawRectangle(topShadow, null, new Rect(1.0, 1.0, bounds.Right - 2.0, 2.0)); - } - } - } - - // Draw the main border - private void DrawBorder(DrawingContext dc, ref Rect bounds) - { - if ((bounds.Width >= 5.0) && (bounds.Height >= 5.0)) - { - Brush border = BorderBrush; - Pen pen = null; - - if (border != null) - { - if (_commonBorderPen == null) // Common case, if non-null, avoid the lock - { - lock (_resourceAccess ) // If non-null, lock to create the pen for thread safety - { - if (_commonBorderPen == null) // Check again in case _pen was created within the last line - { - // Assume that the first render of Button uses the most common brush for the app. - // This breaks down if (a) the first Button is disabled, (b) the first Button is - // customized, or (c) ButtonChrome becomes more broadly used than just on Button. - // - // If these cons sufficiently weaken the effectiveness of this cache, then we need - // to build a larger brush-to-pen mapping cache. - - // If the brush is not already frozen, we need to create our own - // copy. Otherwise we will inadvertently freeze the user's - // BorderBrush when we freeze the pen below. - if (!border.IsFrozen && border.CanFreeze) - { - border = border.Clone(); - border.Freeze(); - } - - Pen commonPen = new Pen(border, 1); - if (commonPen.CanFreeze) - { - // Only save frozen pens, some brushes such as VisualBrush - // can not be frozen - commonPen.Freeze(); - _commonBorderPen = commonPen; - } - } - } - } - - if (_commonBorderPen != null && border == _commonBorderPen.Brush) - { - - pen = _commonBorderPen; - } - else - { - if (!border.IsFrozen && border.CanFreeze) - { - border = border.Clone(); - border.Freeze(); - } - - pen = new Pen(border, 1); - if (pen.CanFreeze) - { - pen.Freeze(); - } - } - } - - - Pen overlayPen = BorderOverlayPen; - - if (pen != null || overlayPen != null) - { - if (RoundCorners) - { - Rect rect = new Rect(bounds.Left + 0.5, - bounds.Top + 0.5, - bounds.Width - 1.0, - bounds.Height - 1.0); - - if (IsEnabled && pen != null) - dc.DrawRoundedRectangle(null, pen, rect, 2.75, 2.75); - - if (overlayPen != null) - dc.DrawRoundedRectangle(null, overlayPen, rect, 2.75, 2.75); - } - else - { - // Left side is flat, have to generate a geometry because - // DrawRoundedRectangle does not let you specify per corner radii - PathFigure borderFigure = new PathFigure(); - - borderFigure.StartPoint = new Point(0.5, 0.5); - borderFigure.Segments.Add(new LineSegment(new Point(0.5, bounds.Bottom - 0.5), true)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 2.5, bounds.Bottom - 0.5), true)); - borderFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 0.5, bounds.Bottom - 2.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - 0.5, bounds.Top + 2.5), true)); - borderFigure.Segments.Add(new ArcSegment(new Point(bounds.Right - 2.5, bounds.Top + 0.5), new Size(2.0, 2.0), 0.0, false, SweepDirection.Counterclockwise, true)); - borderFigure.IsClosed = true; - - PathGeometry borderGeometry = new PathGeometry(); - borderGeometry.Figures.Add(borderFigure); - - if (IsEnabled && pen != null) - dc.DrawGeometry(null, pen, borderGeometry); - - if (overlayPen != null) - dc.DrawGeometry(null, overlayPen, borderGeometry); - } - } - } - } - - - // Draw the inner border - private void DrawInnerBorder(DrawingContext dc, ref Rect bounds) - { - if (!IsEnabled && !RoundCorners) - return; - - if ((bounds.Width >= 4.0) && (bounds.Height >= 4.0)) - { - Pen innerBorder = InnerBorderPen; - - if (innerBorder != null) - { - dc.DrawRoundedRectangle(null, innerBorder, new Rect(bounds.Left + 1.5, bounds.Top + 1.5, bounds.Width - 3.0, bounds.Height - 3.0), 1.75, 1.75); - } - } - } - - #endregion - - #region Private Properties - - // - // This property - // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject - // 2. This is a performance optimization - // - internal override int EffectiveValuesInitialSize - { - get { return 9; } - } - - private bool Animates - { - get - { - return SystemParameters.PowerLineStatus == PowerLineStatus.Online && - SystemParameters.ClientAreaAnimation && - RenderCapability.Tier > 0 && - IsEnabled; - } - } - - - private static LinearGradientBrush CommonHoverBackgroundOverlay - { - get - { - if (_commonHoverBackgroundOverlay == null) - { - lock (_resourceAccess) - { - if (_commonHoverBackgroundOverlay == null) - { - LinearGradientBrush temp = new LinearGradientBrush(); - temp.StartPoint = new Point(0, 0); - temp.EndPoint = new Point(0, 1); - - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEA, 0xF6, 0xFD), 0)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xD9, 0xF0, 0xFC), 0.5)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBE, 0xE6, 0xFD), 0.5)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA7, 0xD9, 0xF5), 1)); - - temp.Freeze(); - - // Static field must not be set until the local has been frozen - _commonHoverBackgroundOverlay = temp; - } - } - } - return _commonHoverBackgroundOverlay; - } - } - - private static LinearGradientBrush CommonPressedBackgroundOverlay - { - get - { - if (_commonPressedBackgroundOverlay == null) - { - lock (_resourceAccess) - { - if (_commonPressedBackgroundOverlay == null) - { - LinearGradientBrush temp = new LinearGradientBrush(); - temp.StartPoint = new Point(0, 0); - temp.EndPoint = new Point(0, 1); - - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC2, 0xE4, 0xF6), 0.5)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAB, 0xDA, 0xF3), 0.5)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x90, 0xCB, 0xEB), 1)); - - temp.Freeze(); - _commonPressedBackgroundOverlay = temp; - } - } - } - return _commonPressedBackgroundOverlay; - } - } - - private static SolidColorBrush CommonDisabledBackgroundOverlay - { - get - { - if (_commonDisabledBackgroundOverlay == null) - { - lock (_resourceAccess) - { - if (_commonDisabledBackgroundOverlay == null) - { - SolidColorBrush temp = new SolidColorBrush(Color.FromRgb(0xF4, 0xF4, 0xF4)); - temp.Freeze(); - _commonDisabledBackgroundOverlay = temp; - } - } - } - return _commonDisabledBackgroundOverlay; - } - } - - private Brush BackgroundOverlay - { - get - { - if (!IsEnabled) - { - return CommonDisabledBackgroundOverlay; - } - - if (!Animates) - { - if (RenderPressed) - { - return CommonPressedBackgroundOverlay; - } - else if (RenderMouseOver) - { - return CommonHoverBackgroundOverlay; - } - else - { - return null; - } - } - - if (_localResources != null) - { - if (_localResources.BackgroundOverlay == null) - { - _localResources.BackgroundOverlay = CommonHoverBackgroundOverlay.Clone(); - _localResources.BackgroundOverlay.Opacity = 0; - } - return _localResources.BackgroundOverlay; - } - else - { - return null; - } - } - } - - private static Pen CommonHoverBorderOverlay - { - get - { - if (_commonHoverBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonHoverBorderOverlay == null) - { - Pen temp = new Pen(); - temp.Thickness = 1; - temp.Brush = new SolidColorBrush(Color.FromRgb(0x3C, 0x7F, 0xB1)); - temp.Freeze(); - _commonHoverBorderOverlay = temp; - } - } - } - return _commonHoverBorderOverlay; - } - } - - private static Pen CommonPressedBorderOverlay - { - get - { - if (_commonPressedBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonPressedBorderOverlay == null) - { - Pen temp = new Pen(); - temp.Thickness = 1; - temp.Brush = new SolidColorBrush(Color.FromRgb(0x2C, 0x62, 0x8B)); - temp.Freeze(); - - _commonPressedBorderOverlay = temp; - } - } - } - return _commonPressedBorderOverlay; - } - } - - private static Pen CommonDisabledBorderOverlay - { - get - { - if (_commonDisabledBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonDisabledBorderOverlay == null) - { - Pen temp = new Pen(); - temp.Thickness = 1; - temp.Brush = new SolidColorBrush(Color.FromRgb(0xAD, 0xB2, 0xB5)); - temp.Freeze(); - _commonDisabledBorderOverlay = temp; - } - } - } - return _commonDisabledBorderOverlay; - } - } - - private Pen BorderOverlayPen - { - get - { - if (!IsEnabled) - { - if (RoundCorners) - { - return CommonDisabledBorderOverlay; - } - else - { - return null; - } - } - - if (!Animates) - { - if (RenderPressed) - { - return CommonPressedBorderOverlay; - } - else if (RenderMouseOver) - { - return CommonHoverBorderOverlay; - } - else - { - return null; - } - } - - if (_localResources != null) - { - if (_localResources.BorderOverlayPen == null) - { - _localResources.BorderOverlayPen = CommonHoverBorderOverlay.Clone(); - _localResources.BorderOverlayPen.Brush.Opacity = 0; - } - return _localResources.BorderOverlayPen; - } - else - { - return null; - } - } - } - - private static Pen CommonInnerBorderPen - { - get - { - if (_commonInnerBorderPen == null) - { - lock (_resourceAccess) - { - if (_commonInnerBorderPen == null) - { - Pen temp = new Pen(); - - temp.Thickness = 1; - - LinearGradientBrush brush = new LinearGradientBrush(); - brush.StartPoint = new Point(0,0); - brush.EndPoint = new Point(0,1); - - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFA,0xFF,0xFF,0xFF), 0)); - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0x85,0xFF,0xFF,0xFF), 1)); - - temp.Brush = brush; - temp.Freeze(); - _commonInnerBorderPen = temp; - } - } - } - return _commonInnerBorderPen; - } - } - - - private static Pen CommonDefaultedInnerBorderPen - { - get - { - if (_commonDefaultedInnerBorderPen == null) - { - lock (_resourceAccess) - { - if (_commonDefaultedInnerBorderPen == null) - { - Pen temp = new Pen(); - temp.Thickness = 1; - temp.Brush = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0xCC, 0xFF)); - temp.Freeze(); - _commonDefaultedInnerBorderPen = temp; - } - } - } - return _commonDefaultedInnerBorderPen; - } - } - - - - private Pen InnerBorderPen - { - get - { - if (!IsEnabled) - { - return CommonInnerBorderPen; - } - - if (!Animates) - { - if (RenderPressed) - { - return null; - } - else if (RenderDefaulted) - { - return CommonDefaultedInnerBorderPen; - } - else - { - return CommonInnerBorderPen; - } - } - - if (_localResources != null) - { - if (_localResources.InnerBorderPen == null) - { - _localResources.InnerBorderPen = CommonInnerBorderPen.Clone(); - } - return _localResources.InnerBorderPen; - } - else - { - return CommonInnerBorderPen; - } - } - } - - private static LinearGradientBrush CommonPressedLeftDropShadowBrush - { - get - { - if (_commonPressedLeftDropShadowBrush == null) - { - lock (_resourceAccess) - { - if (_commonPressedLeftDropShadowBrush == null) - { - LinearGradientBrush temp = new LinearGradientBrush(); - temp.StartPoint = new Point(0, 0); - temp.EndPoint = new Point(1, 0); - - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x80, 0x33, 0x33, 0x33), 0)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0x33, 0x33, 0x33), 1)); - - temp.Freeze(); - _commonPressedLeftDropShadowBrush = temp; - } - } - } - return _commonPressedLeftDropShadowBrush; - } - } - - - private LinearGradientBrush LeftDropShadowBrush - { - get - { - if (!IsEnabled) - { - return null; - } - - if (!Animates) - { - if (RenderPressed) - { - return CommonPressedLeftDropShadowBrush; - } - else - { - return null; - } - } - - if (_localResources != null) - { - if (_localResources.LeftDropShadowBrush == null) - { - _localResources.LeftDropShadowBrush = CommonPressedLeftDropShadowBrush.Clone(); - _localResources.LeftDropShadowBrush.Opacity = 0; - } - return _localResources.LeftDropShadowBrush; - } - else - { - return null; - } - } - } - private static LinearGradientBrush CommonPressedTopDropShadowBrush - { - get - { - if (_commonPressedTopDropShadowBrush == null) - { - lock (_resourceAccess) - { - if (_commonPressedTopDropShadowBrush == null) - { - LinearGradientBrush temp = new LinearGradientBrush(); - temp.StartPoint = new Point(0, 0); - temp.EndPoint = new Point(0, 1); - - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x80, 0x33, 0x33, 0x33), 0)); - temp.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0x33, 0x33, 0x33), 1)); - - temp.Freeze(); - _commonPressedTopDropShadowBrush = temp; - } - } - } - return _commonPressedTopDropShadowBrush; - } - } - - private LinearGradientBrush TopDropShadowBrush - { - get - { - if (!IsEnabled) - { - return null; - } - - if (!Animates) - { - if (RenderPressed) - { - return CommonPressedTopDropShadowBrush; - } - else - { - return null; - } - } - - if (_localResources != null) - { - if (_localResources.TopDropShadowBrush == null) - { - _localResources.TopDropShadowBrush = CommonPressedTopDropShadowBrush.Clone(); - _localResources.TopDropShadowBrush.Opacity = 0; - } - return _localResources.TopDropShadowBrush; - } - else - { - return null; - } - } - } - - // Common LocalResources - private static Pen _commonBorderPen; - private static Pen _commonInnerBorderPen; - - private static Pen _commonDisabledBorderOverlay; - private static SolidColorBrush _commonDisabledBackgroundOverlay; - - private static Pen _commonDefaultedInnerBorderPen; - - private static LinearGradientBrush _commonHoverBackgroundOverlay; - private static Pen _commonHoverBorderOverlay; - - - private static LinearGradientBrush _commonPressedBackgroundOverlay; - private static Pen _commonPressedBorderOverlay; - - private static LinearGradientBrush _commonPressedLeftDropShadowBrush; - private static LinearGradientBrush _commonPressedTopDropShadowBrush; - - - private static object _resourceAccess = new object(); - - // Per instance resources - - private LocalResources _localResources; - - private class LocalResources - { - public Pen BorderOverlayPen; - public Pen InnerBorderPen; - public LinearGradientBrush BackgroundOverlay; - public LinearGradientBrush LeftDropShadowBrush; - public LinearGradientBrush TopDropShadowBrush; - } - - #endregion - } -} - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs deleted file mode 100644 index c8cfee99513..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Microsoft/Windows/Themes/ListBoxChrome.cs +++ /dev/null @@ -1,693 +0,0 @@ -// 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.Windows.Shapes; -using System.Windows.Controls; -using System.Diagnostics; -using System.Threading; - -using System.ComponentModel; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Animation; -using MS.Internal; - -using System; - -namespace Microsoft.Windows.Themes -{ - /// - /// The ListBoxChrome element - /// This element is a theme-specific type that is used as an optimization - /// for a common complex rendering used in Windows 11 themes - /// - /// - public sealed class ListBoxChrome : Decorator - { - #region Constructors - - static ListBoxChrome() - { - IsEnabledProperty.OverrideMetadata(typeof(ListBoxChrome), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); - } - - /// - /// Instantiates a new instance of a ListBoxChrome with no parent element. - /// - /// - public ListBoxChrome() - { - } - - #endregion Constructors - - #region Dynamic Properties - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty BackgroundProperty = - Control.BackgroundProperty.AddOwner( - typeof(ListBoxChrome), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// The Background property defines the brush used to fill the background of the button. - /// - public Brush Background - { - get { return (Brush) GetValue(BackgroundProperty); } - set { SetValue(BackgroundProperty, value); } - } - - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty BorderBrushProperty = - Border.BorderBrushProperty.AddOwner( - typeof(ListBoxChrome), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// The BorderBrush property defines the brush used to draw the outer border. - /// - public Brush BorderBrush - { - get { return (Brush) GetValue(BorderBrushProperty); } - set { SetValue(BorderBrushProperty, value); } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty BorderThicknessProperty = - Border.BorderThicknessProperty.AddOwner( - typeof(ListBoxChrome), - new FrameworkPropertyMetadata( - new Thickness(1), - FrameworkPropertyMetadataOptions.AffectsRender)); - - /// - /// The BorderThickness property defines the thickness of the border. - /// - public Thickness BorderThickness - { - get { return (Thickness)GetValue(BorderThicknessProperty); } - set { SetValue(BorderThicknessProperty, value); } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RenderMouseOverProperty = - DependencyProperty.Register("RenderMouseOver", - typeof(bool), - typeof(ListBoxChrome), - new FrameworkPropertyMetadata( - false, - new PropertyChangedCallback(OnRenderMouseOverChanged))); - - /// - /// When true the chrome renders with a mouse over look. - /// - public bool RenderMouseOver - { - get { return (bool)GetValue(RenderMouseOverProperty); } - set { SetValue(RenderMouseOverProperty, value); } - } - - private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ListBoxChrome chrome = ((ListBoxChrome)o); - - if (chrome.RenderFocused) - { - return; - } - - if (chrome.Animates) - { - if (((bool)e.NewValue)) - { - if (chrome._localResources == null) - { - chrome._localResources = new LocalResources(); - chrome.InvalidateVisual(); - } - - Duration duration = new Duration(TimeSpan.FromSeconds(0.3)); - - DoubleAnimation da = new DoubleAnimation(1, duration); - - chrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, da); - } - else if (chrome._localResources == null) - { - chrome.InvalidateVisual(); - } - else - { - Duration duration = new Duration(TimeSpan.FromSeconds(0.2)); - - DoubleAnimation da = new DoubleAnimation(); - da.Duration = duration; - - chrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, da); - } - } - else - { - chrome._localResources = null; - chrome.InvalidateVisual(); - } - } - - /// - /// DependencyProperty for property. - /// - public static readonly DependencyProperty RenderFocusedProperty = - DependencyProperty.Register("RenderFocused", - typeof(bool), - typeof(ListBoxChrome), - new FrameworkPropertyMetadata( - false, - new PropertyChangedCallback(OnRenderFocusedChanged))); - - /// - /// When true the chrome renders with a Focused look. - /// - public bool RenderFocused - { - get { return (bool)GetValue(RenderFocusedProperty); } - set { SetValue(RenderFocusedProperty, value); } - } - - private static void OnRenderFocusedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ListBoxChrome chrome = ((ListBoxChrome)o); - - chrome._localResources = null; - chrome.InvalidateVisual(); - } - - #endregion Dynamic Properties - - #region Protected Methods - - /// - /// Updates DesiredSize of the ListBoxChrome. Called by parent UIElement. This is the first pass of layout. - /// - /// Available size is an "upper limit" that the return value should not exceed. - /// The ListBoxChrome's desired size. - protected override Size MeasureOverride(Size availableSize) - { - Size desired; - - Thickness border = BorderThickness; - double borderX = border.Left + border.Right; - double borderY = border.Top + border.Bottom; - - // When BorderThickness is 0, draw no border - otherwise add 1 on each side - // for inner border - if (borderX > 0 || borderY > 0) - { - borderX += 2.0; - borderY += 2.0; - } - - UIElement child = Child; - if (child != null) - { - Size childConstraint = new Size(); - bool isWidthTooSmall = (availableSize.Width < borderX); - bool isHeightTooSmall = (availableSize.Height < borderY); - - if (!isWidthTooSmall) - { - childConstraint.Width = availableSize.Width - borderX; - } - if (!isHeightTooSmall) - { - childConstraint.Height = availableSize.Height - borderY; - } - - child.Measure(childConstraint); - - desired = child.DesiredSize; - - if (!isWidthTooSmall) - { - desired.Width += borderX; - } - if (!isHeightTooSmall) - { - desired.Height += borderY; - } - } - else - { - desired = new Size(Math.Min(borderX, availableSize.Width), Math.Min(borderY, availableSize.Height)); - } - - return desired; - } - - /// - /// ListBoxChrome computes the position of its single child inside child's Margin and calls Arrange - /// on the child. - /// - /// - /// ListBoxChrome basically inflates the desired size of its one child by 2 on all four sides - /// - /// Size the ContentPresenter will assume. - protected override Size ArrangeOverride(Size finalSize) - { - Rect childArrangeRect = new Rect(); - - Thickness border = BorderThickness; - double borderX = border.Left + border.Right; - double borderY = border.Top + border.Bottom; - - // When BorderThickness is 0, draw no border - otherwise add 1 on each side - // for inner border - if (borderX > 0 || borderY > 0) - { - border.Left += 1.0; - border.Top += 1.0; - borderX += 2.0; - borderY += 2.0; - } - - if ((finalSize.Width > borderX) && (finalSize.Height > borderY)) - { - childArrangeRect.X = border.Left; - childArrangeRect.Y = border.Top; - childArrangeRect.Width = finalSize.Width - borderX; - childArrangeRect.Height = finalSize.Height - borderY; - } - - if (Child != null) - { - Child.Arrange(childArrangeRect); - } - - return finalSize; - } - - - /// - /// Render callback. - /// - protected override void OnRender(DrawingContext dc) - { - Rect bounds = new Rect(0, 0, ActualWidth, ActualHeight); - - Thickness border = BorderThickness; - double borderX = border.Left + border.Right; - double borderY = border.Top + border.Bottom; - - // ListBoxChrome is rendered with a border of BorderThickness - // Inside this is the Background. Inside the background - // is the Background overlay for disabled controls which - // is offset by 1 px. - - bool isSimpleBorder = border.Left == 1.0 && border.Right == 1.0 && - border.Top == 1.0 && border.Bottom == 1.0; - - double innerBorderThickness = (borderX == 0.0 && borderY == 0.0) ? 0.0 : 1.0; - double innerBorderThickness2 = 2 * innerBorderThickness; - - if ((bounds.Width > borderX) && - (bounds.Height > borderY)) - { - Rect backgroundRect = new Rect(bounds.Left + border.Left, - bounds.Top + border.Top, - bounds.Width - borderX, - bounds.Height - borderY); - - Brush fill = Background; - - // Draw Background - if (fill != null) - dc.DrawRectangle(fill, null, backgroundRect); - - // Draw Background Overlay inset by 1px from edge of main border - if ((bounds.Width > borderX + innerBorderThickness2) && - (bounds.Height > borderY + innerBorderThickness2)) - { - backgroundRect = new Rect(bounds.Left + border.Left + innerBorderThickness, - bounds.Top + border.Top + innerBorderThickness, - bounds.Width - borderX - innerBorderThickness2, - bounds.Height - borderY - innerBorderThickness2); - - // Draw BackgroundOverlay - fill = BackgroundOverlay; - if (fill != null) - dc.DrawRoundedRectangle(fill, null, backgroundRect, 1, 1); - } - } - - // Draw borders - // innerBorderThickness is 0 when the listbox border is 0 - if (innerBorderThickness > 0) - { - // Draw Main border - if ((bounds.Width >= borderX) && - (bounds.Height >= borderY)) - { - if (isSimpleBorder) - { - Rect rect = new Rect(bounds.Left + 0.5, - bounds.Top + 0.5, - bounds.Width - 1.0, - bounds.Height - 1.0); - - Pen pen = GetBorderPen(BorderBrush); - Pen overlayPen = BorderOverlayPen; - - if (pen != null) - dc.DrawRoundedRectangle(null, pen, rect, 1.0, 1.0); - - if (overlayPen != null) - dc.DrawRoundedRectangle(null, overlayPen, rect, 1.0, 1.0); - } - else - { - Geometry geometry = GetBorderGeometry(border, bounds); - - if (BorderBrush != null) - dc.DrawGeometry(BorderBrush, null, geometry); - } - } - } - } - - #endregion - - #region Private Properties - - // - // This property - // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject - // 2. This is a performance optimization - // - internal override int EffectiveValuesInitialSize - { - get { return 9; } - } - - private bool Animates - { - get - { - return SystemParameters.ClientAreaAnimation && - RenderCapability.Tier > 0 && - IsEnabled; - } - } - - private static Pen GetBorderPen(Brush border) - { - Pen pen = null; - - if (border != null) - { - if (_commonBorderPen == null) // Common case, if non-null, avoid the lock - { - lock (_resourceAccess) // If non-null, lock to create the pen for thread safety - { - if (_commonBorderPen == null) // Check again in case _pen was created within the last line - { - // Assume that the first render of Button uses the most common brush for the app. - // This breaks down if (a) the first Button is disabled, (b) the first Button is - // customized, or (c) ListBoxChrome becomes more broadly used than just on Button. - // - // If these cons sufficiently weaken the effectiveness of this cache, then we need - // to build a larger brush-to-pen mapping cache. - - // If the brush is not already frozen, we need to create our own - // copy. Otherwise we will inadvertently freeze the user's - // BorderBrush when we freeze the pen below. - if (!border.IsFrozen && border.CanFreeze) - { - border = border.Clone(); - border.Freeze(); - } - - Pen commonPen = new Pen(border, 1); - if (commonPen.CanFreeze) - { - // Only save frozen pens, some brushes such as VisualBrush - // can not be frozen - commonPen.Freeze(); - _commonBorderPen = commonPen; - } - } - } - } - - if (_commonBorderPen != null && border == _commonBorderPen.Brush) - { - - pen = _commonBorderPen; - } - else - { - if (!border.IsFrozen && border.CanFreeze) - { - border = border.Clone(); - border.Freeze(); - } - - pen = new Pen(border, 1); - if (pen.CanFreeze) - { - pen.Freeze(); - } - } - } - return pen; - } - - private static Geometry GetBorderGeometry(Thickness thickness, Rect bounds) - { - PathFigure borderFigure = new PathFigure(); - - borderFigure.StartPoint = new Point(bounds.Left, bounds.Top); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Left, bounds.Bottom), false)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right, bounds.Bottom), false)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right, bounds.Top), false)); - borderFigure.IsClosed = true; - - PathGeometry borderGeometry = new PathGeometry(); - borderGeometry.Figures.Add(borderFigure); - - borderFigure = new PathFigure(); - - borderFigure.StartPoint = new Point(bounds.Left + thickness.Left, bounds.Top + thickness.Top); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Left + thickness.Left, bounds.Bottom - thickness.Bottom), false)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - thickness.Right, bounds.Bottom - thickness.Bottom), false)); - borderFigure.Segments.Add(new LineSegment(new Point(bounds.Right - thickness.Right, bounds.Top + thickness.Top), false)); - borderFigure.IsClosed = true; - - borderGeometry.Figures.Add(borderFigure); - - return borderGeometry; - } - - - private static SolidColorBrush CommonDisabledBackgroundOverlay - { - get - { - if (_commonDisabledBackgroundOverlay == null) - { - lock (_resourceAccess) - { - if (_commonDisabledBackgroundOverlay == null) - { - SolidColorBrush temp = new SolidColorBrush(Color.FromRgb(0xF4, 0xF4, 0xF4)); - temp.Freeze(); - - // Static field must not be set until the local has been frozen - _commonDisabledBackgroundOverlay = temp; - } - } - } - return _commonDisabledBackgroundOverlay; - } - } - - private static Pen CommonHoverBorderOverlay - { - get - { - if (_commonHoverBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonHoverBorderOverlay == null) - { - Pen temp = new Pen(); - - temp.Thickness = 1; - - LinearGradientBrush brush = new LinearGradientBrush(); - brush.StartPoint = new Point(0, 0); - brush.EndPoint = new Point(0, 20); - brush.MappingMode = BrushMappingMode.Absolute; - - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x57, 0x94, 0xBF), 0.05)); - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xD5, 0xEA), 0.07)); - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC7, 0xE2, 0xF1), 1)); - - temp.Brush = brush; - temp.Freeze(); - - _commonHoverBorderOverlay = temp; - } - } - } - return _commonHoverBorderOverlay; - } - } - - private static Pen CommonFocusedBorderOverlay - { - get - { - if (_commonFocusedBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonFocusedBorderOverlay == null) - { - Pen temp = new Pen(); - - - temp.Thickness = 1; - - LinearGradientBrush brush = new LinearGradientBrush(); - brush.StartPoint = new Point(0, 0); - brush.EndPoint = new Point(0, 20); - brush.MappingMode = BrushMappingMode.Absolute; - - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3D, 0x7B, 0xAD), 0.05)); - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA4, 0xC9, 0xE3), 0.07)); - brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xD9, 0xED), 1)); - - temp.Brush = brush; - temp.Freeze(); - - _commonFocusedBorderOverlay = temp; - } - } - } - return _commonFocusedBorderOverlay; - } - } - - private static Pen CommonDisabledBorderOverlay - { - get - { - if (_commonDisabledBorderOverlay == null) - { - lock (_resourceAccess) - { - if (_commonDisabledBorderOverlay == null) - { - Pen temp = new Pen(); - temp.Thickness = 1; - temp.Brush = new SolidColorBrush(Color.FromRgb(0xAD, 0xB2, 0xB5)); - temp.Freeze(); - _commonDisabledBorderOverlay = temp; - } - } - } - return _commonDisabledBorderOverlay; - } - } - - - - - private Brush BackgroundOverlay - { - get - { - if (!IsEnabled) - { - return CommonDisabledBackgroundOverlay; - } - else - { - return null; - } - } - } - - - private Pen BorderOverlayPen - { - get - { - if (!IsEnabled) - { - return CommonDisabledBorderOverlay; - } - - if (_localResources != null) - { - if (_localResources.BorderOverlayPen == null) - { - _localResources.BorderOverlayPen = CommonHoverBorderOverlay.Clone(); - _localResources.BorderOverlayPen.Brush.Opacity = 0; - } - return _localResources.BorderOverlayPen; - } - - if (RenderFocused) - { - return CommonFocusedBorderOverlay; - } - else if (RenderMouseOver) - { - return CommonHoverBorderOverlay; - } - else - { - return null; - } - } - } - - private static SolidColorBrush _commonDisabledBackgroundOverlay; - - private static Pen _commonBorderPen; - - private static Pen _commonDisabledBorderOverlay; - private static Pen _commonHoverBorderOverlay; - private static Pen _commonFocusedBorderOverlay; - - private static object _resourceAccess = new object(); - - // Per instance resources - - private LocalResources _localResources; - - private class LocalResources - { - public Pen BorderOverlayPen; - } - - #endregion - } -} - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml index e41ea626286..b26203bcbf9 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/PresentationFramework.Win11.xaml @@ -17,7 +17,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml index 051fbdc2bab..be45ed45837 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml @@ -81,7 +81,7 @@ - + - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml index 5407fe2377d..7fda4e47119 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -39,7 +39,7 @@ - - + - \ No newline at end of file From d82b90369cd2d4b79fe913babf329eed20f40e1b Mon Sep 17 00:00:00 2001 From: dipeshmsft Date: Fri, 23 Feb 2024 19:42:02 +0530 Subject: [PATCH 098/185] Removed SystemDropShadowChrome from Win11 style --- .../PresentationFramework.Win11.csproj | 2 +- .../Styles/NavigationWindow.xaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj index fa0fd3b78a3..10a504777ea 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -22,7 +22,7 @@ MSBuild:Compile - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml index 065c9942685..9d7d88be6f9 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml @@ -61,8 +61,8 @@ IsOpen="{Binding Path=(MenuItem.IsSubmenuOpen),RelativeSource={RelativeSource TemplatedParent}}" Focusable="false" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"> - + - + - - + --> From 1321dd90b91f667c7497c81973d127c2a6652a46 Mon Sep 17 00:00:00 2001 From: dipeshmsft Date: Sat, 24 Feb 2024 12:11:12 +0530 Subject: [PATCH 099/185] Remove extra properties from PasswordBox --- .../System/Windows/Controls/PasswordBox.cs | 85 +++++-------------- .../Styles/PasswordBox.xaml | 41 +-------- 2 files changed, 25 insertions(+), 101 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs index ce8e33e5ed8..4270bdae59b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs @@ -348,43 +348,20 @@ public bool IsSelectionActive } /// - /// Defines which side the icon should be placed on. - /// - public ElementPlacement IconPlacement - { - get => (ElementPlacement)GetValue(IconPlacementProperty); - set => SetValue(IconPlacementProperty, value); - } - - /// - /// Property for . + /// /// - public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register( - nameof(IconPlacement), - typeof(ElementPlacement), - typeof(PasswordBox), - new PropertyMetadata(ElementPlacement.Left) - ); + public static readonly DependencyProperty IsInactiveSelectionHighlightEnabledProperty = + TextBoxBase.IsInactiveSelectionHighlightEnabledProperty.AddOwner(typeof(PasswordBox)); /// - /// Gets or sets displayed . + /// /// - public IconElement Icon + public bool IsInactiveSelectionHighlightEnabled { - get => (IconElement)GetValue(IconProperty); - set => SetValue(IconProperty, value); + get { return (bool)GetValue(IsInactiveSelectionHighlightEnabledProperty); } + set { SetValue(IsInactiveSelectionHighlightEnabledProperty, value); } } - /// - /// Property for . - /// - public static readonly DependencyProperty IconProperty = DependencyProperty.Register( - nameof(Icon), - typeof(IconElement), - typeof(PasswordBox), - new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement) - ); - /// /// Gets or sets numbers pattern. /// @@ -404,40 +381,6 @@ public string PlaceholderText new PropertyMetadata(String.Empty) ); - /// - /// Gets or sets a value determining whether to display the placeholder. - /// - public bool PlaceholderEnabled - { - get => (bool)GetValue(PlaceholderEnabledProperty); - set => SetValue(PlaceholderEnabledProperty, value); - } - - /// - /// Property for . - /// - public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register( - nameof(PlaceholderEnabled), - typeof(bool), - typeof(PasswordBox), - new PropertyMetadata(true) - ); - - /// - /// - /// - public static readonly DependencyProperty IsInactiveSelectionHighlightEnabledProperty = - TextBoxBase.IsInactiveSelectionHighlightEnabledProperty.AddOwner(typeof(PasswordBox)); - - /// - /// - /// - public bool IsInactiveSelectionHighlightEnabled - { - get { return (bool)GetValue(IsInactiveSelectionHighlightEnabledProperty); } - set { SetValue(IsInactiveSelectionHighlightEnabledProperty, value); } - } - #endregion Public Properties //------------------------------------------------------ @@ -1006,6 +949,18 @@ private void OnTextContainerChanged(object sender, TextContainerChangedEventArgs return; } + if(PlaceholderText != string.Empty && Password.Length > 0) + { + _placeholderText = PlaceholderText; + PlaceholderText = string.Empty; + } + + if(_placeholderText != string.Empty && Password.Length == 0) + { + PlaceholderText = _placeholderText; + _placeholderText = string.Empty; + } + RaiseEvent(new RoutedEventArgs(PasswordChangedEvent)); } @@ -1369,6 +1324,8 @@ private ITextSelection Selection // Border private Border _border; + private string _placeholderText; + // An element marked as ContentHostTemplateName which we assign our _renderScope as a child. private FrameworkElement _passwordBoxContentHost; diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml index 3f93ff8a9f8..556629f73ce 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/PasswordBox.xaml @@ -134,7 +134,7 @@ - + @@ -161,15 +161,6 @@ - - - @@ -226,23 +209,9 @@ CornerRadius="{TemplateBinding Border.CornerRadius}" /> - + - - - - - - - - - - - - - - - + @@ -263,10 +232,8 @@ - - - + From a5777fb0aa9d0f80403fd420c366af4103e3e52e Mon Sep 17 00:00:00 2001 From: dipeshmsft Date: Sat, 24 Feb 2024 20:31:28 +0530 Subject: [PATCH 100/185] Removed extra public API changes in TextBox and RichTextBox --- .../PresentationFramework-ref.baseline.txt | 40 +++++---- .../System/Windows/Controls/TextBox.cs | 90 +++++-------------- .../Styles/RichTextBox.xaml | 8 -- .../Styles/TextBox.xaml | 46 +++------- 4 files changed, 58 insertions(+), 126 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt index 94e051d5ab0..adad408a579 100644 --- a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt +++ b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt @@ -92,6 +92,27 @@ CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.Button' does not MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.IconProperty' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public System.Windows.Controls.IconElement System.Windows.Controls.Button.Icon.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public void System.Windows.Controls.Button.Icon.set(System.Windows.Controls.IconElement)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.AppearanceProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.CornerRadiusProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.MouseOverBackgroundProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.MouseOverBorderBrushProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.PressedBackgroundProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.PressedBorderBrushProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.Button.PressedForegroundProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Controls.ControlAppearance System.Windows.Controls.Button.Appearance.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.Appearance.set(System.Windows.Controls.ControlAppearance)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.CornerRadius System.Windows.Controls.Button.CornerRadius.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.CornerRadius.set(System.Windows.CornerRadius)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Media.Brush System.Windows.Controls.Button.MouseOverBackground.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.MouseOverBackground.set(System.Windows.Media.Brush)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Media.Brush System.Windows.Controls.Button.MouseOverBorderBrush.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.MouseOverBorderBrush.set(System.Windows.Media.Brush)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Media.Brush System.Windows.Controls.Button.PressedBackground.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.PressedBackground.set(System.Windows.Media.Brush)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Media.Brush System.Windows.Controls.Button.PressedBorderBrush.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.PressedBorderBrush.set(System.Windows.Media.Brush)' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Windows.Media.Brush System.Windows.Controls.Button.PressedForeground.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void System.Windows.Controls.Button.PressedForeground.set(System.Windows.Media.Brush)' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.CheckBox' changed from '[LocalizabilityAttribute(5)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.CheckBox)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.ComboBox' changed from '[LocalizabilityAttribute(6)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.ComboBox)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.ComboBoxItem' changed from '[LocalizabilityAttribute(6)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.ComboBox)]' in the implementation. @@ -214,13 +235,7 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.TextBlock.Text' changed from '[LocalizabilityAttribute(1)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Text)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.TextBox' changed from '[LocalizabilityAttribute(1)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Text)]' in the implementation. MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.ClearButtonEnabledProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.IconPlacementProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.IconProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.IsTextSelectionEnabledProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.PlaceholderEnabledProperty' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.PlaceholderTextProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.ShowClearButtonProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.TextBox.TemplateButtonCommandProperty' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.TextBox.CaretIndex' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.TextBox.LineCount' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.TextBox.MaxLength' changed from '[LocalizabilityAttribute(0, Modifiability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Modifiability=Modifiability.Unmodifiable)]' in the implementation. @@ -231,22 +246,11 @@ CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'S MembersMustExist : Member 'public System.Boolean System.Windows.Controls.TextBox.ClearButtonEnabled.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public void System.Windows.Controls.TextBox.ClearButtonEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'protected void System.Windows.Controls.TextBox.HideClearButton()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.Controls.IconElement System.Windows.Controls.TextBox.Icon.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void System.Windows.Controls.TextBox.Icon.set(System.Windows.Controls.IconElement)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.Controls.ElementPlacement System.Windows.Controls.TextBox.IconPlacement.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void System.Windows.Controls.TextBox.IconPlacement.set(System.Windows.Controls.ElementPlacement)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Boolean System.Windows.Controls.TextBox.IsTextSelectionEnabled.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void System.Windows.Controls.TextBox.IsTextSelectionEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'protected void System.Windows.Controls.TextBox.OnClearButtonClick()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'protected void System.Windows.Controls.TextBox.OnTemplateButtonClick(System.String)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Boolean System.Windows.Controls.TextBox.PlaceholderEnabled.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void System.Windows.Controls.TextBox.PlaceholderEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public System.String System.Windows.Controls.TextBox.PlaceholderText.get()' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'public void System.Windows.Controls.TextBox.PlaceholderText.set(System.String)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'protected void System.Windows.Controls.TextBox.RevealClearButton()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Boolean System.Windows.Controls.TextBox.ShowClearButton.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'protected void System.Windows.Controls.TextBox.ShowClearButton.set(System.Boolean)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Windows.Input.IRelayCommand System.Windows.Controls.TextBox.TemplateButtonCommand.get()' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Controls.TitleBar' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Controls.TitleBarButton' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Controls.TitleBarButtonType' does not exist in the implementation but it does exist in the contract. @@ -267,8 +271,6 @@ TypesMustExist : Type 'System.Windows.Controls.WindowCornerPreference' does not CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Primitives.ButtonBase' changed from '[LocalizabilityAttribute(4)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Button)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Primitives.ButtonBase.Command' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Primitives.ButtonBase.CommandParameter' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. -CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.Primitives.CalendarButton' does not implement interface 'System.Windows.Controls.IIconControl' in the implementation but it does in the contract. -CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.Primitives.CalendarDayButton' does not implement interface 'System.Windows.Controls.IIconControl' in the implementation but it does in the contract. MembersMustExist : Member 'internal void System.Windows.Controls.Primitives.GridViewRowPresenterBase.OnColumnPropertyChanged(System.Windows.Controls.GridViewColumn, System.String)' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Primitives.MenuBase' changed from '[LocalizabilityAttribute(8)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Menu)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.Primitives.MultiSelector.SelectedItems' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs index 596a6bfcbcb..6a41b26cb4b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextBox.cs @@ -965,7 +965,6 @@ public Typography Typography return new Typography(this); } } - /// /// Property for . /// @@ -976,15 +975,6 @@ public Typography Typography new PropertyMetadata(String.Empty) ); - /// - /// Property for . - /// - public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register( - nameof(PlaceholderEnabled), - typeof(bool), - typeof(TextBox), - new PropertyMetadata(true) - ); /// /// Property for . @@ -993,33 +983,14 @@ public Typography Typography nameof(ClearButtonEnabled), typeof(bool), typeof(TextBox), - new PropertyMetadata(true) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register( - nameof(ShowClearButton), - typeof(bool), - typeof(TextBox), new PropertyMetadata(false) ); - /// - /// Property for . - /// - public static readonly DependencyProperty IsTextSelectionEnabledProperty = DependencyProperty.Register( - nameof(IsTextSelectionEnabled), - typeof(bool), - typeof(TextBox), - new PropertyMetadata(false) - ); /// /// Property for . /// - public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( + internal static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( nameof(TemplateButtonCommand), typeof(IRelayCommand), typeof(TextBox), @@ -1037,14 +1008,6 @@ public string PlaceholderText set => SetValue(PlaceholderTextProperty, value); } - /// - /// Gets or sets a value determining whether to display the placeholder. - /// - public bool PlaceholderEnabled - { - get => (bool)GetValue(PlaceholderEnabledProperty); - set => SetValue(PlaceholderEnabledProperty, value); - } /// /// Gets or sets a value determining whether to enable the clear button. @@ -1055,28 +1018,10 @@ public bool ClearButtonEnabled set => SetValue(ClearButtonEnabledProperty, value); } - /// - /// Gets or sets a value determining whether to show the clear button when is focused. - /// - public bool ShowClearButton - { - get => (bool)GetValue(ShowClearButtonProperty); - protected set => SetValue(ShowClearButtonProperty, value); - } - - /// - /// TODO - /// - public bool IsTextSelectionEnabled - { - get => (bool)GetValue(IsTextSelectionEnabledProperty); - set => SetValue(IsTextSelectionEnabledProperty, value); - } - /// /// Command triggered after clicking the button. /// - public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); + internal IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); #endregion @@ -1087,11 +1032,18 @@ protected override void OnTextChanged(TextChangedEventArgs e) { base.OnTextChanged(e); - if (PlaceholderEnabled && Text.Length > 0) - PlaceholderEnabled = false; + if (PlaceholderText != string.Empty && Text.Length > 0) + { + _placeholderText = PlaceholderText; + PlaceholderText = string.Empty; + } + - if (!PlaceholderEnabled && Text.Length < 1) - PlaceholderEnabled = true; + if (_placeholderText != string.Empty && Text.Length < 1) + { + PlaceholderText = _placeholderText; + _placeholderText = string.Empty; + } RevealClearButton(); } @@ -1115,21 +1067,23 @@ protected override void OnLostFocus(RoutedEventArgs e) } /// - /// Reveals the clear button by property. + /// Reveals the clear button by property. /// protected void RevealClearButton() { - if (ClearButtonEnabled && IsKeyboardFocusWithin) - ShowClearButton = Text.Length > 0; + if (IsKeyboardFocusWithin) + { + ClearButtonEnabled = Text.Length > 0; + } } /// - /// Hides the clear button by property. + /// Hides the clear button by property. /// protected void HideClearButton() { - if (ClearButtonEnabled && !IsKeyboardFocusWithin && ShowClearButton) - ShowClearButton = false; + if (ClearButtonEnabled && !IsKeyboardFocusWithin) + ClearButtonEnabled = false; } /// @@ -2122,6 +2076,8 @@ private static void OnTypographyChanged(DependencyObject d, DependencyPropertyCh // depth of nested calls to OnTextContainerChanged. private int _changeEventNestingCount; + private string _placeholderText; + #endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/RichTextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/RichTextBox.xaml index cd1398d4738..994939cd021 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/RichTextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/RichTextBox.xaml @@ -67,14 +67,6 @@ BasedOn="{StaticResource DefaultRichTextBoxStyle}" TargetType="{x:Type RichTextBox}"> - - - - - - - - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml index 7fda4e47119..4303361c4e0 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -11,7 +11,8 @@ + xmlns:system="clr-namespace:System;assembly=System.Runtime" + xmlns:Controls="clr-namespace:System.Windows.Controls"> 1,1,1,1 0,0,0,1 @@ -205,10 +206,10 @@ BorderBrush="Transparent" Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" Cursor="Arrow" - Foreground="{DynamicResource TextControlButtonForeground}"> - + IsTabStop ="False" + Foreground="{DynamicResource TextControlButtonForeground}" + > + @@ -235,31 +236,13 @@ CornerRadius="{TemplateBinding Border.CornerRadius}" /> - + - - - - - @@ -284,8 +267,6 @@ - - @@ -293,7 +274,7 @@ - + + + - - - - - - - From f9c1ee910bc4e11082f6bb5f27e06b0b54f5fb0c Mon Sep 17 00:00:00 2001 From: hmishra Date: Fri, 1 Mar 2024 17:29:07 +0530 Subject: [PATCH 120/185] Fix(Win11Theming): CheckBox Design Issues --- .../Resources/Theme/Dark.xaml | 4 +++ .../Resources/Theme/HC1.xaml | 3 ++ .../Resources/Theme/HC2.xaml | 3 ++ .../Resources/Theme/HCBlack.xaml | 3 ++ .../Resources/Theme/HCWhite.xaml | 3 ++ .../Resources/Theme/Light.xaml | 4 +++ .../Styles/CheckBox.xaml | 31 +++++++++++++++++++ 7 files changed, 51 insertions(+) diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Dark.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Dark.xaml index 2b296f47d2e..23833c364b0 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Dark.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Dark.xaml @@ -53,6 +53,7 @@ #0FFFFFFF #0AFFFFFF #00FFFFFF + #4A4A4A #00FFFFFF #19000000 @@ -385,7 +386,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC1.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC1.xaml index 884d02f55af..611184a2a93 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC1.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC1.xaml @@ -272,7 +272,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC2.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC2.xaml index 4ccd8d5fbfa..68ca0a24479 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC2.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HC2.xaml @@ -271,7 +271,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCBlack.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCBlack.xaml index f8c9f5e0780..4c64fc877e5 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCBlack.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCBlack.xaml @@ -271,7 +271,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCWhite.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCWhite.xaml index 923085a8920..a8600cd46c6 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCWhite.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/HCWhite.xaml @@ -271,7 +271,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml index c5e2b1d4c11..968c2735afe 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml @@ -53,6 +53,7 @@ #09000000 #06000000 #00FFFFFF + #B6B6B6 #00FFFFFF #06000000 @@ -385,7 +386,10 @@ + + + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml index 2df6aa05b1c..c9755b501e3 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml @@ -123,25 +123,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 37fccb6957f4d69666540b111e64f8ce67093558 Mon Sep 17 00:00:00 2001 From: Anjali Date: Fri, 1 Mar 2024 22:56:25 +0530 Subject: [PATCH 121/185] Fixed gradient for border brush --- .../PresentationFramework.Win11/Resources/Theme/Light.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml index c5e2b1d4c11..732ea4db586 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Resources/Theme/Light.xaml @@ -243,8 +243,8 @@ - - + + From 0d3e0ec42f645c95e4d13a9e6ef645f62df4df76 Mon Sep 17 00:00:00 2001 From: hmishra Date: Sun, 3 Mar 2024 15:01:57 +0530 Subject: [PATCH 122/185] Fix(Win11Theming): Removal of unused RDM, changing requested method name, and code refactoring --- .../PresentationFramework.csproj | 33 ++-- .../Appearance/ResourceDictionaryManager.cs | 160 ------------------ .../Windows/Appearance/WindowBackdrop.cs | 2 +- .../System/Windows/Application.cs | 4 +- .../System/Windows/DWMColorization.cs | 4 +- .../System/Windows/SystemResources.cs | 4 +- .../System/Windows/ThemeColorization.cs | 22 +-- .../System/Windows/Window.cs | 3 +- .../src/WindowsBase/MS/Internal/Utilities.cs | 4 +- 9 files changed, 38 insertions(+), 198 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ResourceDictionaryManager.cs diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index 38764e9257c..e87dd8b6de1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -403,17 +403,6 @@ - - - - - - - - - - - @@ -430,6 +419,9 @@ + + + @@ -631,6 +623,7 @@ + @@ -650,12 +643,11 @@ - - - + + @@ -793,6 +785,7 @@ + @@ -1106,12 +1099,14 @@ + + @@ -1127,6 +1122,7 @@ + @@ -1138,12 +1134,15 @@ + + + + - @@ -1349,8 +1348,6 @@ - - @@ -1363,6 +1360,7 @@ + @@ -1380,6 +1378,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ResourceDictionaryManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ResourceDictionaryManager.cs deleted file mode 100644 index 2d566b79433..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ResourceDictionaryManager.cs +++ /dev/null @@ -1,160 +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. - -using System.Collections.ObjectModel; - -namespace System.Windows.Appearance; - -/// -/// Allows managing application dictionaries. -/// -internal class ResourceDictionaryManager -{ - /// - /// Gets the namespace, e.g. the library the resource is being searched for. - /// - public string SearchNamespace { get; } - - public ResourceDictionaryManager(string searchNamespace) - { - SearchNamespace = searchNamespace; - } - - /// - /// Shows whether the application contains the . - /// - /// Any part of the resource name. - /// if it doesn't exist. - public bool HasDictionary(string resourceLookup) - { - return GetDictionary(resourceLookup) != null; - } - - /// - /// Gets the if exists. - /// - /// Any part of the resource name. - /// , if it doesn't exist. - public ResourceDictionary GetDictionary(string resourceLookup) - { - Collection applicationDictionaries = GetApplicationMergedDictionaries(); - - if (applicationDictionaries.Count == 0) - { - return null; - } - - resourceLookup = resourceLookup.ToLower().Trim(); - - foreach (ResourceDictionary t in applicationDictionaries) - { - string resourceDictionaryUri; - - if (t?.Source != null) - { - resourceDictionaryUri = t.Source.ToString().ToLower().Trim(); - - if ( - resourceDictionaryUri.Contains(SearchNamespace) - && resourceDictionaryUri.Contains(resourceLookup) - ) - { - return t; - } - } - - foreach (ResourceDictionary t1 in t.MergedDictionaries) - { - if (t1?.Source == null) - { - continue; - } - - resourceDictionaryUri = t1.Source.ToString().ToLower().Trim(); - - if ( - !resourceDictionaryUri.Contains(SearchNamespace) - || !resourceDictionaryUri.Contains(resourceLookup) - ) - { - continue; - } - - return t1; - } - } - - return null; - } - - /// - /// Shows whether the application contains the . - /// - /// Any part of the resource name. - /// A valid for the replaced resource. - /// if the dictionary was updated. otherwise. - public bool UpdateDictionary(string resourceLookup, Uri newResourceUri) - { - Collection applicationDictionaries = Application - .Current - .Resources - .MergedDictionaries; - - if (applicationDictionaries.Count == 0 || newResourceUri is null) - { - return false; - } - - resourceLookup = resourceLookup.ToLower().Trim(); - - for (var i = 0; i < applicationDictionaries.Count; i++) - { - string sourceUri; - - if (applicationDictionaries[i]?.Source != null) - { - sourceUri = applicationDictionaries[i].Source.ToString().ToLower().Trim(); - - if (sourceUri.Contains(SearchNamespace) && sourceUri.Contains(resourceLookup)) - { - applicationDictionaries[i] = new() { Source = newResourceUri }; - - return true; - } - } - - for (var j = 0; j < applicationDictionaries[i].MergedDictionaries.Count; j++) - { - if (applicationDictionaries[i].MergedDictionaries[j]?.Source == null) - { - continue; - } - - sourceUri = applicationDictionaries[i] - .MergedDictionaries[j] - .Source - .ToString() - .ToLower() - .Trim(); - - if (!sourceUri.Contains(SearchNamespace) || !sourceUri.Contains(resourceLookup)) - { - continue; - } - - applicationDictionaries[i].MergedDictionaries[j] = new() { Source = newResourceUri }; - - return true; - } - } - - return false; - } - - private Collection GetApplicationMergedDictionaries() - { - return Application.Current.Resources.MergedDictionaries; - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs index 9099cc8e153..8cbb72119bc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackdrop.cs @@ -373,7 +373,7 @@ private static Brush GetFallbackBackgroundBrush() { if(Application.IsThemeHighContrast()) { - string currentTheme = ThemeColorization.GetNewTheme(); + string currentTheme = ThemeColorization.GetSystemTheme(); if(currentTheme.Contains("hc1")) { return new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x32, 0x36)); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs index 0153de87f79..a3a1f0655a8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs @@ -1479,7 +1479,7 @@ internal virtual void PerformNavigationStateChangeTasks( internal static bool isThemeDark() { - var currentTheme = ThemeColorization.GetNewTheme(); + var currentTheme = ThemeColorization.GetSystemTheme(); if (currentTheme != null) { @@ -1491,7 +1491,7 @@ internal static bool isThemeDark() internal static bool IsThemeHighContrast() { - string currentTheme = ThemeColorization.GetNewTheme(); + string currentTheme = ThemeColorization.GetSystemTheme(); if(currentTheme != null) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DWMColorization.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DWMColorization.cs index 1fc60fc74dd..c5a0293ae06 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DWMColorization.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DWMColorization.cs @@ -38,7 +38,7 @@ internal static Color CurrentApplicationAccentColor /// /// Updated Accent Color. /// - internal static Color GetNewAccentColor() + internal static Color GetSystemAccentColor() { var dwmValue = (Int32)Registry.GetValue( _dwmKey, @@ -66,7 +66,7 @@ internal static Color GetNewAccentColor() /// internal static void ApplyAccentColors() { - Color systemAccent = GetNewAccentColor(); + Color systemAccent = GetSystemAccentColor(); Color primaryAccent; Color secondaryAccent; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs index 52253316365..a53ea5cf8f1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/SystemResources.cs @@ -1416,9 +1416,9 @@ private static IntPtr SystemThemeFilterMessage(IntPtr hwnd, int msg, IntPtr wPar if(ThemeColorization.AppInitContainsNewTheme) { string currentApplicationTheme = ThemeColorization.CurrentApplicationTheme; - string themeToApply = ThemeColorization.GetNewTheme(); + string themeToApply = ThemeColorization.GetSystemTheme(); Color currentApplicationAccentColor = DWMColorization.CurrentApplicationAccentColor; - Color accentColorToApply = DWMColorization.GetNewAccentColor(); + Color accentColorToApply = DWMColorization.GetSystemAccentColor(); if (themeToApply != currentApplicationTheme || accentColorToApply != currentApplicationAccentColor) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeColorization.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeColorization.cs index fd32dee7051..1c15c12e164 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeColorization.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeColorization.cs @@ -1,7 +1,7 @@ +using Standard; using System.Windows.Appearance; using System.Windows.Media; using Microsoft.Win32; -using MS.Internal; namespace System.Windows; @@ -96,36 +96,36 @@ internal static void UpdateApplicationResources(Uri dictionaryUri) /// internal static void ApplyTheme() { - string themeToApply = GetNewTheme(); + string themeToApply = GetSystemTheme(); Window currentWindow = Application.Current.MainWindow; - if (themeToApply.Contains("dark") && Utilities.IsOSWindows11OrNewer) + if (themeToApply.Contains("dark") && Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "dark.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.Dark, WindowBackdropType.Mica, false); } - else if(themeToApply.Contains("hcwhite") && Utilities.IsOSWindows11OrNewer) + else if(themeToApply.Contains("hcwhite") && Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hcwhite.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); } - else if(themeToApply.Contains("hcblack") && Utilities.IsOSWindows11OrNewer) + else if(themeToApply.Contains("hcblack") && Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hcblack.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); } - else if (themeToApply.Contains("hc1") && Utilities.IsOSWindows11OrNewer) + else if (themeToApply.Contains("hc1") && Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hc1.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); } - else if (themeToApply.Contains("hc2") && Utilities.IsOSWindows11OrNewer) + else if (themeToApply.Contains("hc2") && Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "hc2.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.HighContrast, WindowBackdropType.None, false); } - else if (Utilities.IsOSWindows11OrNewer) + else if (Utility.IsOSWindows11OrNewer) { UpdateApplicationResources(new Uri("pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/" + "light.xaml", UriKind.Absolute)); WindowBackgroundManager.UpdateBackground(currentWindow, ApplicationTheme.Light, WindowBackdropType.Mica, false); @@ -138,16 +138,16 @@ internal static void ApplyTheme() /// Fetches registry value /// /// string indicating the current theme - internal static string GetNewTheme() + internal static string GetSystemTheme() { - string newTheme = Registry.GetValue( + string systemTheme = Registry.GetValue( _regThemeKey, "CurrentTheme", "aero.theme" ) as string ?? String.Empty; - return newTheme; + return systemTheme; } #endregion } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs index ab0ea736eb7..e96d77c324d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs @@ -1911,9 +1911,8 @@ protected virtual void OnSourceInitialized(EventArgs e) if (handler != null) handler(this, e); } - /// - /// This even fires when window is activated. This event is non cancelable and is + /// This event fires when window is activated. This event is non cancelable and is /// for user infromational purposes /// /// diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs index bf869c52db4..ef7a18df559 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs @@ -33,7 +33,8 @@ internal static bool IsOSWindows8OrNewer { get { return _osVersion >= new Version(6, 2); } } - /// + + /// /// Whether the operating system version is greater than or equal to 10.0* (build 10240). /// public static bool IsOSWindows10OrNewer => _osVersion.Build >= 10240; @@ -42,6 +43,7 @@ internal static bool IsOSWindows8OrNewer /// Whether the operating system version is greater than or equal to 10.0* (build 22000). /// public static bool IsOSWindows11OrNewer => _osVersion.Build >= 22000; + internal static bool IsCompositionEnabled { get From 20257544a8346e4ef36a94b36fc7e303d277feb4 Mon Sep 17 00:00:00 2001 From: dipeshmsft Date: Mon, 4 Mar 2024 12:01:08 +0530 Subject: [PATCH 123/185] Removed extra classes and replaced FontIcon with TextBlock --- .../PresentationFramework.csproj | 10 - .../System/Windows/Controls/FluentWindow.cs | 231 ------------------ .../Windows/Controls/FontIconExtension.cs | 67 ----- .../Windows/Controls/IconElement/FontIcon.cs | 210 ---------------- .../Controls/IconElement/IconElement.cs | 101 -------- .../Controls/IconElement/IconSourceElement.cs | 40 --- .../IconElement/IconSourceElementConverter.cs | 68 ------ .../Windows/Controls/IconElement/ImageIcon.cs | 55 ----- .../Controls/IconElement/SymbolIcon.bmp | Bin 824 -> 0 bytes .../Controls/IconSource/FontIconSource.cs | 135 ---------- .../Windows/Controls/IconSource/IconSource.cs | 36 --- .../Windows/Controls/ImageIconExtension.cs | 60 ----- .../Windows/Controls/UiElementExtensions.cs | 46 ---- .../Controls/ClientAreaBorder.cs | 222 ----------------- .../PresentationFramework.Win11.csproj | 2 - .../Styles/Calendar.xaml | 12 +- .../Styles/CheckBox.xaml | 7 +- .../Styles/ComboBox.xaml | 14 +- .../Styles/DataGrid.xaml | 17 +- .../Styles/DatePicker.xaml | 5 +- .../Styles/Expander.xaml | 28 ++- .../Styles/MenuItem.xaml | 8 +- .../Styles/ScrollBar.xaml | 4 +- .../Styles/TextBox.xaml | 6 +- .../Styles/ToolBar.xaml | 4 +- .../Styles/TreeViewItem.xaml | 4 +- 26 files changed, 57 insertions(+), 1335 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FluentWindow.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FontIconExtension.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/FontIcon.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconElement.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElement.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElementConverter.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/ImageIcon.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/SymbolIcon.bmp delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconSource/FontIconSource.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconSource/IconSource.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ImageIconExtension.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/UiElementExtensions.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index e87dd8b6de1..6f068d4f2f4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -623,7 +623,6 @@ - @@ -639,15 +638,7 @@ - - - - - - - - @@ -785,7 +776,6 @@ - diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FluentWindow.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FluentWindow.cs deleted file mode 100644 index 561a1abfc57..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FluentWindow.cs +++ /dev/null @@ -1,231 +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. - -using System.Windows.Shell; -using System.Windows.Interop; -using System.Windows.Controls; -using System.Windows.Appearance; -// ReSharper disable once CheckNamespace -namespace System.Windows.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. - /// - protected WindowInteropHelper InteropHelper - { - get => _interopHelper ??= new WindowInteropHelper(this); - } - - /// - /// Property for . - /// - // public static readonly DependencyProperty WindowCornerPreferenceProperty = DependencyProperty.Register( - // nameof(WindowCornerPreference), - // typeof(WindowCornerPreference), - // typeof(FluentWindow), - // new PropertyMetadata(WindowCornerPreference.Round, OnCornerPreferenceChanged) - // ); - - /// - /// Property for . - /// - public static readonly DependencyProperty WindowBackdropTypeProperty = DependencyProperty.Register( - nameof(WindowBackdropType), - typeof(WindowBackdropType), - typeof(FluentWindow), - new PropertyMetadata(WindowBackdropType.None, OnBackdropTypeChanged) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty ExtendsContentIntoTitleBarProperty = - DependencyProperty.Register( - nameof(ExtendsContentIntoTitleBar), - typeof(bool), - typeof(FluentWindow), - new PropertyMetadata(false, OnExtendsContentIntoTitleBarChanged) - ); - - /// - /// Gets or sets a value determining corner preference for current . - /// - // public System.Windows.Controls.WindowCornerPreference WindowCornerPreference - // { - // get => (WindowCornerPreference)GetValue(WindowCornerPreferenceProperty); - // set => SetValue(WindowCornerPreferenceProperty, value); - // } - - /// - /// Gets or sets a value determining preferred backdrop type for current . - /// - public WindowBackdropType WindowBackdropType - { - get => (WindowBackdropType)GetValue(WindowBackdropTypeProperty); - set => SetValue(WindowBackdropTypeProperty, value); - } - - /// - /// Gets or sets a value that specifies whether the default title bar of the window should be hidden to create space for app content. - /// - public bool ExtendsContentIntoTitleBar - { - get => (bool)GetValue(ExtendsContentIntoTitleBarProperty); - set => SetValue(ExtendsContentIntoTitleBarProperty, value); - } - - /// - /// Creates new instance and sets default style. - /// - public FluentWindow() - { - SetResourceReference(StyleProperty, typeof(FluentWindow)); - } - - /// - /// Overrides default properties. - /// - static FluentWindow() - { - DefaultStyleKeyProperty.OverrideMetadata( - typeof(FluentWindow), - new FrameworkPropertyMetadata(typeof(FluentWindow)) - ); - } - - /// - protected override void OnSourceInitialized(EventArgs e) - { - // OnCornerPreferenceChanged(default, WindowCornerPreference); - OnExtendsContentIntoTitleBarChanged(default, ExtendsContentIntoTitleBar); - OnBackdropTypeChanged(default, WindowBackdropType); - - base.OnSourceInitialized(e); - } - - /// - /// Private property callback. - /// - // private static void OnCornerPreferenceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - // { - // if (d is not FluentWindow window) - // return; - - // if (e.OldValue == e.NewValue) - // return; - - // window.OnCornerPreferenceChanged( - // (WindowCornerPreference)e.OldValue, - // (WindowCornerPreference)e.NewValue - // ); - // } - - /// - /// This virtual method is called when is changed. - /// - // protected virtual void OnCornerPreferenceChanged( - // WindowCornerPreference oldValue, - // WindowCornerPreference newValue - // ) - // { - // if (InteropHelper.Handle == IntPtr.Zero) - // return; - - // UnsafeNativeMethodsWindow.ApplyWindowCornerPreference(InteropHelper.Handle, newValue); - // } - - /// - /// Private property callback. - /// - private static void OnBackdropTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is not FluentWindow window) - return; - - if (e.OldValue == e.NewValue) - return; - - window.OnBackdropTypeChanged((WindowBackdropType)e.OldValue, (WindowBackdropType)e.NewValue); - } - - /// - /// This virtual method is called when is changed. - /// - protected virtual void OnBackdropTypeChanged(WindowBackdropType oldValue, WindowBackdropType newValue) - { - if (Application.IsThemeHighContrast()) - { - newValue = WindowBackdropType.None; - } - - if (InteropHelper.Handle == IntPtr.Zero) - return; - - if (newValue == WindowBackdropType.None) - { - WindowBackdrop.RemoveBackdrop(this); - return; - } - - if (!ExtendsContentIntoTitleBar) - throw new InvalidOperationException( - $"Cannot apply backdrop effect if {nameof(ExtendsContentIntoTitleBar)} is false." - ); - - if (WindowBackdrop.IsSupported(newValue) && WindowBackdrop.RemoveBackground(this)) - WindowBackdrop.ApplyBackdrop(this, newValue); - } - - /// - /// Private property callback. - /// - private static void OnExtendsContentIntoTitleBarChanged( - DependencyObject d, - DependencyPropertyChangedEventArgs e - ) - { - if (d is not FluentWindow window) - return; - - if (e.OldValue == e.NewValue) - return; - - window.OnExtendsContentIntoTitleBarChanged((bool)e.OldValue, (bool)e.NewValue); - } - - /// - /// This virtual method is called when is changed. - /// - protected virtual void OnExtendsContentIntoTitleBarChanged(bool oldValue, bool newValue) - { - WindowStyle = WindowStyle.SingleBorderWindow; - //AllowsTransparency = true; - - WindowChrome.SetWindowChrome( - this, - new WindowChrome - { - CaptionHeight = 0, - CornerRadius = default, - GlassFrameThickness = new Thickness(-1), - ResizeBorderThickness = ResizeMode == ResizeMode.NoResize ? default : new Thickness(4), - UseAeroCaptionButtons = false - } - ); - - UnsafeNativeMethodsWindow.RemoveWindowTitlebarContents(this); - ////WindowStyleProperty.OverrideMetadata(typeof(FluentWindow), new FrameworkPropertyMetadata(WindowStyle.SingleBorderWindow)); - ////AllowsTransparencyProperty.OverrideMetadata(typeof(FluentWindow), new FrameworkPropertyMetadata(false)); - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FontIconExtension.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FontIconExtension.cs deleted file mode 100644 index 9b433c43181..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/FontIconExtension.cs +++ /dev/null @@ -1,67 +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. - -using System.Windows.Markup; -using System.Windows.Media; -using System.Windows.Controls; - -namespace System.Windows.Markup; - -/// -/// Custom which can provide . -/// -/// -/// -/// <ui:Button -/// Appearance="Primary" -/// Content="WPF UI button with font icon" -/// Icon="{ui:FontIcon '🌈'}" /> -/// -/// -/// <ui:Button Icon="{ui:FontIcon '&#x1F308;'}" /> -/// -/// -/// <ui:HyperlinkButton Icon="{ui:FontIcon '&#x1F308;'}" /> -/// -/// -/// <ui:TitleBar Icon="{ui:FontIcon '&#x1F308;'}" /> -/// -/// -[ContentProperty(nameof(Glyph))] -[MarkupExtensionReturnType(typeof(FontIcon))] -public class FontIconExtension : MarkupExtension -{ - public FontIconExtension(string glyph) - { - Glyph = glyph; - FontFamily = new FontFamily("FluentSystemIcons"); - } - - public FontIconExtension(string glyph, FontFamily fontFamily) - : this(glyph) - { - FontFamily = fontFamily; - } - - [ConstructorArgument("glyph")] - public string Glyph { get; set; } - - [ConstructorArgument("fontFamily")] - public FontFamily FontFamily { get; set; } - - public double FontSize { get; set; } - - public override object ProvideValue(IServiceProvider serviceProvider) - { - var fontIcon = new FontIcon { Glyph = Glyph, FontFamily = FontFamily }; - - if (FontSize > 0) - { - fontIcon.FontSize = FontSize; - } - - return fontIcon; - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/FontIcon.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/FontIcon.cs deleted file mode 100644 index 406ad32fb2e..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/FontIcon.cs +++ /dev/null @@ -1,210 +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. - -using System.Windows.Controls; -using System.Windows.Documents; -using FontFamily = System.Windows.Media.FontFamily; -using FontStyle = System.Windows.FontStyle; -using SystemFonts = System.Windows.SystemFonts; -using System.ComponentModel; - -// ReSharper disable once CheckNamespace -namespace System.Windows.Controls; - -/// -/// Represents an icon that uses a glyph from the specified font. -/// -public class FontIcon : IconElement -{ - #region Static properties - - /// - /// Property for . - /// - public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register( - nameof(FontFamily), - typeof(FontFamily), - typeof(FontIcon), - new FrameworkPropertyMetadata(SystemFonts.MessageFontFamily, OnFontFamilyChanged) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontSizeProperty = TextElement - .FontSizeProperty - .AddOwner( - typeof(FontIcon), - new FrameworkPropertyMetadata( - SystemFonts.MessageFontSize, - FrameworkPropertyMetadataOptions.Inherits, - OnFontSizeChanged - ) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register( - nameof(FontStyle), - typeof(FontStyle), - typeof(FontIcon), - new FrameworkPropertyMetadata(FontStyles.Normal, OnFontStyleChanged) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register( - nameof(FontWeight), - typeof(FontWeight), - typeof(FontIcon), - new FrameworkPropertyMetadata(FontWeights.Normal, OnFontWeightChanged) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register( - nameof(Glyph), - typeof(string), - typeof(FontIcon), - new FrameworkPropertyMetadata(string.Empty, OnGlyphChanged) - ); - - #endregion - - #region Properties - - /// - [Bindable(true), Category("Appearance")] - [Localizability(LocalizationCategory.Font)] - public FontFamily FontFamily - { - get => (FontFamily)GetValue(FontFamilyProperty); - set => SetValue(FontFamilyProperty, value); - } - - /// - [TypeConverter(typeof(FontSizeConverter))] - [Bindable(true), Category("Appearance")] - [Localizability(LocalizationCategory.None)] - public double FontSize - { - get => (double)GetValue(FontSizeProperty); - set => SetValue(FontSizeProperty, value); - } - - /// - [Bindable(true), Category("Appearance")] - public FontStyle FontStyle - { - get => (FontStyle)GetValue(FontStyleProperty); - set => SetValue(FontStyleProperty, value); - } - - /// - [Bindable(true), Category("Appearance")] - public FontWeight FontWeight - { - get => (FontWeight)GetValue(FontWeightProperty); - set => SetValue(FontWeightProperty, value); - } - - /// - /// Gets or sets the character code that identifies the icon glyph. - /// - /// The hexadecimal character code for the icon glyph. - public string Glyph - { - get => (string)GetValue(GlyphProperty); - set => SetValue(GlyphProperty, value); - } - - #endregion - - protected TextBlock TextBlock; - - protected override UIElement InitializeChildren() - { - if (VisualParent is not null) - { - FontSize = TextElement.GetFontSize(VisualParent); - } - - if (FontSize.Equals(SystemFonts.MessageFontSize)) - { - SetResourceReference(FontSizeProperty, "DefaultIconFontSize"); - } - - TextBlock = new TextBlock - { - Style = null, - HorizontalAlignment = HorizontalAlignment.Stretch, - VerticalAlignment = VerticalAlignment.Center, - TextAlignment = TextAlignment.Center, - FontFamily = FontFamily, - FontSize = FontSize, - FontStyle = FontStyle, - FontWeight = FontWeight, - Text = Glyph, - Visibility = Visibility.Visible, - Focusable = false, - }; - - Focusable = false; - - return TextBlock; - } - - #region Static methods - - private static void OnFontFamilyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (FontIcon)d; - if (self.TextBlock is null) - return; - - self.TextBlock.FontFamily = (FontFamily)e.NewValue; - } - - private static void OnFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (FontIcon)d; - if (self.TextBlock is null) - return; - - self.TextBlock.FontSize = (double)e.NewValue; - } - - private static void OnFontStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (FontIcon)d; - if (self.TextBlock is null) - return; - - self.TextBlock.FontStyle = (FontStyle)e.NewValue; - } - - private static void OnFontWeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (FontIcon)d; - if (self.TextBlock is null) - return; - - self.TextBlock.FontWeight = (FontWeight)e.NewValue; - } - - private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (FontIcon)d; - if (self.TextBlock is null) - return; - - self.TextBlock.Text = (string)e.NewValue; - } - - #endregion -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconElement.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconElement.cs deleted file mode 100644 index 1173202db2c..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconElement.cs +++ /dev/null @@ -1,101 +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. - -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.ComponentModel; -// ReSharper disable once CheckNamespace -namespace System.Windows.Controls; - -/// -/// Represents the base class for an icon UI element. -/// -// [TypeConverter(typeof(IconElementConverter))] -public abstract class IconElement : FrameworkElement -{ - static IconElement() - { - FocusableProperty.OverrideMetadata(typeof(IconElement), new FrameworkPropertyMetadata(false)); - KeyboardNavigation - .IsTabStopProperty - .OverrideMetadata(typeof(IconElement), new FrameworkPropertyMetadata(false)); - } - - /// - /// Property for . - /// - public static readonly DependencyProperty ForegroundProperty = TextElement - .ForegroundProperty - .AddOwner( - typeof(IconElement), - new FrameworkPropertyMetadata( - SystemColors.ControlTextBrush, - FrameworkPropertyMetadataOptions.Inherits, - static (d, args) => ((IconElement)d).OnForegroundPropertyChanged(args) - ) - ); - - /// - [Bindable(true), Category("Appearance")] - public Brush Foreground - { - get => (Brush)GetValue(ForegroundProperty); - set => SetValue(ForegroundProperty, value); - } - - protected override int VisualChildrenCount => 1; - - private Grid _layoutRoot; - - #region Protected methods - - protected abstract UIElement InitializeChildren(); - - protected virtual void OnForegroundPropertyChanged(DependencyPropertyChangedEventArgs args) { } - - #endregion - - #region Layout methods - - private void EnsureLayoutRoot() - { - if (_layoutRoot != null) - return; - - _layoutRoot = new Grid { Background = Brushes.Transparent, SnapsToDevicePixels = true, }; - - _layoutRoot.Children.Add(InitializeChildren()); - AddVisualChild(_layoutRoot); - } - - protected override Visual GetVisualChild(int index) - { - if (index != 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - EnsureLayoutRoot(); - return _layoutRoot!; - } - - protected override Size MeasureOverride(Size availableSize) - { - EnsureLayoutRoot(); - - _layoutRoot!.Measure(availableSize); - return _layoutRoot.DesiredSize; - } - - protected override Size ArrangeOverride(Size finalSize) - { - EnsureLayoutRoot(); - - _layoutRoot!.Arrange(new Rect(new Point(), finalSize)); - return finalSize; - } - - #endregion -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElement.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElement.cs deleted file mode 100644 index eee5edcaeda..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElement.cs +++ /dev/null @@ -1,40 +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. - -using System.Windows.Markup; -// ReSharper disable once CheckNamespace -namespace System.Windows.Controls; - -/// -/// Represents an icon that uses an IconSource as its content. -/// -[ContentProperty(nameof(IconSource))] -public class IconSourceElement : IconElement -{ - /// - /// Property for . - /// - public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register( - nameof(IconSource), - typeof(IconSource), - typeof(IconSourceElement), - new FrameworkPropertyMetadata(null) - ); - - /// - /// Gets or sets - /// - public IconSource IconSource - { - get => (IconSource)GetValue(IconSourceProperty); - set => SetValue(IconSourceProperty, value); - } - - protected override UIElement InitializeChildren() - { - //TODO come up with an elegant solution - throw new InvalidOperationException($"Use {nameof(IconSourceElementConverter)} class."); - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElementConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElementConverter.cs deleted file mode 100644 index 18a5a6331c3..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/IconSourceElementConverter.cs +++ /dev/null @@ -1,68 +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. - -using System.Windows.Data; -using System.Windows.Controls; -using System.Globalization; -using System.ComponentModel; -namespace System.Windows.Controls; - -/// -/// 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); - } - - 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(); - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/ImageIcon.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/ImageIcon.cs deleted file mode 100644 index c19d7ef788c..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/ImageIcon.cs +++ /dev/null @@ -1,55 +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. - -using System.Windows.Media; -// ReSharper disable once CheckNamespace -namespace System.Windows.Controls; - -/// -/// Represents an icon that uses an as its content. -/// -public class ImageIcon : IconElement -{ - /// - /// Property for . - /// - public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( - nameof(Source), - typeof(ImageSource), - typeof(ImageIcon), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, - OnSourcePropertyChanged - ) - ); - - /// - /// Gets or sets the Source on this Image. - /// - public ImageSource Source - { - get => (ImageSource)GetValue(SourceProperty); - set => SetValue(SourceProperty, value); - } - - protected System.Windows.Controls.Image Image; - - protected override UIElement InitializeChildren() - { - Image = new System.Windows.Controls.Image() { Source = Source, Stretch = Stretch.UniformToFill }; - - return Image; - } - - private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var self = (ImageIcon)d; - if (self.Image is null) - return; - - self.Image.Source = (ImageSource)e.NewValue; - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/SymbolIcon.bmp b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/SymbolIcon.bmp deleted file mode 100644 index 4fe46c317b076b931c584ed319707350f5ecd9e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 824 zcma))ziI+O5QkS&+K5#i!6yjT_I820>Y4+EdxN`5TW#(MVxv!?No)_2JVR8_Ks-zu zTm9Gx!)Ow4*j;`z^X=~JpLVBpvemUPm)Aj05D*T^Jyh%nm)}Rg+bto1^`oD*L-_<9rXM6-VnH&`jaO+ z8V={P84aN@!tz?rdbN(CNHE05W-Hp(W6!&MUj{)ymWIF;-k#UqC)w#_0*Q?u#=5xP lr#|kL? -/// Represents an icon source that uses a glyph from the specified font. -/// -public class FontIconSource : IconSource -{ - /// - /// Property for . - /// - public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register( - nameof(FontFamily), - typeof(FontFamily), - typeof(FontIconSource), - new PropertyMetadata(SystemFonts.MessageFontFamily) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register( - nameof(FontSize), - typeof(double), - typeof(FontIconSource), - new PropertyMetadata(SystemFonts.MessageFontSize) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register( - nameof(FontStyle), - typeof(FontStyle), - typeof(FontIconSource), - new PropertyMetadata(FontStyles.Normal) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register( - nameof(FontWeight), - typeof(FontWeight), - typeof(FontIconSource), - new PropertyMetadata(FontWeights.Normal) - ); - - /// - /// Property for . - /// - public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register( - nameof(Glyph), - typeof(string), - typeof(FontIconSource), - new PropertyMetadata(string.Empty) - ); - - /// - public FontFamily FontFamily - { - get => (FontFamily)GetValue(FontFamilyProperty); - set => SetValue(FontFamilyProperty, value); - } - - /// - public double FontSize - { - get => (double)GetValue(FontSizeProperty); - set => SetValue(FontSizeProperty, value); - } - - /// - public FontWeight FontWeight - { - get => (FontWeight)GetValue(FontWeightProperty); - set => SetValue(FontWeightProperty, value); - } - - /// - public FontStyle FontStyle - { - get => (FontStyle)GetValue(FontStyleProperty); - set => SetValue(FontStyleProperty, value); - } - - /// - /// Gets or sets the character code that identifies the icon glyph. - /// - /// The hexadecimal character code for the icon glyph. - public string Glyph - { - get => (string)GetValue(GlyphProperty); - set => SetValue(GlyphProperty, value); - } - - public override IconElement CreateIconElement() - { - FontIcon fontIcon = new FontIcon() { Glyph = Glyph }; - - if (!Equals(FontFamily, SystemFonts.MessageFontFamily)) - { - fontIcon.FontFamily = FontFamily; - } - - if (!FontSize.Equals(SystemFonts.MessageFontSize)) - { - fontIcon.FontSize = FontSize; - } - - if (FontWeight != FontWeights.Normal) - { - fontIcon.FontWeight = FontWeight; - } - - if (FontStyle != FontStyles.Normal) - { - fontIcon.FontStyle = FontStyle; - } - - if (Foreground != SystemColors.ControlTextBrush) - { - fontIcon.Foreground = Foreground; - } - - return fontIcon; - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconSource/IconSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconSource/IconSource.cs deleted file mode 100644 index 786a3acd57b..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconSource/IconSource.cs +++ /dev/null @@ -1,36 +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. - -using System.Windows.Controls; -using System.Windows.Media; -// ReSharper disable once CheckNamespace -namespace System.Windows.Controls; - -/// -/// Represents the base class for an icon source. -/// -public abstract class IconSource : DependencyObject -{ - /// - /// Property for . - /// - public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register( - nameof(Foreground), - typeof(Brush), - typeof(IconSource), - new FrameworkPropertyMetadata(SystemColors.ControlTextBrush) - ); - - /// - /// - /// - public Brush Foreground - { - get => (Brush)GetValue(ForegroundProperty); - set => SetValue(ForegroundProperty, value); - } - - public abstract IconElement CreateIconElement(); -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ImageIconExtension.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ImageIconExtension.cs deleted file mode 100644 index 8fe866fb0d9..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ImageIconExtension.cs +++ /dev/null @@ -1,60 +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. - -using System.Windows.Markup; -using System.Windows.Media; - -using System.Windows.Controls; - -namespace System.Windows.Markup; - -/// -/// Custom which can provide . -/// -/// -/// -/// <ui:Button -/// Appearance="Primary" -/// Content="WPF UI button with font icon" -/// Icon="{ui:ImageIcon '/my-icon.png'}" /> -/// -/// -/// <ui:Button Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /> -/// -/// -/// <ui:HyperlinkButton Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /> -/// -/// -/// <ui:TitleBar Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /> -/// -/// -[ContentProperty(nameof(Source))] -[MarkupExtensionReturnType(typeof(ImageIcon))] -public class ImageIconExtension : MarkupExtension -{ - public ImageIconExtension(ImageSource source) - { - Source = source; - } - - [ConstructorArgument("source")] - public ImageSource Source { get; set; } - - public double Width { get; set; } = 16D; - - public double Height { get; set; } = 16D; - - public override object ProvideValue(IServiceProvider serviceProvider) - { - var imageIcon = new ImageIcon - { - Source = Source, - Width = Width, - Height = Height - }; - - return imageIcon; - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/UiElementExtensions.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/UiElementExtensions.cs deleted file mode 100644 index fe96bf0c6d0..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/UiElementExtensions.cs +++ /dev/null @@ -1,46 +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. - -namespace System.Windows.Controls; - -internal static class UiElementExtensions -{ - /// - /// Do not call it outside of NCHITTEST, NCLBUTTONUP, NCLBUTTONDOWN messages! - /// - /// if mouse is over the element. otherwise. - public static bool IsMouseOverElement(this UIElement element, IntPtr lParam) - { - // This method will be invoked very often and must be as simple as possible. - if (lParam == IntPtr.Zero) - { - return false; - } - - try - { - var mousePosScreen = new Point(Get_X_LParam(lParam), Get_Y_LParam(lParam)); - var bounds = new Rect(default(Point), element.RenderSize); - - Point mousePosRelative = element.PointFromScreen(mousePosScreen); - - return bounds.Contains(mousePosRelative); - } - catch - { - return false; - } - } - - private static int Get_X_LParam(IntPtr lParam) - { - return (short)(lParam.ToInt32() & 0xFFFF); - } - - private static int Get_Y_LParam(IntPtr lParam) - { - return (short)(lParam.ToInt32() >> 16); - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs deleted file mode 100644 index 5c5547722c4..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs +++ /dev/null @@ -1,222 +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. - -using System; -using System.Windows; -using System.Windows.Shell; -using System.Windows.Appearance; -using System.Windows.Hardware; -using System.Windows.Interop; -using System.Windows.Media; -using System.ComponentModel; -using Standard; -using Size = System.Windows.Size; -// ReSharper disable once CheckNamespace -namespace PresentationFramework.Win11.Controls -{ - /// - /// If you use to extend the UI elements to the non-client area, you can include this container - /// in the template of so that the content inside automatically fills the client area. - /// Using this container can let you get rid of various margin adaptations done in - /// Setter/Trigger of the style of when the window state changes. - /// - /// - /// - /// <Style - /// x:Key="MyWindowCustomStyle" - /// BasedOn="{StaticResource {x:Type Window}}" - /// TargetType="{x:Type controls:FluentWindow}"> - /// <Setter Property="Template" > - /// <Setter.Value> - /// <ControlTemplate TargetType="{x:Type Window}"> - /// <AdornerDecorator> - /// <controls:ClientAreaBorder - /// Background="{TemplateBinding Background}" - /// BorderBrush="{TemplateBinding BorderBrush}" - /// BorderThickness="{TemplateBinding BorderThickness}"> - /// <ContentPresenter x:Name="ContentPresenter" /> - /// </controls:ClientAreaBorder> - /// </AdornerDecorator> - /// </ControlTemplate> - /// </Setter.Value> - /// </Setter> - /// </Style> - /// - /// - public class ClientAreaBorder : System.Windows.Controls.Border - { - // private bool _borderBrushApplied = false; - - private const int SM_CXFRAME = 32; - - private const int SM_CYFRAME = 33; - - private const int SM_CXPADDEDBORDER = 92; - - private System.Windows.Window _oldWindow; - - private static Thickness? _paddedBorderThickness; - - private static Thickness? _resizeFrameBorderThickness; - - private static Thickness? _windowChromeNonClientFrameThickness; - - internal ApplicationTheme ApplicaitonTheme { get; set; } = ApplicationTheme.Unknown; - - /// - /// Get the system value in WPF units. - /// - public Thickness PaddedBorderThickness - { - get - { - if (_paddedBorderThickness is not null) - { - return _paddedBorderThickness.Value; - } - - var paddedBorder = NativeMethods.GetSystemMetrics(SM.CXPADDEDBORDER); - - (double factorX, double factorY) = GetDpi(); - - var frameSize = new Size(paddedBorder, paddedBorder); - var frameSizeInDips = new Size(frameSize.Width / factorX, frameSize.Height / factorY); - - _paddedBorderThickness = new Thickness( - frameSizeInDips.Width, - frameSizeInDips.Height, - frameSizeInDips.Width, - frameSizeInDips.Height - ); - - return _paddedBorderThickness.Value; - } - } - - /// - /// Get the system and values in WPF units. - /// - public Thickness ResizeFrameBorderThickness => - _resizeFrameBorderThickness ??= new Thickness( - SystemParameters.ResizeFrameVerticalBorderWidth, - SystemParameters.ResizeFrameHorizontalBorderHeight, - SystemParameters.ResizeFrameVerticalBorderWidth, - SystemParameters.ResizeFrameHorizontalBorderHeight - ); - - /// - /// 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, - ResizeFrameBorderThickness.Top + PaddedBorderThickness.Top, - ResizeFrameBorderThickness.Right + PaddedBorderThickness.Right, - ResizeFrameBorderThickness.Bottom + PaddedBorderThickness.Bottom - ); - - - public ClientAreaBorder() - { - ApplicaitonTheme = ApplicationTheme.Dark; - // ApplicationThemeManager.Changed += OnThemeChanged; - } - - // private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color systemAccent) - // { - // ApplicationTheme = currentApplicationTheme; - - // if (!_borderBrushApplied || _oldWindow == null) - // { - // return; - // } - - // ApplyDefaultWindowBorder(); - // } - - /// - protected internal override void OnVisualParentChanged(DependencyObject oldParent) - { - base.OnVisualParentChanged(oldParent); - - if (_oldWindow is { } oldWindow) - { - oldWindow.StateChanged -= OnWindowStateChanged; - oldWindow.Closing -= OnWindowClosing; - } - - var newWindow = (System.Windows.Window)System.Windows.Window.GetWindow(this); - - if (newWindow is not null) - { - newWindow.StateChanged -= OnWindowStateChanged; // Unsafe - newWindow.StateChanged += OnWindowStateChanged; - newWindow.Closing += OnWindowClosing; - } - - _oldWindow = newWindow; - - ApplyDefaultWindowBorder(); - } - - private void OnWindowClosing(object sender, CancelEventArgs e) - { - // ApplicationThemeManager.Changed -= OnThemeChanged; - if (_oldWindow != null) - { - _oldWindow.Closing -= OnWindowClosing; - } - } - - private void OnWindowStateChanged(object sender, EventArgs e) - { - if (sender is not System.Windows.Window window) - { - return; - } - - Padding = window.WindowState switch - { - WindowState.Maximized => WindowChromeNonClientFrameThickness, - _ => default, - }; - } - - private void ApplyDefaultWindowBorder() - { - if (Utility.IsOSWindows11OrNewer || _oldWindow == null) - { - return; - } - - // _borderBrushApplied = true; - - // SystemParameters.WindowGlassBrush - _oldWindow.BorderThickness = new Thickness(1); - _oldWindow.BorderBrush = new SolidColorBrush( - ApplicaitonTheme == ApplicationTheme.Light - ? Color.FromArgb(0xFF, 0x7A, 0x7A, 0x7A) - : Color.FromArgb(0xFF, 0x3A, 0x3A, 0x3A) - ); - } - - private (double factorX, double factorY) GetDpi() - { - if (PresentationSource.FromVisual(this) is { } source) - { - return ( - source.CompositionTarget.TransformToDevice.M11, // Possible null reference - source.CompositionTarget.TransformToDevice.M22 - ); - } - - DisplayDpi systemDPi = DpiHelper.GetSystemDpi(); - - return (systemDPi.DpiScaleX, systemDPi.DpiScaleY); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj index 1b64b60c4eb..b25ed5391e7 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/PresentationFramework.Win11.csproj @@ -22,13 +22,11 @@ MSBuild:Compile - - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml index f0c13143420..d8b4cf57eb5 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Calendar.xaml @@ -358,10 +358,10 @@ Focusable="False" Foreground="{DynamicResource CalendarViewButtonForeground}"> - + FontFamily="Segoe Fluent Icons" + > diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml index c9755b501e3..eafaa66e913 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/CheckBox.xaml @@ -77,7 +77,7 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding Border.CornerRadius}"> - + Visibility="Collapsed"> @@ -109,7 +108,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ComboBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ComboBox.xaml index 5099a1fe881..51f6b0f5450 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ComboBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ComboBox.xaml @@ -214,7 +214,7 @@ TextElement.Foreground="{TemplateBinding Foreground}" /> - - + Text ="{StaticResource ComboBoxChevronDownGlyph}"> + - - + + @@ -334,7 +334,7 @@ diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml index 3b55ce19734..977d3e9c228 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml @@ -586,7 +586,8 @@ - + Text="" /> @@ -829,7 +830,7 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding Border.CornerRadius}"> - - + - - + + @@ -861,7 +862,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DatePicker.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DatePicker.xaml index c14cb79b091..3f38091d8bd 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DatePicker.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DatePicker.xaml @@ -135,14 +135,15 @@ BorderBrush="Transparent" Cursor="Arrow"> - + Text="{StaticResource CalendarGlyph}" /> diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Expander.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Expander.xaml index ed43cddea11..7bfda3a82ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Expander.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Expander.xaml @@ -3,7 +3,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 Microsoft XAML for Win UI Copyright (c) Microsoft Corporation. All Rights Reserved. --> @@ -20,7 +20,7 @@ 16.0 - + @@ -47,12 +47,13 @@ - + Text="{StaticResource ExpanderChevronDownGlyph}" /> @@ -106,12 +107,12 @@ - + Text="{StaticResource ExpanderChevronUpGlyph}" /> @@ -165,12 +166,13 @@ - + Text="{StaticResource ExpanderChevronLeftGlyph}" /> @@ -224,12 +226,12 @@ - + Text="{StaticResource ExpanderChevronRightGlyph}" /> @@ -445,7 +447,7 @@ - + @@ -490,7 +492,7 @@ - + @@ -568,7 +570,7 @@ TargetName="ContentPresenterBorder" /> - - + Text="{StaticResource MenuItemChevronRightGlyph}" /> @@ -754,13 +754,13 @@ RecognizesAccessKey="True" /> - + Text="{StaticResource MenuItemChevronRightGlyph}" /> diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ScrollBar.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ScrollBar.xaml index 19620984f74..7f14c93f310 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ScrollBar.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ScrollBar.xaml @@ -41,14 +41,14 @@ Margin="{TemplateBinding Margin}" Background="{DynamicResource ScrollBarButtonBackground}" CornerRadius="6"> - + Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" /> diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml index 08e39cd9096..800ec8fc297 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/TextBox.xaml @@ -211,8 +211,10 @@ > - - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ToolBar.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ToolBar.xaml index 67757506f8f..c46eeb7f900 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ToolBar.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ToolBar.xaml @@ -161,12 +161,12 @@ CornerRadius="0,3,3,0" SnapsToDevicePixels="true"> - + Text="{StaticResource ToolBarChevronDownGlyph}" /> - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml deleted file mode 100644 index b944b9ea71f..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Border.xaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml index be45ed45837..2b5ece053f1 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Button.xaml @@ -17,70 +17,6 @@ 1 0,0,8,0 - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContextMenu.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContextMenu.xaml index dc81fb42b65..8d60f544e7e 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContextMenu.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ContextMenu.xaml @@ -9,7 +9,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml index 977d3e9c228..fc97f9dcf6f 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DataGrid.xaml @@ -21,11 +21,7 @@ xmlns:controls="clr-namespace:PresentationFramework.Win11.Controls" xmlns:system="clr-namespace:System;assembly=System.Runtime"> - - 14 diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml deleted file mode 100644 index e91aac42e98..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/DocumentViewer.xaml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml deleted file mode 100644 index 38aa4583a76..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Floater.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml deleted file mode 100644 index 27484c3082f..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GridSplitter.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml deleted file mode 100644 index a8f8d234457..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupBox.xaml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml deleted file mode 100644 index 8c53ac65823..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/GroupItem.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml deleted file mode 100644 index ec19c931e55..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/HeaderedContentControl.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml deleted file mode 100644 index c1fa27e643b..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Hyperlink.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml deleted file mode 100644 index c320044baf3..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/Italic.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml deleted file mode 100644 index f657f7fbebb..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ItemsControl.xaml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml deleted file mode 100644 index 6f9b23a50d2..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/List.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml deleted file mode 100644 index 9d7d88be6f9..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/NavigationWindow.xaml +++ /dev/null @@ -1,546 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -