mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-21 21:30:12 +00:00
Update camera view logic
This commit is contained in:
parent
079e040ce7
commit
324b7a051b
13 changed files with 327 additions and 207 deletions
|
@ -46,6 +46,9 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
||||||
case StatusMessageType.Failure:
|
case StatusMessageType.Failure:
|
||||||
run.Foreground = new SolidColorBrush(Colors.IndianRed);
|
run.Foreground = new SolidColorBrush(Colors.IndianRed);
|
||||||
break;
|
break;
|
||||||
|
case StatusMessageType.Executing:
|
||||||
|
run.Foreground = new SolidColorBrush(Colors.Yellow);
|
||||||
|
break;
|
||||||
case StatusMessageType.Info:
|
case StatusMessageType.Info:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
||||||
if (AppSettingData.ApplicationSetting.PopOutSetting.EnablePopOutMessages)
|
if (AppSettingData.ApplicationSetting.PopOutSetting.EnablePopOutMessages)
|
||||||
{
|
{
|
||||||
WindowActionManager.ApplyAlwaysOnTop(Handle, PanelType.StatusMessageWindow, true);
|
WindowActionManager.ApplyAlwaysOnTop(Handle, PanelType.StatusMessageWindow, true);
|
||||||
OnMessageUpdated?.Invoke(this, FormatStatusMessages(e.Messages));
|
OnMessageUpdated?.Invoke(this, FormatStatusMessages(e));
|
||||||
|
|
||||||
CenterDialogToGameWindow();
|
CenterDialogToGameWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
_simConnectProvider = null;
|
_simConnectProvider = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOnTrackIR(bool writeMessage = true)
|
public void TurnOnTrackIR()
|
||||||
{
|
{
|
||||||
if (_simConnectProvider == null)
|
if (_simConnectProvider == null)
|
||||||
return;
|
return;
|
||||||
|
@ -122,24 +122,22 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning on TrackIR", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning on TrackIR", () =>
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOnTrackIR();
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOnTrackIR();
|
||||||
while (!_flightSimData.TrackIRStatus && count < 5);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (!_flightSimData.TrackIRStatus && count < 5);
|
||||||
|
|
||||||
if (_flightSimData.TrackIRStatus)
|
return _flightSimData.TrackIRStatus;
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
});
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOffTrackIR(bool writeMessage = true)
|
public void TurnOffTrackIR()
|
||||||
{
|
{
|
||||||
if (_simConnectProvider == null)
|
if (_simConnectProvider == null)
|
||||||
return;
|
return;
|
||||||
|
@ -147,24 +145,19 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning off TrackIR", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning off TrackIR", () =>
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOffTrackIR();
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOffTrackIR();
|
||||||
while (_flightSimData.TrackIRStatus && count < 5);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (_flightSimData.TrackIRStatus && count < 5);
|
||||||
|
|
||||||
if (!writeMessage)
|
return !_flightSimData.TrackIRStatus;
|
||||||
return;
|
});
|
||||||
|
|
||||||
if (!_flightSimData.TrackIRStatus)
|
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOnPower()
|
public void TurnOnPower()
|
||||||
|
@ -176,21 +169,20 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_isTurnedOnPower = true;
|
_isTurnedOnPower = true;
|
||||||
StatusMessageWriter.WriteMessage("Turning on battery", StatusMessageType.Info);
|
|
||||||
|
|
||||||
int count = 0;
|
WorkflowStepWithMessage.Execute("Turning on battery", () =>
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOnPower(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOnPower(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
||||||
while (!_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (!_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
||||||
|
|
||||||
if (_flightSimData.ElectricalMasterBatteryStatus)
|
return _flightSimData.ElectricalMasterBatteryStatus;
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
});
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOffPower()
|
public void TurnOffPower()
|
||||||
|
@ -201,21 +193,19 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (_profileData.ActiveProfile == null || !_isTurnedOnPower)
|
if (_profileData.ActiveProfile == null || !_isTurnedOnPower)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning off battery", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning off battery", () =>
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOffPower(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOffPower(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
||||||
while (_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
||||||
|
|
||||||
if (!_flightSimData.ElectricalMasterBatteryStatus)
|
return !_flightSimData.ElectricalMasterBatteryStatus;
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
});
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
|
|
||||||
_isTurnedOnPower = false;
|
_isTurnedOnPower = false;
|
||||||
}
|
}
|
||||||
|
@ -230,21 +220,19 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
|
|
||||||
_isTurnedOnAvionics = true;
|
_isTurnedOnAvionics = true;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning on avionics", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning on avionics", () =>
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOnAvionics(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOnAvionics(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
||||||
while (!_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (!_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
||||||
|
|
||||||
if (_flightSimData.AvionicsMasterSwitchStatus)
|
return _flightSimData.AvionicsMasterSwitchStatus;
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
});
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOffAvionics()
|
public void TurnOffAvionics()
|
||||||
|
@ -255,21 +243,19 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (_profileData.ActiveProfile == null || !_isTurnedOnAvionics)
|
if (_profileData.ActiveProfile == null || !_isTurnedOnAvionics)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning off avionics", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning off avionics", () =>
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
_simConnectProvider.TurnOffAvionics(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
int count = 0;
|
||||||
Thread.Sleep(500);
|
do
|
||||||
count++;
|
{
|
||||||
}
|
_simConnectProvider.TurnOffAvionics(_profileData.ActiveProfile.ProfileSetting.PowerOnRequiredForColdStart);
|
||||||
while (_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
Thread.Sleep(500);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
||||||
|
|
||||||
if (!_flightSimData.AvionicsMasterSwitchStatus)
|
return !_flightSimData.AvionicsMasterSwitchStatus;
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
});
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
|
|
||||||
_isTurnedOnAvionics = false;
|
_isTurnedOnAvionics = false;
|
||||||
}
|
}
|
||||||
|
@ -282,9 +268,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning on active pause", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning on active pause", () =>
|
||||||
_simConnectProvider.TurnOnActivePause();
|
{
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
_simConnectProvider.TurnOnActivePause();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TurnOffActivePause()
|
public void TurnOffActivePause()
|
||||||
|
@ -295,10 +282,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Turning off active pause", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Turning off active pause", () =>
|
||||||
_simConnectProvider.TurnOffActivePause();
|
{
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
_simConnectProvider.TurnOffActivePause();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncreaseSimRate()
|
public void IncreaseSimRate()
|
||||||
|
@ -328,6 +315,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
_simConnectProvider.SetCockpitCameraZoomLevel(zoomLevel);
|
_simConnectProvider.SetCockpitCameraZoomLevel(zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetCameraView()
|
||||||
|
{
|
||||||
|
_simConnectProvider.SetCameraRequestAction(1);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetHudBarConfig()
|
public void SetHudBarConfig()
|
||||||
{
|
{
|
||||||
if (_simConnectProvider == null)
|
if (_simConnectProvider == null)
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace MSFSPopoutPanelManager.Orchestration
|
namespace MSFSPopoutPanelManager.Orchestration
|
||||||
{
|
{
|
||||||
|
@ -86,7 +87,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
|
|
||||||
StatusMessageWriter.IsEnabled = true;
|
StatusMessageWriter.IsEnabled = true;
|
||||||
StatusMessageWriter.ClearMessage();
|
StatusMessageWriter.ClearMessage();
|
||||||
StatusMessageWriter.WriteMessageNewLine("Pop out in progress. Please refrain from moving your mouse.", StatusMessageType.Info);
|
StatusMessageWriter.WriteMessageWithNewLine("Pop out in progress. Please refrain from moving your mouse.", StatusMessageType.Info);
|
||||||
|
|
||||||
StepPopoutPrep();
|
StepPopoutPrep();
|
||||||
|
|
||||||
|
@ -141,10 +142,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Set Windowed Display Mode window's configuration if needed
|
// Set Windowed Display Mode window's configuration if needed
|
||||||
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow && WindowActionManager.IsMsfsGameInWindowedMode())
|
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow && WindowActionManager.IsMsfsGameInWindowedMode())
|
||||||
{
|
{
|
||||||
StatusMessageWriter.WriteMessage("Moving and resizing MSFS game window", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Moving and resizing MSFS game window", () =>
|
||||||
WindowActionManager.SetMsfsGameWindowLocation(ActiveProfile.MsfsGameWindowConfig);
|
{
|
||||||
Thread.Sleep(500);
|
WindowActionManager.SetMsfsGameWindowLocation(ActiveProfile.MsfsGameWindowConfig);
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
Thread.Sleep(1000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn on power and avionics if required to pop out panels at least one (fix Cessna 208b grand caravan mod bug where battery is reported as on)
|
// Turn on power and avionics if required to pop out panels at least one (fix Cessna 208b grand caravan mod bug where battery is reported as on)
|
||||||
|
@ -163,13 +165,28 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Setting custom camera angle for auto panning
|
// Setting custom camera angle for auto panning
|
||||||
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
||||||
{
|
{
|
||||||
StatusMessageWriter.WriteMessage("Setting auto panning camera angle", StatusMessageType.Info);
|
StatusMessageWriter.WriteMessageWithNewLine("Setting auto panning camera view", StatusMessageType.Info);
|
||||||
|
|
||||||
// Remember current game's zoom level to be recall after pop out
|
// Remember current game's zoom level to be recall after pop out
|
||||||
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
|
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
|
||||||
LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
|
||||||
SetCockpitZoomLevel(50);
|
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
{
|
||||||
|
ResetCockpitView();
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
|
||||||
|
{
|
||||||
|
LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
|
||||||
|
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||||
|
{
|
||||||
|
SetCockpitZoomLevel(50);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -181,25 +198,29 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Save current application location to restore it after pop out
|
// Save current application location to restore it after pop out
|
||||||
var appLocation = WindowActionManager.GetWindowRectangle(WindowProcessManager.GetApplicationProcess().Handle);
|
var appLocation = WindowActionManager.GetWindowRectangle(WindowProcessManager.GetApplicationProcess().Handle);
|
||||||
|
|
||||||
|
if(ActiveProfile.PanelConfigs.Count > 0)
|
||||||
|
StatusMessageWriter.WriteMessageWithNewLine("Popping out user defined panels", StatusMessageType.Info);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (var panelConfig in ActiveProfile.PanelConfigs)
|
foreach (var panelConfig in ActiveProfile.PanelConfigs)
|
||||||
{
|
{
|
||||||
if (panelConfig.PanelType == PanelType.CustomPopout)
|
if (panelConfig.PanelType == PanelType.CustomPopout)
|
||||||
{
|
{
|
||||||
StatusMessageWriter.WriteMessage($"Popping out panel '{panelConfig.PanelName}'", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
|
||||||
|
{
|
||||||
|
panelConfig.IsSelectedPanelSource = true;
|
||||||
|
//PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
|
||||||
|
//Thread.Sleep(500);
|
||||||
|
//PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
|
||||||
|
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
|
||||||
|
ApplyPanelLocation(panelConfig);
|
||||||
|
panelConfig.IsSelectedPanelSource = false;
|
||||||
|
|
||||||
panelConfig.IsSelectedPanelSource = true;
|
if (panelConfig.IsPopOutSuccess != null && !(bool)panelConfig.IsPopOutSuccess)
|
||||||
//PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
|
return false;
|
||||||
//Thread.Sleep(500);
|
else
|
||||||
//PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
|
return true;
|
||||||
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
|
}, true);
|
||||||
ApplyPanelLocation(panelConfig);
|
|
||||||
panelConfig.IsSelectedPanelSource = false;
|
|
||||||
|
|
||||||
if (panelConfig.IsPopOutSuccess != null && !(bool)panelConfig.IsPopOutSuccess)
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,10 +246,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
FlightSimOrchestrator.TurnOffActivePause();
|
FlightSimOrchestrator.TurnOffActivePause();
|
||||||
|
|
||||||
// Return to custom camera view if set
|
// Return to custom camera view if set
|
||||||
var task = Task.Run(() => {
|
ReturnToAfterPopOutCameraView();
|
||||||
//SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
|
||||||
ReturnToAfterPopOutCameraView();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,57 +254,64 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
{
|
{
|
||||||
if (ActiveProfile.ProfileSetting.IncludeInGamePanels)
|
if (ActiveProfile.ProfileSetting.IncludeInGamePanels)
|
||||||
{
|
{
|
||||||
var builtInPanels = new List<PanelConfig>();
|
WorkflowStepWithMessage.Execute("Configuring built-in panel", () =>
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Configuring built-in panel", StatusMessageType.Info);
|
|
||||||
|
|
||||||
foreach (var panelHandle in builtInPanelHandles)
|
|
||||||
{
|
{
|
||||||
var panelCaption = WindowActionManager.GetWindowCaption(panelHandle);
|
int count = 0;
|
||||||
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelName == panelCaption);
|
while (builtInPanelHandles.Count == 0 && count < 5)
|
||||||
|
|
||||||
if (panelConfig == null)
|
|
||||||
{
|
{
|
||||||
if (!ActiveProfile.IsLocked)
|
builtInPanelHandles = WindowActionManager.GetWindowsByPanelType(new List<PanelType>() { PanelType.BuiltInPopout });
|
||||||
{
|
}
|
||||||
var rectangle = WindowActionManager.GetWindowRectangle(panelHandle);
|
|
||||||
panelConfig = new PanelConfig()
|
|
||||||
{
|
|
||||||
PanelHandle = panelHandle,
|
|
||||||
PanelType = PanelType.BuiltInPopout,
|
|
||||||
PanelName = panelCaption,
|
|
||||||
Top = rectangle.Top,
|
|
||||||
Left = rectangle.Left,
|
|
||||||
Width = rectangle.Width,
|
|
||||||
Height = rectangle.Height,
|
|
||||||
AutoGameRefocus = false
|
|
||||||
};
|
|
||||||
|
|
||||||
ActiveProfile.PanelConfigs.Add(panelConfig);
|
var builtInPanels = new List<PanelConfig>();
|
||||||
|
|
||||||
|
foreach (var panelHandle in builtInPanelHandles)
|
||||||
|
{
|
||||||
|
var panelCaption = WindowActionManager.GetWindowCaption(panelHandle);
|
||||||
|
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelName == panelCaption);
|
||||||
|
|
||||||
|
if (panelConfig == null)
|
||||||
|
{
|
||||||
|
if (!ActiveProfile.IsLocked)
|
||||||
|
{
|
||||||
|
var rectangle = WindowActionManager.GetWindowRectangle(panelHandle);
|
||||||
|
panelConfig = new PanelConfig()
|
||||||
|
{
|
||||||
|
PanelHandle = panelHandle,
|
||||||
|
PanelType = PanelType.BuiltInPopout,
|
||||||
|
PanelName = panelCaption,
|
||||||
|
Top = rectangle.Top,
|
||||||
|
Left = rectangle.Left,
|
||||||
|
Width = rectangle.Width,
|
||||||
|
Height = rectangle.Height,
|
||||||
|
AutoGameRefocus = false
|
||||||
|
};
|
||||||
|
|
||||||
|
ActiveProfile.PanelConfigs.Add(panelConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panelConfig.PanelHandle = panelHandle;
|
||||||
|
|
||||||
|
// Need to do it twice for MSFS to take this setting (MSFS bug)
|
||||||
|
ApplyPanelLocation(panelConfig);
|
||||||
|
ApplyPanelLocation(panelConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Set handles for missing built-in panels
|
||||||
|
foreach (var panelConfig in ActiveProfile.PanelConfigs)
|
||||||
{
|
{
|
||||||
panelConfig.PanelHandle = panelHandle;
|
if (panelConfig.PanelType == PanelType.BuiltInPopout && panelConfig.PanelHandle == IntPtr.MaxValue)
|
||||||
|
panelConfig.PanelHandle = IntPtr.Zero;
|
||||||
// Need to do it twice for MSFS to take this setting (MSFS bug)
|
|
||||||
ApplyPanelLocation(panelConfig);
|
|
||||||
ApplyPanelLocation(panelConfig);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Set handles for missing built-in panels
|
if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.BuiltInPopout && p.IsPopOutSuccess != null && !(bool)p.IsPopOutSuccess) ||
|
||||||
foreach (var panelConfig in ActiveProfile.PanelConfigs)
|
ActiveProfile.PanelConfigs.Count(p => p.PanelType == PanelType.BuiltInPopout) == 0)
|
||||||
{
|
return false;
|
||||||
if (panelConfig.PanelType == PanelType.BuiltInPopout && panelConfig.PanelHandle == IntPtr.MaxValue)
|
else
|
||||||
panelConfig.PanelHandle = IntPtr.Zero;
|
return true;
|
||||||
}
|
});
|
||||||
|
|
||||||
if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.BuiltInPopout && p.IsPopOutSuccess != null && !(bool)p.IsPopOutSuccess) ||
|
|
||||||
ActiveProfile.PanelConfigs.Count(p => p.PanelType == PanelType.BuiltInPopout) == 0)
|
|
||||||
StatusMessageWriter.WriteFailureStatusMessage();
|
|
||||||
else
|
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,13 +320,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!ActiveProfile.ProfileSetting.HudBarConfig.IsEnabled)
|
if (!ActiveProfile.ProfileSetting.HudBarConfig.IsEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusMessageWriter.WriteMessage("Opening HUD Bar", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute("Opening HUD Bar", () =>
|
||||||
|
{
|
||||||
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelType == PanelType.HudBarWindow);
|
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelType == PanelType.HudBarWindow);
|
||||||
|
OnHudBarOpened?.Invoke(this, panelConfig);
|
||||||
OnHudBarOpened?.Invoke(this, panelConfig);
|
});
|
||||||
|
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupRefocusDisplay()
|
public void SetupRefocusDisplay()
|
||||||
|
@ -309,13 +332,21 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!ActiveProfile.ProfileSetting.RefocusOnDisplay.IsEnabled)
|
if (!ActiveProfile.ProfileSetting.RefocusOnDisplay.IsEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var panelConfig in ActiveProfile.PanelConfigs.Where(p => p.PanelType == PanelType.RefocusDisplay))
|
var panelConfigs = ActiveProfile.PanelConfigs.Where(p => p.PanelType == PanelType.RefocusDisplay);
|
||||||
|
|
||||||
|
if (panelConfigs.Count() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StatusMessageWriter.WriteMessageWithNewLine("Configurating panels for auto refocus on touch", StatusMessageType.Info);
|
||||||
|
|
||||||
|
foreach (var panelConfig in panelConfigs)
|
||||||
{
|
{
|
||||||
if (panelConfig != null)
|
if (panelConfig != null)
|
||||||
{
|
{
|
||||||
StatusMessageWriter.WriteMessage($"Configurating {panelConfig.PanelName} for auto refocus on touch", StatusMessageType.Info);
|
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
|
||||||
panelConfig.PanelHandle = new IntPtr(1);
|
{
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
panelConfig.PanelHandle = new IntPtr(1);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,9 +380,9 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
PanelConfigurationOrchestrator.StartTouchHook();
|
PanelConfigurationOrchestrator.StartTouchHook();
|
||||||
|
|
||||||
if (CheckForPopOutError())
|
if (CheckForPopOutError())
|
||||||
StatusMessageWriter.WriteMessageNewLine("Pop out has been completed with error.", StatusMessageType.Info, 10);
|
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed with error.", StatusMessageType.Info);
|
||||||
else
|
else
|
||||||
StatusMessageWriter.WriteMessageNewLine("Pop out has been completed successfully.", StatusMessageType.Info, 10);
|
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed successfully.", StatusMessageType.Info);
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
OnPopOutCompleted?.Invoke(this, null);
|
OnPopOutCompleted?.Invoke(this, null);
|
||||||
|
@ -461,15 +492,41 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
StatusMessageWriter.WriteMessageWithNewLine("Applying cockpit view after pop out", StatusMessageType.Info);
|
||||||
|
|
||||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||||
{
|
{
|
||||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||||
InputEmulationManager.CenterView();
|
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||||
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
{
|
||||||
|
ResetCockpitView();
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||||
|
{
|
||||||
|
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
||||||
|
}, true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AfterPopOutCameraViewType.CustomCameraView:
|
case AfterPopOutCameraViewType.CustomCameraView:
|
||||||
LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||||
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
{
|
||||||
|
ResetCockpitView();
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
|
||||||
|
{
|
||||||
|
LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||||
|
{
|
||||||
|
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
||||||
|
}, true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,13 +536,25 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
return ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null && (bool)p.IsPopOutSuccess) != ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null);
|
return ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null && (bool)p.IsPopOutSuccess) != ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ResetCockpitView()
|
||||||
|
{
|
||||||
|
int retry = 10;
|
||||||
|
for (var i = 0; i < retry; i++)
|
||||||
|
{
|
||||||
|
FlightSimOrchestrator.ResetCameraView();
|
||||||
|
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||||
|
if (_flightSimData.CameraViewTypeAndIndex1 == 0) // 0 = reset view
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadCustomView(string keybinding)
|
private void LoadCustomView(string keybinding)
|
||||||
{
|
{
|
||||||
int retry = 20;
|
int retry = 20;
|
||||||
for(var i = 0; i < retry; i++)
|
for(var i = 0; i < retry; i++)
|
||||||
{
|
{
|
||||||
InputEmulationManager.LoadCustomView(keybinding);
|
InputEmulationManager.LoadCustomView(keybinding);
|
||||||
Thread.Sleep(750); // wait for flightsimdata to be updated
|
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||||
if (_flightSimData.CameraViewTypeAndIndex1 == 7) // 7 = custom camera view enum
|
if (_flightSimData.CameraViewTypeAndIndex1 == 7) // 7 = custom camera view enum
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +566,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
for (var i = 0; i < retry; i++)
|
for (var i = 0; i < retry; i++)
|
||||||
{
|
{
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
|
||||||
Thread.Sleep(500); // wait for flightsimdata to be updated
|
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||||
|
|
||||||
if (_flightSimData.CockpitCameraZoom == zoom)
|
if (_flightSimData.CockpitCameraZoom == zoom)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn off TrackIR if TrackIR is started
|
// Turn off TrackIR if TrackIR is started
|
||||||
FlightSimOrchestrator.TurnOffTrackIR(false);
|
FlightSimOrchestrator.TurnOffTrackIR();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task EndEditPanelSources()
|
public async Task EndEditPanelSources()
|
||||||
|
@ -88,19 +88,22 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Save last auto panning camera angle
|
// Save last auto panning camera angle
|
||||||
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
||||||
{
|
{
|
||||||
InputEmulationManager.SaveCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
|
||||||
|
|
||||||
// If using windows mode, save MSFS game window configuration
|
// If using windows mode, save MSFS game window configuration
|
||||||
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow)
|
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow)
|
||||||
_profileData.SaveMsfsGameWindowConfig();
|
_profileData.SaveMsfsGameWindowConfig();
|
||||||
|
|
||||||
|
InputEmulationManager.SaveCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(500); // wait for custom view save to be completed
|
||||||
|
|
||||||
// Recenter game or return to after pop out camera view
|
// Recenter game or return to after pop out camera view
|
||||||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||||
{
|
{
|
||||||
InputEmulationManager.CenterView();
|
FlightSimOrchestrator.ResetCameraView();
|
||||||
|
Thread.Sleep(500);
|
||||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -108,7 +111,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||||
{
|
{
|
||||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||||
InputEmulationManager.CenterView();
|
FlightSimOrchestrator.ResetCameraView();
|
||||||
|
Thread.Sleep(500);
|
||||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||||
break;
|
break;
|
||||||
case AfterPopOutCameraViewType.CustomCameraView:
|
case AfterPopOutCameraViewType.CustomCameraView:
|
||||||
|
@ -121,7 +125,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
WindowActionManager.BringWindowToForeground(ApplicationHandle);
|
WindowActionManager.BringWindowToForeground(ApplicationHandle);
|
||||||
|
|
||||||
// Turn TrackIR back on
|
// Turn TrackIR back on
|
||||||
FlightSimOrchestrator.TurnOnTrackIR(false);
|
FlightSimOrchestrator.TurnOnTrackIR();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,20 +8,9 @@ namespace MSFSPopoutPanelManager.Shared
|
||||||
public StatusMessageEventArg(List<StatusMessage> messages)
|
public StatusMessageEventArg(List<StatusMessage> messages)
|
||||||
{
|
{
|
||||||
Messages = messages;
|
Messages = messages;
|
||||||
Duration = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StatusMessageEventArg(List<StatusMessage> messages, int duration)
|
|
||||||
{
|
|
||||||
Messages = messages;
|
|
||||||
Duration = duration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StatusMessage> Messages { get; set; }
|
public List<StatusMessage> Messages { get; set; }
|
||||||
|
|
||||||
public StatusMessageType StatusMessageType { get; set; }
|
|
||||||
|
|
||||||
public int Duration { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatusMessage
|
public class StatusMessage
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
Info,
|
Info,
|
||||||
Success,
|
Success,
|
||||||
Failure,
|
Failure,
|
||||||
|
Executing,
|
||||||
Error,
|
Error,
|
||||||
Debug
|
Debug
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,44 +7,57 @@ namespace MSFSPopoutPanelManager.Shared
|
||||||
{
|
{
|
||||||
private static List<StatusMessage> _messages = new List<StatusMessage>();
|
private static List<StatusMessage> _messages = new List<StatusMessage>();
|
||||||
|
|
||||||
public static event EventHandler<StatusMessageEventArg> OnStatusMessage;
|
public static event EventHandler<List<StatusMessage>> OnStatusMessage;
|
||||||
|
|
||||||
public static void WriteMessage(string message, StatusMessageType statusMessageType, int duration = -1)
|
public static void WriteMessage(string message, StatusMessageType statusMessageType)
|
||||||
{
|
{
|
||||||
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = false });
|
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType });
|
||||||
|
|
||||||
if (IsEnabled)
|
if (IsEnabled)
|
||||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
OnStatusMessage?.Invoke(null, _messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteMessageNewLine(string message, StatusMessageType statusMessageType, int duration = -1)
|
public static void WriteMessageWithNewLine(string message, StatusMessageType statusMessageType)
|
||||||
{
|
{
|
||||||
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = true });
|
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = true });
|
||||||
|
|
||||||
if (IsEnabled)
|
if (IsEnabled)
|
||||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
OnStatusMessage?.Invoke(null, _messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteOkStatusMessage(int duration = -1)
|
public static void WriteExecutingStatusMessage()
|
||||||
|
{
|
||||||
|
_messages.Add(new StatusMessage { Message = " (Executing)", StatusMessageType = StatusMessageType.Executing, NewLine = false });
|
||||||
|
|
||||||
|
if (IsEnabled)
|
||||||
|
OnStatusMessage?.Invoke(null, _messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteOkStatusMessage()
|
||||||
{
|
{
|
||||||
_messages.Add(new StatusMessage { Message = " (OK)", StatusMessageType = StatusMessageType.Success, NewLine = true });
|
_messages.Add(new StatusMessage { Message = " (OK)", StatusMessageType = StatusMessageType.Success, NewLine = true });
|
||||||
|
|
||||||
if (IsEnabled)
|
if (IsEnabled)
|
||||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
OnStatusMessage?.Invoke(null, _messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteFailureStatusMessage(int duration = -1)
|
public static void WriteFailureStatusMessage()
|
||||||
{
|
{
|
||||||
_messages.Add(new StatusMessage { Message = " (FAILED)", StatusMessageType = StatusMessageType.Failure, NewLine = true });
|
_messages.Add(new StatusMessage { Message = " (FAILED)", StatusMessageType = StatusMessageType.Failure, NewLine = true });
|
||||||
|
|
||||||
if (IsEnabled)
|
if (IsEnabled)
|
||||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
OnStatusMessage?.Invoke(null, _messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveLastMessage()
|
||||||
|
{
|
||||||
|
_messages.RemoveAt(_messages.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ClearMessage()
|
public static void ClearMessage()
|
||||||
{
|
{
|
||||||
_messages.Clear();
|
_messages.Clear();
|
||||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(new List<StatusMessage>()));
|
OnStatusMessage?.Invoke(null, new List<StatusMessage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsEnabled { get; set; }
|
public static bool IsEnabled { get; set; }
|
||||||
|
|
38
Shared/WorkflowStepWithMessage.cs
Normal file
38
Shared/WorkflowStepWithMessage.cs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSFSPopoutPanelManager.Shared
|
||||||
|
{
|
||||||
|
public static class WorkflowStepWithMessage
|
||||||
|
{
|
||||||
|
public static void Execute(string message, Func<bool> function, bool isSubTask = false)
|
||||||
|
{
|
||||||
|
if (isSubTask)
|
||||||
|
message = " " + message;
|
||||||
|
|
||||||
|
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||||
|
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||||
|
|
||||||
|
var result = function.Invoke();
|
||||||
|
|
||||||
|
StatusMessageWriter.RemoveLastMessage();
|
||||||
|
if (result)
|
||||||
|
StatusMessageWriter.WriteOkStatusMessage();
|
||||||
|
else
|
||||||
|
StatusMessageWriter.WriteFailureStatusMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Execute(string message, Action function, bool isSubTask = false)
|
||||||
|
{
|
||||||
|
if (isSubTask)
|
||||||
|
message = " " + message;
|
||||||
|
|
||||||
|
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||||
|
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||||
|
|
||||||
|
function.Invoke();
|
||||||
|
|
||||||
|
StatusMessageWriter.RemoveLastMessage();
|
||||||
|
StatusMessageWriter.WriteOkStatusMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
HUDBAR_DEFINITION,
|
HUDBAR_DEFINITION,
|
||||||
WRITEABLE_TRACKIR_DEFINITION,
|
WRITEABLE_TRACKIR_DEFINITION,
|
||||||
WRITEABLE_COCKPITCAMERAZOOM_DEFINITION,
|
WRITEABLE_COCKPITCAMERAZOOM_DEFINITION,
|
||||||
|
WRITEABLE_CAMERAREQUESTACTION_DEFINITION,
|
||||||
NA
|
NA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,11 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
||||||
_simConnector.SetDataObject(WriteableVariableName.CockpitCameraZoom, Convert.ToDouble(zoomLevel));
|
_simConnector.SetDataObject(WriteableVariableName.CockpitCameraZoom, Convert.ToDouble(zoomLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCameraRequestAction(int actionEnum)
|
||||||
|
{
|
||||||
|
_simConnector.SetDataObject(WriteableVariableName.CameraRequestAction, Convert.ToDouble(actionEnum));
|
||||||
|
}
|
||||||
|
|
||||||
private void SetTrackIREnable(bool enable)
|
private void SetTrackIREnable(bool enable)
|
||||||
{
|
{
|
||||||
_simConnector.SetDataObject(WriteableVariableName.TrackIREnable, enable ? Convert.ToDouble(1) : Convert.ToDouble(0));
|
_simConnector.SetDataObject(WriteableVariableName.TrackIREnable, enable ? Convert.ToDouble(1) : Convert.ToDouble(0));
|
||||||
|
|
|
@ -192,6 +192,9 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
||||||
case WriteableVariableName.CockpitCameraZoom:
|
case WriteableVariableName.CockpitCameraZoom:
|
||||||
_simConnect.SetDataOnSimObject(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dataStruct);
|
_simConnect.SetDataOnSimObject(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dataStruct);
|
||||||
break;
|
break;
|
||||||
|
case WriteableVariableName.CameraRequestAction:
|
||||||
|
_simConnect.SetDataOnSimObject(DATA_DEFINITION.WRITEABLE_CAMERAREQUESTACTION_DEFINITION, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dataStruct);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -309,6 +312,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
||||||
|
|
||||||
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION, "TRACK IR ENABLE", "bool", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION, "TRACK IR ENABLE", "bool", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||||
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, "COCKPIT CAMERA ZOOM", "percentage", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, "COCKPIT CAMERA ZOOM", "percentage", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||||
|
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_CAMERAREQUESTACTION_DEFINITION, "CAMERA REQUEST ACTION", "enum", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||||
|
|
||||||
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.REQUIRED_DEFINITION);
|
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.REQUIRED_DEFINITION);
|
||||||
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION);
|
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION);
|
||||||
|
|
|
@ -94,7 +94,8 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
||||||
public enum WriteableVariableName
|
public enum WriteableVariableName
|
||||||
{
|
{
|
||||||
TrackIREnable,
|
TrackIREnable,
|
||||||
CockpitCameraZoom
|
CockpitCameraZoom,
|
||||||
|
CameraRequestAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue