mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2025-12-06 10:10:48 +01:00
Add Mica theme for Windows 11 and newer
This commit is contained in:
@@ -36,7 +36,11 @@ class Program
|
|||||||
return AppBuilder.Configure(() => new App(BuildServices()))
|
return AppBuilder.Configure(() => new App(BuildServices()))
|
||||||
.UsePlatformDetect()
|
.UsePlatformDetect()
|
||||||
.WithInterFont()
|
.WithInterFont()
|
||||||
.LogToTrace();
|
.LogToTrace()
|
||||||
|
.With(new Win32PlatformOptions
|
||||||
|
{
|
||||||
|
CompositionMode = [ Win32CompositionMode.WinUIComposition, Win32CompositionMode.DirectComposition ]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IServiceProvider BuildServices()
|
private static IServiceProvider BuildServices()
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Avalonia.Controls;
|
||||||
using FluentAvalonia.UI.Windowing;
|
using FluentAvalonia.UI.Windowing;
|
||||||
|
|
||||||
namespace Needlework.Net.Views.MainWindow;
|
namespace Needlework.Net.Views.MainWindow;
|
||||||
@@ -9,5 +12,19 @@ public partial class MainWindowView : AppWindow
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
TitleBar.ExtendsContentIntoTitleBar = true;
|
TitleBar.ExtendsContentIntoTitleBar = true;
|
||||||
|
TransparencyLevelHint = [WindowTransparencyLevel.Mica, WindowTransparencyLevel.None];
|
||||||
|
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
if (IsWindows11OrNewer())
|
||||||
|
{
|
||||||
|
Background = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsWindows11OrNewer()
|
||||||
|
{
|
||||||
|
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 22000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,27 @@
|
|||||||
<ui:TabView TabItems="{Binding Endpoints}"
|
<ui:TabView TabItems="{Binding Endpoints}"
|
||||||
AddTabButtonCommand="{Binding AddEndpointCommand}"
|
AddTabButtonCommand="{Binding AddEndpointCommand}"
|
||||||
TabCloseRequested="TabView_TabCloseRequested">
|
TabCloseRequested="TabView_TabCloseRequested">
|
||||||
|
<!--Need to override Tab header for Mica theme...-->
|
||||||
|
<ui:TabView.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{DynamicResource ControlFillColorTransparent}"/>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ui:TabView.Resources>
|
||||||
|
<!--We need to hack this style for Mica theme since there is no way to explicity set style priority in Avalonia...-->
|
||||||
|
<ui:TabView.Styles>
|
||||||
|
<Style Selector="Grid > ContentPresenter#TabContentPresenter">
|
||||||
|
<Style.Animations>
|
||||||
|
<Animation IterationCount="1" Duration="0:0:1" FillMode="Both">
|
||||||
|
<KeyFrame Cue="0%">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource ControlFillColorTransparent}"/>
|
||||||
|
</KeyFrame>
|
||||||
|
<KeyFrame Cue="100%">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource ControlFillColorTransparent}"/>
|
||||||
|
</KeyFrame>
|
||||||
|
</Animation>
|
||||||
|
</Style.Animations>
|
||||||
|
</Style>
|
||||||
|
</ui:TabView.Styles>
|
||||||
<ui:TabView.TabItemTemplate>
|
<ui:TabView.TabItemTemplate>
|
||||||
<DataTemplate DataType="vm:EndpointItem">
|
<DataTemplate DataType="vm:EndpointItem">
|
||||||
<ui:TabViewItem Header="{Binding Header}"
|
<ui:TabViewItem Header="{Binding Header}"
|
||||||
|
|||||||
Reference in New Issue
Block a user