1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-25 15:20:10 +00:00
msfs-popout-panel-manager/MainApp/ViewModel/ApplicationViewModel.cs

48 lines
1.6 KiB
C#
Raw Normal View History

2023-07-12 22:41:31 +00:00
using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.WindowsAgent;
using PropertyChanged;
using System;
using System.Windows;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
[SuppressPropertyChangedWarnings]
public class ApplicationViewModel : BaseViewModel
{
2024-02-28 02:44:21 +00:00
private readonly AppOrchestrator _appOrchestrator;
2023-07-12 22:41:31 +00:00
public WindowState InitialWindowState { get; private set; }
2024-02-28 02:44:21 +00:00
public ApplicationViewModel(SharedStorage sharedStorage, AppOrchestrator appOrchestrator) : base(sharedStorage)
{
_appOrchestrator = appOrchestrator;
}
2023-07-12 22:41:31 +00:00
public void Initialize()
{
// Set title bar color
WindowActionManager.SetWindowTitleBarColor(ApplicationHandle, "303030");
2024-02-28 02:44:21 +00:00
_appOrchestrator.Initialize();
AppSettingData.OnAlwaysOnTopChanged += (_, e) => WindowActionManager.ApplyAlwaysOnTop(ApplicationHandle, PanelType.PopOutManager, e);
2023-07-12 22:41:31 +00:00
// Set window state
2024-02-28 02:44:21 +00:00
if (AppSettingData.ApplicationSetting.GeneralSetting.StartMinimized)
2023-07-12 22:41:31 +00:00
InitialWindowState = WindowState.Minimized;
// Set Always on Top
2024-02-28 02:44:21 +00:00
if (AppSettingData.ApplicationSetting.GeneralSetting.AlwaysOnTop)
WindowActionManager.ApplyAlwaysOnTop(ApplicationHandle, PanelType.PopOutManager, AppSettingData.ApplicationSetting.GeneralSetting.AlwaysOnTop);
2023-07-12 22:41:31 +00:00
}
public void WindowClosing()
{
2024-02-28 02:44:21 +00:00
_appOrchestrator.ApplicationClose();
2023-07-12 22:41:31 +00:00
if (Application.Current != null)
Environment.Exit(0);
}
}
}