From d36f737c3884a170813be4781e86bf641a538d25 Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Sun, 5 Jan 2025 15:52:54 -0800 Subject: [PATCH] Open peripherals page on connected device selection (#1899) * Open perhipherals page on connected device selection Fixes #1897 * Fix spelling --- UI/Dialogs/SettingsDialog.Designer.cs | 2 +- UI/MainForm.cs | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/UI/Dialogs/SettingsDialog.Designer.cs b/UI/Dialogs/SettingsDialog.Designer.cs index da47a1be..818166f6 100644 --- a/UI/Dialogs/SettingsDialog.Designer.cs +++ b/UI/Dialogs/SettingsDialog.Designer.cs @@ -385,7 +385,7 @@ private void InitializeComponent() private Panels.Settings.ArcazePanel arcazePanel; private Panels.Settings.MobiFlightPanel mobiFlightPanel; private System.Windows.Forms.ToolStripMenuItem analogDeviceToolStripMenuItem; - private System.Windows.Forms.TabPage peripheralsTabPage; + public System.Windows.Forms.TabPage peripheralsTabPage; private Panels.Settings.PeripheralsPanel peripheralsPanel; } } \ No newline at end of file diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 1fa10077..0a996dbd 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -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; } @@ -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; @@ -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); } @@ -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; @@ -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); } @@ -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; @@ -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; } @@ -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); + } + /// /// toggles the current timer when user clicks on respective run/stop buttons ///