diff --git a/src/Tkmm.Launcher/ViewModels/ShellViewModel.cs b/src/Tkmm.Launcher/ViewModels/ShellViewModel.cs index c37a37ad..19160f17 100644 --- a/src/Tkmm.Launcher/ViewModels/ShellViewModel.cs +++ b/src/Tkmm.Launcher/ViewModels/ShellViewModel.cs @@ -1,5 +1,7 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using Avalonia.Controls; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Windowing; using Tkmm.Core.Components; using Tkmm.Core.Helpers; @@ -40,36 +42,61 @@ public ShellViewModel(ShellView view) private async Task Primary() { if (PrimaryText is INSTALL or UPDATE) { - if (OperatingSystem.IsWindows()) { - _view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Indeterminate); - + try { + await Install(); } - - await Task.Run(async () => { - Progress = 10; - await AppManager.Update((progress) => Progress = progress); - await AssetHelper.Download(); - Progress = 98; - }); - - if (InstallShortcuts) { - AppManager.CreateDesktopShortcuts(); + catch (Exception ex) { + ContentDialog dialog = new() { + Title = ex.GetType().Name, + Content = ex.Message, + PrimaryButtonCommand = new RelayCommand(async () => { + await (_view.Clipboard?.SetTextAsync($""" + ``` + {ex} + ``` + """) ?? Task.CompletedTask); + }), + PrimaryButtonText = "Copy", + SecondaryButtonText = "Dismiss", + DefaultButton = ContentDialogButton.Primary + }; + + await dialog.ShowAsync(); } + } + else { + AppManager.Start(); + } + } - AppManager.CreateProtocol(); + private async Task Install() + { + if (OperatingSystem.IsWindows()) { + _view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Indeterminate); - Progress = 100; + } - if (OperatingSystem.IsWindows()) { - _view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Normal); - _view.PlatformFeatures.SetTaskBarProgressBarValue(0, 0); - } + await Task.Run(async () => { + Progress = 10; + await AppManager.Update((progress) => Progress = progress); + await AssetHelper.Download(); + Progress = 98; + }); - PrimaryText = LAUNCH; + if (InstallShortcuts) { + AppManager.CreateDesktopShortcuts(); } - else { - AppManager.Start(); + + AppManager.CreateProtocol(); + + Progress = 100; + + if (OperatingSystem.IsWindows()) { + _view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Normal); + _view.PlatformFeatures.SetTaskBarProgressBarValue(0, 0); } + + PrimaryText = LAUNCH; } [RelayCommand] diff --git a/src/Tkmm/Views/Pages/HomePageView.axaml b/src/Tkmm/Views/Pages/HomePageView.axaml index d554f408..01aee008 100644 --- a/src/Tkmm/Views/Pages/HomePageView.axaml +++ b/src/Tkmm/Views/Pages/HomePageView.axaml @@ -264,7 +264,7 @@ VerticalAlignment="Stretch" Command="{Binding RemoveCommand}" ToolTip.Tip="Remove Mod"> - +