From dc3cccb392c08db025e006f857c9ae9d33bc1ae9 Mon Sep 17 00:00:00 2001 From: Pankaj Chaurasia Date: Wed, 20 Dec 2023 01:15:51 +0530 Subject: [PATCH] Moving types from public to internal + bug fix for Window caption --- .../PresentationFramework-ref.baseline.txt | 8 +- .../System.Windows.Appearence.cs | 108 ------------------ .../PresentationFramework.csproj | 3 - .../Appearance/ApplicationThemeManager.cs | 2 + .../Windows/Appearance/SystemThemeManager.cs | 2 +- .../Windows/Appearance/SystemThemeWatcher.cs | 2 +- .../Windows/Appearance/WindowBackdrop.cs | 3 +- .../Appearance/WindowBackgroundManager.cs | 2 +- .../Windows/Extensions/ColorExtensions.cs | 2 +- .../System/Windows/Hardware/RenderingTier.cs | 33 ------ .../System/Windows/IThemeControl.cs | 19 --- .../Controls/ClientAreaBorder.cs | 4 +- 12 files changed, 11 insertions(+), 177 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/System.Windows.Appearence.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Hardware/RenderingTier.cs delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/IThemeControl.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 8b4d9bf0218..8899fe52375 100644 --- a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt +++ b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt @@ -33,7 +33,6 @@ CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'S CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.FrameworkTemplate.Resources' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. MembersMustExist : Member 'internal void System.Windows.FrameworkTemplate.SetTargetTypeInternal(System.Type)' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.HorizontalAlignment' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation. -TypesMustExist : Type 'System.Windows.IThemeControl' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.MultiDataTrigger.Conditions' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.MultiDataTrigger.Setters' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.MultiTrigger.Conditions' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation. @@ -77,10 +76,7 @@ TypesMustExist : Type 'System.Windows.Appearance.ApplicationAccentColorManager' TypesMustExist : Type 'System.Windows.Appearance.ApplicationTheme' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Appearance.ApplicationThemeManager' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Appearance.SystemTheme' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'System.Windows.Appearance.SystemThemeManager' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'System.Windows.Appearance.SystemThemeWatcher' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Appearance.ThemeChangedEvent' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'System.Windows.Appearance.WindowBackgroundManager' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'internal System.Collections.Generic.List System.Windows.Automation.Peers.ContentTextAutomationPeer.GetAutomationPeersFromRange(System.Windows.Documents.ITextPointer, System.Windows.Documents.ITextPointer)' does not exist in the implementation but it does exist in the contract. MembersMustExist : Member 'internal System.Collections.Generic.List System.Windows.Automation.Peers.TextAutomationPeer.GetAutomationPeersFromRange(System.Windows.Documents.ITextPointer, System.Windows.Documents.ITextPointer)' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.AccessText.FontFamily' changed from '[LocalizabilityAttribute(14, Modifiability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Font, Modifiability=Modifiability.Unmodifiable)]' in the implementation. @@ -304,9 +300,7 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Documents.TextElement.FontFamily' changed from '[LocalizabilityAttribute(14, Modifiability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Font, Modifiability=Modifiability.Unmodifiable)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Documents.TextElement.FontSize' changed from '[LocalizabilityAttribute(0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None)]' in the implementation. CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'System.Windows.Documents.TextElementEditingBehaviorAttribute' changed from '[AttributeUsageAttribute(4)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class)]' in the implementation. -TypesMustExist : Type 'System.Windows.Extensions.ColorExtensions' does not exist in the implementation but it does exist in the contract. TypesMustExist : Type 'System.Windows.Hardware.DisplayDpi' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'System.Windows.Hardware.RenderingTier' does not exist in the implementation but it does exist in the contract. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DependencyProperty System.Windows.Input.KeyboardNavigation.ControlTabNavigationProperty' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DependencyProperty System.Windows.Input.KeyboardNavigation.DirectionalNavigationProperty' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DependencyProperty System.Windows.Input.KeyboardNavigation.TabNavigationProperty' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation. @@ -324,4 +318,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: 325 +Total Issues: 319 diff --git a/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/System.Windows.Appearence.cs b/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/System.Windows.Appearence.cs deleted file mode 100644 index afa212ba164..00000000000 --- a/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/System.Windows.Appearence.cs +++ /dev/null @@ -1,108 +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. -// ------------------------------------------------------------------------------ -// Changes to this file must follow the http://aka.ms/api-review process. -// ------------------------------------------------------------------------------ - -namespace System.Windows.Appearance -{ - - public static class ApplicationAccentColorManager - { - } - - - public static class ApplicationThemeManager - { - - } - - public enum ApplicationTheme - { - /// - /// Unknown application theme. - /// - Unknown, - - /// - /// Dark application theme. - /// - Dark, - - /// - /// Light application theme. - /// - Light, - - /// - /// High contract application theme. - /// - HighContrast - } - - - public enum SystemTheme - { - /// - /// Unknown Windows theme. - /// - Unknown, - - /// - /// Custom Windows theme. - /// - Custom, - - /// - /// Default light theme. - /// - Light, - - /// - /// Default dark theme. - /// - Dark, - - /// - /// High-contrast theme: Desert - /// - HCWhite, - - /// - /// High-contrast theme: Acquatic - /// - HCBlack, - - /// - /// High-contrast theme: Dusk - /// - HC1, - - /// - /// High-contrast theme: Nightsky - /// - HC2, - - /// - /// Dark theme: Glow - /// - Glow, - - /// - /// Dark theme: Captured Motion - /// - CapturedMotion, - - /// - /// Light theme: Sunrise - /// - Sunrise, - - /// - /// Light theme: Flow - /// - Flow - - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index 0e17f5e41a2..54ef130f981 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -417,10 +417,7 @@ - - - diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ApplicationThemeManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ApplicationThemeManager.cs index d72b78374c6..61da81f2585 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ApplicationThemeManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ApplicationThemeManager.cs @@ -151,6 +151,8 @@ public static void Apply( Changed?.Invoke(applicationTheme, ApplicationAccentColorManager.SystemAccent); + // TODO - Why this check for MW only and not for all windows? + if (Application.Current.MainWindow is Window mainWindow) { WindowBackgroundManager.UpdateBackground( diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeManager.cs index babcddeb4f9..90143698ec5 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeManager.cs @@ -20,7 +20,7 @@ namespace System.Windows.Appearance; /// var currentWindowTheme = SystemThemeManager.GetCachedSystemTheme(); /// /// -public static class SystemThemeManager +internal static class SystemThemeManager { private static SystemTheme _cachedTheme = SystemTheme.Unknown; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeWatcher.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeWatcher.cs index 5b297e46be6..c3cf850e0ec 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeWatcher.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/SystemThemeWatcher.cs @@ -26,7 +26,7 @@ namespace System.Windows.Appearance; /// ); /// /// -public static class SystemThemeWatcher +internal static class SystemThemeWatcher { private static readonly ICollection _observedWindows = new List(); 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 29e98f183a9..eb962ac0f1c 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 @@ -100,7 +100,8 @@ public static bool ApplyBackdrop(IntPtr hWnd, WindowBackdropType backdropType) _ = UnsafeNativeMethodsWindow.RemoveWindowDarkMode(hWnd); } - _ = UnsafeNativeMethodsWindow.RemoveWindowCaption(hWnd); + // BUG - This is causing TitleBar caption to be removed for normal windows + //_ = UnsafeNativeMethodsWindow.RemoveWindowCaption(hWnd); // 22H1 if (!Utility.IsOSWindows11Insider1OrNewer) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackgroundManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackgroundManager.cs index 05e1c4eb8e9..c3cfd1c64c5 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackgroundManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/WindowBackgroundManager.cs @@ -21,7 +21,7 @@ namespace System.Windows.Appearance; /// ); /// /// -public static class WindowBackgroundManager +internal static class WindowBackgroundManager { /// /// Tries to apply dark theme to . diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Extensions/ColorExtensions.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Extensions/ColorExtensions.cs index f32dc583aaf..b27cfd1e382 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Extensions/ColorExtensions.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Extensions/ColorExtensions.cs @@ -9,7 +9,7 @@ namespace System.Windows.Extensions; /// /// Adds an extension for that allows manipulation with HSL and HSV color spaces. /// -public static class ColorExtensions +internal static class ColorExtensions { /// /// Maximum size with the current precision. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Hardware/RenderingTier.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Hardware/RenderingTier.cs deleted file mode 100644 index e9bc74695cf..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Hardware/RenderingTier.cs +++ /dev/null @@ -1,33 +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.Hardware; - -/// -/// An value whose high-order word corresponds to the rendering tier for the current thread. -/// Starting in the .NET Framework 4, rendering tier 1 has been redefined to only include graphics hardware that supports DirectX 9.0 or greater. Graphics hardware that supports DirectX 7 or 8 is now defined as rendering tier 0. -/// -public enum RenderingTier -{ - /// - /// No graphics hardware acceleration is available for the application on the device. - /// All graphics features use software acceleration. The DirectX version level is less than version 9.0. - /// - NoAcceleration = 0x0, - - /// - /// Most of the graphics features of WPF will use hardware acceleration - /// if the necessary system resources are available and have not been exhausted. - /// This corresponds to a DirectX version that is greater than or equal to 9.0. - /// - PartialAcceleration = 0x1, - - /// - /// Most of the graphics features of WPF will use hardware acceleration provided the - /// necessary system resources have not been exhausted. - /// This corresponds to a DirectX version that is greater than or equal to 9.0. - /// - FullAcceleration = 0x2 -} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/IThemeControl.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/IThemeControl.cs deleted file mode 100644 index 1efbbc53999..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/IThemeControl.cs +++ /dev/null @@ -1,19 +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.Appearance; - -namespace System.Windows; - -/// -/// Control changing its properties or appearance depending on the theme. -/// -public interface IThemeControl -{ - /// - /// The theme is currently set. - /// - public ApplicationTheme ApplicationTheme { get; } -} 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 index 9eb174cb43a..a068167838f 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Controls/ClientAreaBorder.cs @@ -45,7 +45,7 @@ namespace PresentationFramework.Win11.Controls /// </Style> /// /// - public class ClientAreaBorder : System.Windows.Controls.Border, IThemeControl + public class ClientAreaBorder : System.Windows.Controls.Border { private bool _borderBrushApplied = false; @@ -63,7 +63,7 @@ public class ClientAreaBorder : System.Windows.Controls.Border, IThemeControl private static Thickness? _windowChromeNonClientFrameThickness; - public ApplicationTheme ApplicationTheme { get; set; } = ApplicationTheme.Unknown; + private ApplicationTheme ApplicationTheme { get; set; } = ApplicationTheme.Unknown; /// /// Get the system value in WPF units.