using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.ComponentModel; using System.Threading.Tasks; using Wpf.Ui.Controls; namespace BetterGenshinImpact.View.Windows; [ObservableObject] public partial class CheckUpdateWindow : FluentWindow { public Func? UserInteraction = null!; [ObservableProperty] private bool showUpdateStatus = false; [ObservableProperty] private string updateStatusMessage = string.Empty; public CheckUpdateWindow() { DataContext = this; InitializeComponent(); Closing += OnClosing; } protected void OnClosing(object? sender, CancelEventArgs e) { if (ShowUpdateStatus) { e.Cancel = true; } } public void NavigateToHtml(string html) { WebpagePanel?.NavigateToHtml(html); } [RelayCommand] private async Task BackgroundUpdateAsync() { if (UserInteraction != null) { await UserInteraction.Invoke(this, CheckUpdateWindowButton.BackgroundUpdate); } } [RelayCommand] private async Task OtherUpdateAsync() { if (UserInteraction != null) { await UserInteraction.Invoke(this, CheckUpdateWindowButton.OtherUpdate); } } [RelayCommand] private async Task UpdateAsync() { if (UserInteraction != null) { await UserInteraction.Invoke(this, CheckUpdateWindowButton.Update); } } [RelayCommand] private async Task IgnoreAsync() { if (UserInteraction != null) { await UserInteraction.Invoke(this, CheckUpdateWindowButton.Ignore); } } [RelayCommand] private async Task CancelAsync() { if (UserInteraction != null) { await UserInteraction.Invoke(this, CheckUpdateWindowButton.Cancel); } } public enum CheckUpdateWindowButton { BackgroundUpdate, OtherUpdate, Update, Ignore, Cancel, } }