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

56 lines
1.9 KiB
C#
Raw Normal View History

2023-07-12 22:41:31 +00:00
using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.WindowsAgent;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
[SuppressPropertyChangedWarnings]
public class ApplicationViewModel : BaseViewModel
{
public IntPtr ApplicationHandle
{
get => Orchestrator.ApplicationHandle;
set => Orchestrator.ApplicationHandle = value;
}
public Window ApplicationWindow { set => Orchestrator.ApplicationWindow = value; }
public WindowState InitialWindowState { get; private set; }
public ApplicationViewModel(MainOrchestrator orchestrator) : base(orchestrator) { }
2023-07-12 22:41:31 +00:00
public void Initialize()
{
// Set title bar color
WindowActionManager.SetWindowTitleBarColor(ApplicationHandle, "303030");
Orchestrator.Initialize();
Orchestrator.AppSettingData.AlwaysOnTopChanged += (sender, e) => WindowActionManager.ApplyAlwaysOnTop(ApplicationHandle, PanelType.PopOutManager, e);
// Set window state
if (Orchestrator.AppSettingData.ApplicationSetting.GeneralSetting.StartMinimized)
InitialWindowState = WindowState.Minimized;
// Set Always on Top
if (Orchestrator.AppSettingData.ApplicationSetting.GeneralSetting.AlwaysOnTop)
WindowActionManager.ApplyAlwaysOnTop(ApplicationHandle, PanelType.PopOutManager, Orchestrator.AppSettingData.ApplicationSetting.GeneralSetting.AlwaysOnTop);
2023-08-18 21:02:03 +00:00
2023-07-12 22:41:31 +00:00
}
public void WindowClosing()
{
Orchestrator.ApplicationClose();
if (Application.Current != null)
Environment.Exit(0);
}
}
}