Skip to content

Commit

Permalink
Bring back the icon (#1895)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilenns authored Jan 5, 2025
1 parent fead2d1 commit 1df9968
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 22 deletions.
10 changes: 10 additions & 0 deletions UI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 50 additions & 11 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public partial class MainForm : Form
private Dictionary<string, string> AutoLoadConfigs = new Dictionary<string, string>();
public event EventHandler<string> 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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
34 changes: 23 additions & 11 deletions UI/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABm
PgAAAk1TRnQBSQFMAgEBBAEAAVgBAQFYAQEBGAEAARgBAAT/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N8MAACSzukDtaVvxXf1q0Sq6gp/XrXa
6ja+MQAAJFZjn9P5f8PrDtMZbWnovBG7zW8QAADJkqm1XtTjcK8bJNV1Td+qzjcMmN4sAABi7x5ruCZf
+LbX7ZHr4w4QzBe2G984AADi6Op4t63fvef073jdHVkoNfWFP6nON74/700EACBOahs/qcoX/szr3kgx
yWbtX8jkrH9y3sCeeW8oAAARpgHuTh/2f9WXed0aKTU3b7R+Rc9MVq4u9JreZAAAouJ7a6xB7YGTWdfx
Expand All @@ -7354,7 +7354,7 @@
O6dvqco37tPg9Js3Wr/pdT8kSqmpb/5KVd76jlOdve4csAnjgQQAYEmN49U561XnA+a/atVar5shcYhG
YVbnmv7SOXjrq++xPvqHvHXJfJABAGmnPkLjy5wPkeuq6qy/4Ll+gqLRmZl809edguD7zsF+1qnuGigK
ACCFstaM0xeccv77WfUJ6hsYwZ+yZLMNX6ypt/6wprbwzeraxu9qm+JMbeEpPULwZhq0aP3mqnzhHI8U
ACDCnDbabaudNtv5/1vcNlxtudOmO/9drzZeO/CpzVfb73UDKc2KFf8fdhI4Mpk5nJ0AAAAASUVORK5C
ACDCnDbabaudNtv5/1vcNlxtudOmO/9drzZeO/CpzVfb73UDKc2KFf8fuT44JzqZCk0AAAAASUVORK5C
YII=
</value>
</data>
Expand Down Expand Up @@ -7471,6 +7471,12 @@
<data name="connectedDevicesToolStripLabel.Text" xml:space="preserve">
<value>Connected devices</value>
</data>
<data name="toolStripConnectedDevicesIcon.Size" type="System.Drawing.Size, System.Drawing">
<value>16, 17</value>
</data>
<data name="toolStripConnectedDevicesIcon.Text" xml:space="preserve">
<value>Not Found</value>
</data>
<data name="noneToolStripMenuItem1.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
Expand Down Expand Up @@ -7556,28 +7562,28 @@
<value>Not Found</value>
</data>
<data name="SimProcessDetectedToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>161, 22</value>
</data>
<data name="SimProcessDetectedToolStripMenuItem.Text" xml:space="preserve">
<value>No Sim Running</value>
</data>
<data name="separatorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
<value>158, 6</value>
</data>
<data name="FsuipcToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>161, 22</value>
</data>
<data name="FsuipcToolStripMenuItem.Text" xml:space="preserve">
<value>FSUIPC</value>
</data>
<data name="simConnectToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>161, 22</value>
</data>
<data name="simConnectToolStripMenuItem.Text" xml:space="preserve">
<value>SimConnect</value>
</data>
<data name="xPlaneDirectToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>161, 22</value>
</data>
<data name="xPlaneDirectToolStripMenuItem.Text" xml:space="preserve">
<value>X-Plane (direct)</value>
Expand Down Expand Up @@ -7676,7 +7682,7 @@
<value>|</value>
</data>
<data name="toolStripStatusLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>542, 17</value>
<value>526, 17</value>
</data>
<data name="toolStripStatusLabel.Text" xml:space="preserve">
<value>Status Info...</value>
Expand Down Expand Up @@ -8626,6 +8632,12 @@
<data name="&gt;&gt;dataGridViewTextBoxColumn4.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripConnectedDevicesIcon.Name" xml:space="preserve">
<value>toolStripConnectedDevicesIcon</value>
</data>
<data name="&gt;&gt;toolStripConnectedDevicesIcon.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainForm</value>
</data>
Expand Down

0 comments on commit 1df9968

Please sign in to comment.