2023-07-12 22:41:31 +00:00
|
|
|
|
using AutoUpdaterDotNET;
|
|
|
|
|
using MSFSPopoutPanelManager.Shared;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace MSFSPopoutPanelManager.Orchestration
|
|
|
|
|
{
|
|
|
|
|
public class HelpOrchestrator : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
public void OpenGettingStarted()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://github.com/hawkeye-stan/msfs-popout-panel-manager/blob/master/GETTING_STARTED.md") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenUserGuide()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://github.com/hawkeye-stan/msfs-popout-panel-manager#msfs-pop-out-panel-manager") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenLatestDownloadGitHub()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://github.com/hawkeye-stan/msfs-popout-panel-manager/releases") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenLatestDownloadFligthsimTo()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://flightsim.to/file/35759/msfs-pop-out-panel-manager") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenLicense()
|
|
|
|
|
{
|
|
|
|
|
Process.Start("notepad.exe", "LICENSE");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenVersionInfo()
|
|
|
|
|
{
|
|
|
|
|
Process.Start("notepad.exe", "VERSION.md");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasOrphanAppCache()
|
|
|
|
|
{
|
2024-02-28 02:44:21 +00:00
|
|
|
|
var appLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
|
|
|
var srcPath = Path.Combine(appLocal, @"temp\.net\MSFSPopoutPanelManager");
|
2023-07-12 22:41:31 +00:00
|
|
|
|
|
2024-02-28 02:44:21 +00:00
|
|
|
|
var di = new DirectoryInfo(srcPath);
|
2023-07-12 22:41:31 +00:00
|
|
|
|
|
|
|
|
|
if (di.Exists)
|
|
|
|
|
return di.GetDirectories().Length > 1;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 02:44:21 +00:00
|
|
|
|
public void DownloadVccLibrary()
|
2023-07-12 22:41:31 +00:00
|
|
|
|
{
|
2024-02-28 02:44:21 +00:00
|
|
|
|
var target = "https://aka.ms/vs/17/release/vc_redist.x64.exe";
|
2023-07-12 22:41:31 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-02-28 02:44:21 +00:00
|
|
|
|
var psi = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
FileName = target
|
|
|
|
|
};
|
2023-07-12 22:41:31 +00:00
|
|
|
|
|
|
|
|
|
Process.Start(psi);
|
|
|
|
|
}
|
2024-02-28 02:44:21 +00:00
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// ignored
|
|
|
|
|
}
|
2023-07-12 22:41:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DeleteAppCache()
|
|
|
|
|
{
|
2024-02-28 02:44:21 +00:00
|
|
|
|
var appLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
|
|
|
var srcPath = Path.Combine(appLocal, @"temp\.net\MSFSPopoutPanelManager");
|
2023-07-12 22:41:31 +00:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var currentAppPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location);
|
|
|
|
|
|
2024-02-28 02:44:21 +00:00
|
|
|
|
if (currentAppPath == null)
|
|
|
|
|
throw new ApplicationException("Unable to determine POPM application path.");
|
|
|
|
|
|
2023-07-12 22:41:31 +00:00
|
|
|
|
var dir = new DirectoryInfo(srcPath);
|
|
|
|
|
var subDirs = dir.GetDirectories();
|
|
|
|
|
|
|
|
|
|
foreach (var subDir in subDirs)
|
|
|
|
|
{
|
|
|
|
|
if (subDir.FullName.ToLower().Trim() != currentAppPath.FullName.ToLower().Trim())
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(subDir.FullName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
FileLogger.WriteLog("Delete app cache exception: " + ex.Message, StatusMessageType.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|