Skip to content

Commit

Permalink
Open peripherals page on connected device selection (#1899)
Browse files Browse the repository at this point in the history
* Open perhipherals page on connected device selection
Fixes #1897

* Fix spelling
  • Loading branch information
neilenns authored Jan 5, 2025
1 parent 1df9968 commit d36f737
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion UI/Dialogs/SettingsDialog.Designer.cs

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

27 changes: 17 additions & 10 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private void MainForm_Shown(object sender, EventArgs e)

private void RefreshConnectedDevicesIcon()
{
if (hasConnectedJoysticks || hasConnectedMidiBoards || hasConnectedMidiBoards)
if (hasConnectedJoysticks || hasConnectedMidiBoards || hasConnectedModules)
{
toolStripConnectedDevicesIcon.Image = Properties.Resources.check;
}
Expand All @@ -287,10 +287,8 @@ private void ExecManager_OnJoystickConnectedFinished(object sender, EventArgs e)

if (joysticks.Count == 0)
{
var item = new ToolStripMenuItem(i18n._tr("uiNone"))
{
Enabled = false
};
var item = new ToolStripMenuItem(i18n._tr("uiNone"));
item.Click += peripheralsToolStripMenuItemClick;
joysticksToolStripMenuItem.DropDownItems.Add(item);

hasConnectedJoysticks = false;
Expand All @@ -300,6 +298,7 @@ private void ExecManager_OnJoystickConnectedFinished(object sender, EventArgs e)
foreach (var joystick in joysticks)
{
var item = new ToolStripMenuItem(joystick.Name);
item.Click += peripheralsToolStripMenuItemClick;
joysticksToolStripMenuItem.DropDownItems.Add(item);
}

Expand All @@ -319,8 +318,9 @@ private void ExecManager_OnMidiBoardConnectedFinished(object sender, EventArgs e
{
var item = new ToolStripMenuItem(i18n._tr("uiNone"))
{
Enabled = false
Enabled = true
};
item.Click += peripheralsToolStripMenuItemClick;
joysticksToolStripMenuItem.DropDownItems.Add(item);

hasConnectedMidiBoards = false;
Expand All @@ -330,6 +330,7 @@ private void ExecManager_OnMidiBoardConnectedFinished(object sender, EventArgs e
foreach (var device in devices)
{
var item = new ToolStripMenuItem(device.Name);
item.Click += peripheralsToolStripMenuItemClick;
joysticksToolStripMenuItem.DropDownItems.Add(item);
}

Expand Down Expand Up @@ -697,6 +698,9 @@ private DialogResult ShowSettingsDialog(String SelectedTab, MobiFlightModuleInfo
case "ArcazeTabPage":
dlg.tabControl1.SelectedTab = dlg.ArcazeTabPage;
break;
case "peripheralsTabPage":
dlg.tabControl1.SelectedTab = dlg.peripheralsTabPage;
break;
}
if (SelectedBoard != null)
dlg.PreselectedBoard = SelectedBoard;
Expand Down Expand Up @@ -1259,11 +1263,9 @@ private void UpdateStatusBarModuleInformation()

if ((modules.Count() + mfModules.Count()) == 0)
{
var item = new ToolStripMenuItem(i18n._tr("uiNone"))
{
Enabled = false
};
var item = new ToolStripMenuItem(i18n._tr("uiNone"));
modulesToolStripMenuItem.DropDownItems.Add(item);
item.Click += statusToolStripMenuItemClick;

hasConnectedModules = false;
}
Expand All @@ -1282,6 +1284,11 @@ private void statusToolStripMenuItemClick(object sender, EventArgs e)
ShowSettingsDialog("mobiFlightTabPage", moduleInfo, null, null);
}

private void peripheralsToolStripMenuItemClick(object sender, EventArgs e)
{
ShowSettingsDialog("peripheralsTabPage", null, null, null);
}

/// <summary>
/// toggles the current timer when user clicks on respective run/stop buttons
/// </summary>
Expand Down

0 comments on commit d36f737

Please sign in to comment.