1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-24 23:00:12 +00:00
msfs-popout-panel-manager/MainApp/ViewModel/TrayIconViewModel.cs
2023-07-12 18:47:24 -04:00

55 lines
2.2 KiB
C#

using MSFSPopoutPanelManager.Orchestration;
using Prism.Commands;
using System;
using System.Windows;
using System.Windows.Input;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
public class TrayIconViewModel : BaseViewModel
{
public DelegateCommand<object> ChangeProfileCommand { get; }
public ICommand StartPopOutCommand { get; }
public ICommand ExitAppCommand { get; }
public TrayIconViewModel(MainOrchestrator orchestrator) : base(orchestrator)
{
StartPopOutCommand = new DelegateCommand(OnStartPopOut, () => ProfileData != null && ProfileData.ActiveProfile != null && ProfileData.ActiveProfile.PanelConfigs.Count > 0 && !ProfileData.ActiveProfile.HasUnidentifiedPanelSource && !ProfileData.ActiveProfile.IsEditingPanelSource && FlightSimData.IsInCockpit)
.ObservesProperty(() => ProfileData.ActiveProfile)
.ObservesProperty(() => ProfileData.ActiveProfile.PanelConfigs.Count)
.ObservesProperty(() => ProfileData.ActiveProfile.HasUnidentifiedPanelSource)
.ObservesProperty(() => ProfileData.ActiveProfile.IsEditingPanelSource)
.ObservesProperty(() => FlightSimData.IsInCockpit);
ChangeProfileCommand = new DelegateCommand<object>(OnChangeProfile);
ExitAppCommand = new DelegateCommand(OnExitApp);
}
private void OnChangeProfile(object param)
{
var profileId = Convert.ToString(param);
if (string.IsNullOrEmpty(profileId))
return;
ProfileData.ResetActiveProfile();
ProfileData.SetActiveProfile(new Guid(profileId));
}
private void OnStartPopOut()
{
Orchestrator.PanelPopOut.ManualPopOut();
}
private void OnExitApp()
{
Orchestrator.ApplicationClose();
if (Application.Current != null)
Environment.Exit(0);
}
}
}