diff --git a/UI/MainForm.Designer.cs b/UI/MainForm.Designer.cs index 991ce242..c4e4cbea 100644 --- a/UI/MainForm.Designer.cs +++ b/UI/MainForm.Designer.cs @@ -136,6 +136,7 @@ private void InitializeComponent() this.logSplitter = new System.Windows.Forms.Splitter(); this.startupPanel = new MobiFlight.UI.Panels.StartupPanel(); this.logPanel1 = new MobiFlight.UI.Panels.LogPanel(); + this.toolStripConnectedDevicesIcon = new System.Windows.Forms.ToolStripStatusLabel(); this.menuStrip.SuspendLayout(); this.panelMain.SuspendLayout(); this.inputsTabControl.SuspendLayout(); @@ -606,6 +607,7 @@ private void InitializeComponent() resources.ApplyResources(this.statusStrip2, "statusStrip2"); this.statusStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.connectedDevicesToolStripLabel, + this.toolStripConnectedDevicesIcon, this.connectedDevicesToolStripDropDownButton, this.dividerToolStripStatusLabel2, this.SimStatusToolStripStatusLabel, @@ -878,6 +880,13 @@ private void InitializeComponent() resources.ApplyResources(this.logPanel1, "logPanel1"); this.logPanel1.Name = "logPanel1"; // + // toolStripConnectedDevicesIcon + // + this.toolStripConnectedDevicesIcon.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripConnectedDevicesIcon.Image = global::MobiFlight.Properties.Resources.warning; + this.toolStripConnectedDevicesIcon.Name = "toolStripConnectedDevicesIcon"; + resources.ApplyResources(this.toolStripConnectedDevicesIcon, "toolStripConnectedDevicesIcon"); + // // MainForm // resources.ApplyResources(this, "$this"); @@ -1029,6 +1038,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem2; + private System.Windows.Forms.ToolStripStatusLabel toolStripConnectedDevicesIcon; } } diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 6160f1ec..1fa10077 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -44,6 +44,12 @@ public partial class MainForm : Form private Dictionary AutoLoadConfigs = new Dictionary(); public event EventHandler CurrentFilenameChanged; + // Track whether there are any connected devices of the different types, to avoid unnecessary + // array retrievals from execManager. + private bool hasConnectedJoysticks = false; + private bool hasConnectedMidiBoards = false; + private bool hasConnectedModules = false; + private bool IsMSFSRunning = false; public string CurrentFileName { @@ -218,6 +224,7 @@ private void MainForm_Shown(object sender, EventArgs e) FsuipcToolStripMenuItem.Image = Properties.Resources.warning; simConnectToolStripMenuItem.Image = Properties.Resources.warning; xPlaneDirectToolStripMenuItem.Image = Properties.Resources.warning; + toolStripConnectedDevicesIcon.Image = Properties.Resources.warning; // we only load the autorun value stored in settings // and do not use possibly passed in autoRun from cmdline @@ -260,6 +267,18 @@ private void MainForm_Shown(object sender, EventArgs e) Refresh(); } + private void RefreshConnectedDevicesIcon() + { + if (hasConnectedJoysticks || hasConnectedMidiBoards || hasConnectedMidiBoards) + { + toolStripConnectedDevicesIcon.Image = Properties.Resources.check; + } + else + { + toolStripConnectedDevicesIcon.Image = Properties.Resources.warning; + } + } + private void ExecManager_OnJoystickConnectedFinished(object sender, EventArgs e) { joysticksToolStripMenuItem.DropDownItems.Clear(); @@ -273,14 +292,21 @@ private void ExecManager_OnJoystickConnectedFinished(object sender, EventArgs e) Enabled = false }; joysticksToolStripMenuItem.DropDownItems.Add(item); - return; - } - foreach (var joystick in joysticks) + hasConnectedJoysticks = false; + } + else { - var item = new ToolStripMenuItem(joystick.Name); - joysticksToolStripMenuItem.DropDownItems.Add(item); + foreach (var joystick in joysticks) + { + var item = new ToolStripMenuItem(joystick.Name); + joysticksToolStripMenuItem.DropDownItems.Add(item); + } + + hasConnectedJoysticks = true; } + + RefreshConnectedDevicesIcon(); } private void ExecManager_OnMidiBoardConnectedFinished(object sender, EventArgs e) @@ -296,14 +322,21 @@ private void ExecManager_OnMidiBoardConnectedFinished(object sender, EventArgs e Enabled = false }; joysticksToolStripMenuItem.DropDownItems.Add(item); - return; - } - foreach (var device in devices) + hasConnectedMidiBoards = false; + } + else { - var item = new ToolStripMenuItem(device.Name); - joysticksToolStripMenuItem.DropDownItems.Add(item); + foreach (var device in devices) + { + var item = new ToolStripMenuItem(device.Name); + joysticksToolStripMenuItem.DropDownItems.Add(item); + } + + hasConnectedMidiBoards = true; } + + RefreshConnectedDevicesIcon(); } private void ExecManager_OnSimAircraftChanged(object sender, string aircraftName) @@ -1231,9 +1264,15 @@ private void UpdateStatusBarModuleInformation() Enabled = false }; modulesToolStripMenuItem.DropDownItems.Add(item); - return; + + hasConnectedModules = false; + } + else + { + hasConnectedModules = true; } + RefreshConnectedDevicesIcon(); } private void statusToolStripMenuItemClick(object sender, EventArgs e) diff --git a/UI/MainForm.resx b/UI/MainForm.resx index eeb67fae..e56ae3d6 100644 --- a/UI/MainForm.resx +++ b/UI/MainForm.resx @@ -455,7 +455,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABm - PgAAAk1TRnQBSQFMAgEBBAEAAVgBAQFYAQEBGAEAARgBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFg + PgAAAk1TRnQBSQFMAgEBBAEAAWABAQFgAQEBGAEAARgBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFg AwABMAMAAQEBAAEgBgABSP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/ADYAAcwBZgEzAf8BzAFmATMB/wHMAWYBMwH/AcwBZgEz Af8BzAFmATMB/wHMAWYBMwH/Ac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uq6qy/4Ll+gqLRmZl809edguD7zsF+1qnuGigK ACCFstaM0xeccv77WfUJ6hsYwZ+yZLMNX6ypt/6wprbwzeraxu9qm+JMbeEpPULwZhq0aP3mqnzhHI8U - ACDCnDbabaudNtv5/1vcNlxtudOmO/9drzZeO/CpzVfb73UDKc2KFf8fdhI4Mpk5nJ0AAAAASUVORK5C + ACDCnDbabaudNtv5/1vcNlxtudOmO/9drzZeO/CpzVfb73UDKc2KFf8fuT44JzqZCk0AAAAASUVORK5C YII= @@ -7471,6 +7471,12 @@ Connected devices + + 16, 17 + + + Not Found + False @@ -7556,28 +7562,28 @@ Not Found - 180, 22 + 161, 22 No Sim Running - 177, 6 + 158, 6 - 180, 22 + 161, 22 FSUIPC - 180, 22 + 161, 22 SimConnect - 180, 22 + 161, 22 X-Plane (direct) @@ -7676,7 +7682,7 @@ | - 542, 17 + 526, 17 Status Info... @@ -8626,6 +8632,12 @@ System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolStripConnectedDevicesIcon + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MainForm