1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-28 08:40:09 +00:00
msfs-popout-panel-manager/MainApp/ViewModel/HelpViewModel.cs

97 lines
3.5 KiB
C#
Raw Normal View History

2023-07-12 22:41:31 +00:00
using MaterialDesignThemes.Wpf;
2024-02-28 02:44:21 +00:00
using MSFSPopoutPanelManager.MainApp.AppUserControl.Dialog;
2023-07-12 22:41:31 +00:00
using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.WindowsAgent;
using Prism.Commands;
using System;
using System.Windows.Input;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
public class HelpViewModel : BaseViewModel
{
2024-02-28 02:44:21 +00:00
private readonly HelpOrchestrator _helpOrchestrator;
2023-07-12 22:41:31 +00:00
public DelegateCommand<string> HyperLinkCommand { get; private set; }
public ICommand DeleteAppCacheCommand { get; private set; }
public ICommand RollBackCommand { get; private set; }
public string ApplicationVersion { get; private set; }
public bool IsRollBackCommandVisible { get; private set; }
public bool HasOrphanAppCache { get; private set; }
2024-02-28 02:44:21 +00:00
public HelpViewModel(SharedStorage sharedStorage, HelpOrchestrator helpOrchestrator) : base(sharedStorage)
2023-07-12 22:41:31 +00:00
{
2024-02-28 02:44:21 +00:00
_helpOrchestrator = helpOrchestrator;
2023-07-12 22:41:31 +00:00
HyperLinkCommand = new DelegateCommand<string>(OnHyperLinkActivated);
DeleteAppCacheCommand = new DelegateCommand(OnDeleteAppCache);
RollBackCommand = new DelegateCommand(OnRollBack);
2023-07-30 21:30:47 +00:00
#if DEBUG
2024-02-28 02:44:21 +00:00
var buildConfig = " (Debug)";
2023-07-30 21:30:47 +00:00
#elif LOCAL
2024-02-28 02:44:21 +00:00
var buildConfig = " (Local)";
#else
var buildConfig = string.Empty;
2023-07-30 21:30:47 +00:00
#endif
ApplicationVersion = $"{WindowProcessManager.GetApplicationVersion()}{buildConfig}";
2023-07-12 22:41:31 +00:00
2024-02-28 02:44:21 +00:00
IsRollBackCommandVisible = _helpOrchestrator.IsRollBackUpdateEnabled();
HasOrphanAppCache = _helpOrchestrator.HasOrphanAppCache();
2023-07-12 22:41:31 +00:00
}
private void OnHyperLinkActivated(string commandParameter)
{
switch (commandParameter)
{
case "Getting Started":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenGettingStarted();
2023-07-12 22:41:31 +00:00
break;
case "User Guide":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenUserGuide();
2023-07-12 22:41:31 +00:00
break;
case "Download Latest GitHub":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenLatestDownloadGitHub();
2023-07-12 22:41:31 +00:00
break;
case "Download Latest FlightsimTo":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenLatestDownloadFligthsimTo();
2023-07-12 22:41:31 +00:00
break;
case "License":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenLicense();
2023-07-12 22:41:31 +00:00
break;
case "Version Info":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenVersionInfo();
2023-07-12 22:41:31 +00:00
break;
case "Open Data Folder":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.OpenDataFolder();
2023-07-12 22:41:31 +00:00
break;
case "Download VCC Library":
2024-02-28 02:44:21 +00:00
_helpOrchestrator.DownloadVccLibrary();
2023-07-12 22:41:31 +00:00
break;
}
}
private void OnDeleteAppCache()
{
2024-02-28 02:44:21 +00:00
_helpOrchestrator.DeleteAppCache();
HasOrphanAppCache = _helpOrchestrator.HasOrphanAppCache();
2023-07-12 22:41:31 +00:00
}
private async void OnRollBack()
{
var result = await DialogHost.Show(new ConfirmationDialog($"WARNING!{Environment.NewLine}Are you sure you want to rollback to previous version of Pop Out Panel Manager (v3.4.6.0321)? All your changes since updated to v4.0.0 will be lost. Backups of user profile and application settings file from previous version of the application will be restored.", "Rollback"), "RootDialog");
if (result != null && result.Equals("CONFIRM"))
{
2024-02-28 02:44:21 +00:00
_helpOrchestrator.RollBackUpdate();
2023-07-12 22:41:31 +00:00
}
}
}
}