[PTRun]Update the code for .NET 9.0.1 - remove workarounds (#36909)
* Revove some unneeded changes after pdating to .net9.1
This commit is contained in:
Родитель
41803cc632
Коммит
e7abd34778
|
@ -8,6 +8,7 @@
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/Styles/Styles.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Styles/Styles.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation
|
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
||||||
// See the LICENSE file in the project root for more information.
|
|
||||||
|
|
||||||
// https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Controls/AnimationFactorToValueConverter.cs
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace Fluent.Controls
|
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
|
||||||
internal sealed class AnimationFactorToValueConverter : IMultiValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (values[0] is not double completeValue)
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values[1] is not double factor)
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameter is "negative")
|
|
||||||
{
|
|
||||||
factor = -factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return factor * completeValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation
|
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
||||||
// See the LICENSE file in the project root for more information.
|
|
||||||
|
|
||||||
// Copied from https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Controls/FallbackBrushConverter.cs
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
#pragma warning disable IDE0130 // Namespace does not match folder structure
|
|
||||||
namespace Fluent.Controls
|
|
||||||
#pragma warning restore IDE0130 // Namespace does not match folder structure
|
|
||||||
{
|
|
||||||
internal sealed class FallbackBrushConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (value is SolidColorBrush brush)
|
|
||||||
{
|
|
||||||
return brush;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value is Color color)
|
|
||||||
{
|
|
||||||
return new SolidColorBrush(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We draw red to visibly see an invalid bind in the UI.
|
|
||||||
return Brushes.Red;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -36,37 +36,20 @@ namespace PowerLauncher.Helper
|
||||||
{
|
{
|
||||||
if (e.Category == UserPreferenceCategory.General)
|
if (e.Category == UserPreferenceCategory.General)
|
||||||
{
|
{
|
||||||
// When switching from high contrast to dark mode we have to use UserPreferenceCategory.General otherwise it will crash when loading fluent.xaml
|
|
||||||
UpdateTheme();
|
UpdateTheme();
|
||||||
}
|
}
|
||||||
else if (e.Category == UserPreferenceCategory.Color)
|
|
||||||
{
|
|
||||||
// https://github.com/dotnet/wpf/issues/10043 When switching to high contrast we have to use UserPreferenceCategory.Color or it will crash due to fluent.xaml being already loaded.
|
|
||||||
if (_currentTheme is ManagedCommon.Theme.Dark or ManagedCommon.Theme.Light)
|
|
||||||
{
|
|
||||||
UpdateTheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSystemTheme(ManagedCommon.Theme theme)
|
private void SetSystemTheme(ManagedCommon.Theme theme)
|
||||||
{
|
{
|
||||||
_mainWindow.Background = OSVersionHelper.IsWindows11() is false ? SystemColors.WindowBrush : null;
|
_mainWindow.Background = OSVersionHelper.IsWindows11() is false ? SystemColors.WindowBrush : null;
|
||||||
|
|
||||||
_mainWindow.Resources.MergedDictionaries.Clear();
|
// Need to disable WPF0001 since setting Application.Current.ThemeMode is experimental
|
||||||
_mainWindow.Resources.MergedDictionaries.Add(new ResourceDictionary
|
// https://learn.microsoft.com/en-us/dotnet/desktop/wpf/whats-new/net90#set-in-code
|
||||||
{
|
#pragma warning disable WPF0001
|
||||||
Source = new Uri("Styles/Styles.xaml", UriKind.Relative),
|
Application.Current.ThemeMode = theme is ManagedCommon.Theme.Light ? ThemeMode.Light : ThemeMode.Dark;
|
||||||
});
|
|
||||||
if (theme is ManagedCommon.Theme.Dark or ManagedCommon.Theme.Light)
|
if (theme is ManagedCommon.Theme.Dark or ManagedCommon.Theme.Light)
|
||||||
{
|
{
|
||||||
string themeString = theme == ManagedCommon.Theme.Light ? "pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.Light.xaml"
|
|
||||||
: "pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.Dark.xaml";
|
|
||||||
ResourceDictionary fluentThemeDictionary = new()
|
|
||||||
{
|
|
||||||
Source = new Uri(themeString, UriKind.Absolute),
|
|
||||||
};
|
|
||||||
_mainWindow.Resources.MergedDictionaries.Add(fluentThemeDictionary);
|
|
||||||
if (!OSVersionHelper.IsWindows11())
|
if (!OSVersionHelper.IsWindows11())
|
||||||
{
|
{
|
||||||
// Apply background only on Windows 10
|
// Apply background only on Windows 10
|
||||||
|
@ -79,10 +62,6 @@ namespace PowerLauncher.Helper
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_mainWindow.Resources.MergedDictionaries.Add(new ResourceDictionary
|
|
||||||
{
|
|
||||||
Source = new Uri("Styles/FluentHC.xaml", UriKind.Relative),
|
|
||||||
});
|
|
||||||
string styleThemeString = theme switch
|
string styleThemeString = theme switch
|
||||||
{
|
{
|
||||||
ManagedCommon.Theme.Light => "Themes/Light.xaml",
|
ManagedCommon.Theme.Light => "Themes/Light.xaml",
|
||||||
|
@ -92,10 +71,15 @@ namespace PowerLauncher.Helper
|
||||||
ManagedCommon.Theme.HighContrastWhite => "Themes/HighContrastWhite.xaml",
|
ManagedCommon.Theme.HighContrastWhite => "Themes/HighContrastWhite.xaml",
|
||||||
_ => "Themes/HighContrastBlack.xaml",
|
_ => "Themes/HighContrastBlack.xaml",
|
||||||
};
|
};
|
||||||
|
_mainWindow.Resources.MergedDictionaries.Clear();
|
||||||
_mainWindow.Resources.MergedDictionaries.Add(new ResourceDictionary
|
_mainWindow.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(styleThemeString, UriKind.Relative),
|
Source = new Uri(styleThemeString, UriKind.Relative),
|
||||||
});
|
});
|
||||||
|
ResourceDictionary test = new ResourceDictionary
|
||||||
|
{
|
||||||
|
Source = new Uri(styleThemeString, UriKind.Relative),
|
||||||
|
};
|
||||||
if (OSVersionHelper.IsWindows11())
|
if (OSVersionHelper.IsWindows11())
|
||||||
{
|
{
|
||||||
// Apply background only on Windows 11 to keep the same style as WPFUI
|
// Apply background only on Windows 11 to keep the same style as WPFUI
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -2,98 +2,7 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:core="clr-namespace:System;assembly=mscorlib">
|
xmlns:core="clr-namespace:System;assembly=mscorlib">
|
||||||
<Style
|
<core:Double x:Key="TitleFontSize">16</core:Double>
|
||||||
x:Key="CaptionTextBlockStyle"
|
|
||||||
BasedOn="{StaticResource {x:Type TextBlock}}"
|
|
||||||
TargetType="{x:Type TextBlock}">
|
|
||||||
<Setter Property="FontSize" Value="12" />
|
|
||||||
<Setter Property="LineHeight" Value="16" />
|
|
||||||
<Setter Property="FontWeight" Value="Regular" />
|
|
||||||
</Style>
|
|
||||||
<Style x:Key="DefaultTextBoxStyle" TargetType="{x:Type TextBox}">
|
|
||||||
<!-- Universal WPF UI focus -->
|
|
||||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
|
||||||
<!-- Universal WPF UI focus -->
|
|
||||||
<!-- Universal WPF UI ContextMenu -->
|
|
||||||
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
|
|
||||||
<!-- Universal WPF UI ContextMenu -->
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
|
|
||||||
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
|
|
||||||
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
|
|
||||||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
|
|
||||||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
|
||||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
|
||||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
|
|
||||||
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
|
||||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
||||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
|
||||||
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
|
|
||||||
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
|
|
||||||
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
|
||||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
|
||||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
|
||||||
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
|
||||||
<Border
|
|
||||||
x:Name="ContentBorder"
|
|
||||||
MinWidth="{TemplateBinding MinWidth}"
|
|
||||||
MinHeight="{TemplateBinding MinHeight}"
|
|
||||||
Padding="0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Background="{TemplateBinding Background}"
|
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
|
||||||
CornerRadius="{TemplateBinding Border.CornerRadius}">
|
|
||||||
<Grid
|
|
||||||
Margin="{TemplateBinding Padding}"
|
|
||||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
||||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
|
||||||
</Border>
|
|
||||||
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
|
|
||||||
<Border
|
|
||||||
x:Name="AccentBorder"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
|
||||||
BorderThickness="{StaticResource TextBoxAccentBorderThemeThickness}"
|
|
||||||
CornerRadius="{TemplateBinding Border.CornerRadius}" />
|
|
||||||
</Grid>
|
|
||||||
<ControlTemplate.Triggers>
|
|
||||||
<Trigger Property="IsFocused" Value="True">
|
|
||||||
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
|
|
||||||
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
|
|
||||||
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
|
|
||||||
</Trigger>
|
|
||||||
<MultiTrigger>
|
|
||||||
<MultiTrigger.Conditions>
|
|
||||||
<Condition Property="IsEnabled" Value="True" />
|
|
||||||
<Condition Property="IsMouseOver" Value="True" />
|
|
||||||
<Condition Property="IsFocused" Value="False" />
|
|
||||||
</MultiTrigger.Conditions>
|
|
||||||
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
|
|
||||||
</MultiTrigger>
|
|
||||||
<Trigger Property="IsEnabled" Value="True">
|
|
||||||
<Setter Property="Cursor" Value="IBeam" />
|
|
||||||
</Trigger>
|
|
||||||
<Trigger Property="IsEnabled" Value="False">
|
|
||||||
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
|
|
||||||
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
||||||
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
||||||
</Trigger>
|
|
||||||
</ControlTemplate.Triggers>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
<Style x:Key="PluginsListViewItemStyle" TargetType="{x:Type ListViewItem}">
|
<Style x:Key="PluginsListViewItemStyle" TargetType="{x:Type ListViewItem}">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource ListViewItemForeground}" />
|
<Setter Property="Foreground" Value="{DynamicResource ListViewItemForeground}" />
|
||||||
<Setter Property="Background" Value="Transparent" />
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
|
Загрузка…
Ссылка в новой задаче