Files
better-genshin-impact/BetterGenshinImpact/View/MainWindow.xaml.cs
ema 50922a2a0a confirm the default backdrop type
1. The acrylic not recommended as default.
2. Mica first than Tabbed.
2023-11-30 10:07:57 +08:00

69 lines
1.9 KiB
C#

using BetterGenshinImpact.Helpers.DpiAwareness;
using BetterGenshinImpact.ViewModel;
using System;
using System.Windows.Media;
using Wpf.Ui;
using Wpf.Ui.Controls;
namespace BetterGenshinImpact.View;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : FluentWindow, INavigationWindow
{
public MainWindowViewModel ViewModel { get; }
public MainWindow(MainWindowViewModel viewModel, IPageService pageService, INavigationService navigationService)
{
DataContext = ViewModel = viewModel;
InitializeComponent();
this.InitializeDpiAwareness();
SetPageService(pageService);
navigationService.SetNavigationControl(RootNavigation);
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
TryApplySystemBackdrop();
}
public INavigationView GetNavigation() => RootNavigation;
public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType);
public void SetServiceProvider(IServiceProvider serviceProvider)
{
throw new NotImplementedException();
}
public void SetPageService(IPageService pageService)
{
RootNavigation.SetPageService(pageService);
}
public void ShowWindow() => Show();
public void CloseWindow() => Close();
private void TryApplySystemBackdrop()
{
if (WindowBackdrop.IsSupported(WindowBackdropType.Mica))
{
Background = new SolidColorBrush(Colors.Transparent);
WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Mica);
return;
}
if (WindowBackdrop.IsSupported(WindowBackdropType.Tabbed))
{
Background = new SolidColorBrush(Colors.Transparent);
WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Tabbed);
return;
}
}
}