1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-24 14:50:10 +00:00
msfs-popout-panel-manager/MainApp/ViewModel/BaseViewModel.cs
2023-09-29 02:15:02 -04:00

65 lines
2.4 KiB
C#

using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.Shared;
using System;
using System.Collections.Generic;
using System.Windows.Documents;
using System.Windows.Media;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
public abstract class BaseViewModel : ObservableObject
{
protected const string ROOT_DIALOG_HOST = "RootDialog";
protected MainOrchestrator Orchestrator { get; set; }
public BaseViewModel(MainOrchestrator orchestrator)
{
Orchestrator = orchestrator;
Orchestrator.PanelPopOut.OnPopOutStarted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = true;
Orchestrator.PanelPopOut.OnPopOutCompleted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = false;
Orchestrator.PanelSource.OnPanelSourceSelectionStarted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = true;
Orchestrator.PanelSource.OnPanelSourceSelectionCompleted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = false;
}
public AppSettingData AppSettingData => Orchestrator.AppSettingData;
public ProfileData ProfileData => Orchestrator.ProfileData;
public FlightSimData FlightSimData => Orchestrator.FlightSimData;
protected List<Run> FormatStatusMessages(List<StatusMessage> messages)
{
List<Run> runs = new List<Run>();
foreach (var statusMessage in messages)
{
var run = new Run();
run.Text = statusMessage.Message;
switch (statusMessage.StatusMessageType)
{
case StatusMessageType.Success:
run.Foreground = new SolidColorBrush(Colors.LimeGreen);
break;
case StatusMessageType.Failure:
run.Foreground = new SolidColorBrush(Colors.IndianRed);
break;
case StatusMessageType.Executing:
run.Foreground = new SolidColorBrush(Colors.NavajoWhite);
break;
case StatusMessageType.Info:
break;
}
runs.Add(run);
if (statusMessage.NewLine)
runs.Add(new Run { Text = Environment.NewLine });
}
return runs;
}
}
}