2021-09-27 12:42:46 +00:00
|
|
|
using System;
|
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Controls.Primitives;
|
|
|
|
using Avalonia.Platform;
|
|
|
|
using Avalonia.Styling;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.App;
|
|
|
|
|
|
|
|
public class FluentWindow : Window, IStyleable
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
public FluentWindow()
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
ExtendClientAreaToDecorationsHint = true;
|
|
|
|
ExtendClientAreaTitleBarHeightHint = -1;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
this.GetObservable(WindowStateProperty)
|
|
|
|
.Subscribe(x =>
|
|
|
|
{
|
|
|
|
PseudoClasses.Set(":maximized", x == WindowState.Maximized);
|
|
|
|
PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen);
|
|
|
|
});
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
this.GetObservable(IsExtendedIntoWindowDecorationsProperty)
|
|
|
|
.Subscribe(x =>
|
|
|
|
{
|
|
|
|
if (!x)
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
SystemDecorations = SystemDecorations.Full;
|
|
|
|
TransparencyLevelHint = WindowTransparencyLevel.Blur;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
Type IStyleable.StyleKey => typeof(Window);
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnApplyTemplate(e);
|
|
|
|
ExtendClientAreaChromeHints =
|
|
|
|
ExtendClientAreaChromeHints.PreferSystemChrome |
|
|
|
|
ExtendClientAreaChromeHints.OSXThickTitleBar;
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|