2022-07-23 19:23:32 +00:00
|
|
|
|
using System;
|
2022-01-27 13:40:04 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
2022-07-23 19:23:32 +00:00
|
|
|
|
namespace MSFSPopoutPanelManager.WindowsAgent
|
2022-01-27 13:40:04 +00:00
|
|
|
|
{
|
2022-07-23 19:23:32 +00:00
|
|
|
|
public class WindowProcessManager
|
2022-01-27 13:40:04 +00:00
|
|
|
|
{
|
|
|
|
|
public static string GetApplicationVersion()
|
|
|
|
|
{
|
|
|
|
|
var systemAssemblyVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
|
|
|
|
|
var appVersion = $"{systemAssemblyVersion.Major}.{systemAssemblyVersion.Minor}.{systemAssemblyVersion.Build}";
|
|
|
|
|
if (systemAssemblyVersion.Revision > 0)
|
|
|
|
|
appVersion += "." + systemAssemblyVersion.Revision;
|
|
|
|
|
|
|
|
|
|
return appVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static WindowProcess GetSimulatorProcess()
|
|
|
|
|
{
|
2022-07-23 19:23:32 +00:00
|
|
|
|
return GetWindowProcess("FlightSimulator");
|
2022-01-27 13:40:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static WindowProcess GetApplicationProcess()
|
|
|
|
|
{
|
2022-07-23 19:23:32 +00:00
|
|
|
|
return GetWindowProcess("MSFSPopoutPanelManager");
|
2022-01-27 13:40:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void OpenOnlineUserGuide()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://github.com/hawkeye-stan/msfs-popout-panel-manager#msfs-pop-out-panel-manager") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void OpenOnlineLatestDownload()
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo("https://github.com/hawkeye-stan/msfs-popout-panel-manager/releases") { UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-23 19:23:32 +00:00
|
|
|
|
private static WindowProcess GetWindowProcess(string processName)
|
2022-01-27 13:40:04 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (var process in Process.GetProcesses())
|
|
|
|
|
{
|
|
|
|
|
if (process.ProcessName == processName)
|
|
|
|
|
{
|
|
|
|
|
return new WindowProcess()
|
|
|
|
|
{
|
|
|
|
|
ProcessId = process.Id,
|
|
|
|
|
ProcessName = process.ProcessName,
|
|
|
|
|
Handle = process.MainWindowHandle
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-23 19:23:32 +00:00
|
|
|
|
|
|
|
|
|
public class WindowProcess
|
|
|
|
|
{
|
|
|
|
|
public int ProcessId { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ProcessName { get; set; }
|
|
|
|
|
|
|
|
|
|
public IntPtr Handle { get; set; }
|
|
|
|
|
}
|
2022-01-27 13:40:04 +00:00
|
|
|
|
}
|