Let's agree to the disagree. We'll map 3rd party controls to our own classes therefore having the ability to declare XML to CRL mapping. Cleaner xaml without the prefixes.
This commit is contained in:
@@ -12,64 +12,65 @@ using System.Runtime.InteropServices;
|
||||
namespace Builder;
|
||||
|
||||
[DoNotNotify]
|
||||
public partial class MainWindow : CoreWindow
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnOpened(EventArgs args)
|
||||
{
|
||||
if (AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>() is FluentAvaloniaTheme theme)
|
||||
{
|
||||
theme.RequestedThemeChanged += OnRequestedThemeChanged;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
if (IsWindows11 && theme.RequestedTheme != FluentAvaloniaTheme.HighContrastModeString)
|
||||
{
|
||||
TransparencyBackgroundFallback = Brushes.Transparent;
|
||||
TransparencyLevelHint = WindowTransparencyLevel.Mica;
|
||||
|
||||
TryEnableMicaEffect(theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnOpened(args);
|
||||
}
|
||||
|
||||
private void OnRequestedThemeChanged(FluentAvaloniaTheme sender, RequestedThemeChangedEventArgs args)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
if (IsWindows11 && args.NewTheme != FluentAvaloniaTheme.HighContrastModeString)
|
||||
{
|
||||
TryEnableMicaEffect(sender);
|
||||
}
|
||||
else if (args.NewTheme == FluentAvaloniaTheme.HighContrastModeString)
|
||||
{
|
||||
SetValue(BackgroundProperty, AvaloniaProperty.UnsetValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TryEnableMicaEffect(FluentAvaloniaTheme theme)
|
||||
{
|
||||
if (theme.RequestedTheme == FluentAvaloniaTheme.DarkModeString)
|
||||
{
|
||||
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color2)(Color)value! : new Color2(32, 32, 32);
|
||||
color = color.LightenPercent(-0.5f);
|
||||
|
||||
Background = new ImmutableSolidColorBrush(color, 0.78);
|
||||
}
|
||||
else if (theme.RequestedTheme == FluentAvaloniaTheme.LightModeString)
|
||||
{
|
||||
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color2)(Color)value! : new Color2(243, 243, 243);
|
||||
color = color.LightenPercent(0.5f);
|
||||
|
||||
Background = new ImmutableSolidColorBrush(color, 0.9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// protected override void OnOpened(EventArgs args)
|
||||
// {
|
||||
// if (AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>() is FluentAvaloniaTheme theme)
|
||||
// {
|
||||
// theme.RequestedThemeChanged += OnRequestedThemeChanged;
|
||||
|
||||
// if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
// {
|
||||
// if (IsWindows11 && theme.RequestedTheme != FluentAvaloniaTheme.HighContrastModeString)
|
||||
// {
|
||||
// TransparencyBackgroundFallback = Brushes.Transparent;
|
||||
// TransparencyLevelHint = WindowTransparencyLevel.Mica;
|
||||
|
||||
// TryEnableMicaEffect(theme);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// base.OnOpened(args);
|
||||
// }
|
||||
|
||||
// private void OnRequestedThemeChanged(FluentAvaloniaTheme sender, RequestedThemeChangedEventArgs args)
|
||||
// {
|
||||
// if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
// {
|
||||
// if (IsWindows11 && args.NewTheme != FluentAvaloniaTheme.HighContrastModeString)
|
||||
// {
|
||||
// TryEnableMicaEffect(sender);
|
||||
// }
|
||||
// else if (args.NewTheme == FluentAvaloniaTheme.HighContrastModeString)
|
||||
// {
|
||||
// SetValue(BackgroundProperty, AvaloniaProperty.UnsetValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void TryEnableMicaEffect(FluentAvaloniaTheme theme)
|
||||
// {
|
||||
// if (theme.RequestedTheme == FluentAvaloniaTheme.DarkModeString)
|
||||
// {
|
||||
// Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color2)(Color)value! : new Color2(32, 32, 32);
|
||||
// color = color.LightenPercent(-0.5f);
|
||||
|
||||
// Background = new ImmutableSolidColorBrush(color, 0.78);
|
||||
// }
|
||||
// else if (theme.RequestedTheme == FluentAvaloniaTheme.LightModeString)
|
||||
// {
|
||||
// Color2 color = this.TryFindResource("SolidBackgroundFillColorBase", out object? value) ? (Color2)(Color)value! : new Color2(243, 243, 243);
|
||||
// color = color.LightenPercent(0.5f);
|
||||
|
||||
// Background = new ImmutableSolidColorBrush(color, 0.9);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user