From f8ab7223158b7cef1e58e07aa73ccfcdee59194c Mon Sep 17 00:00:00 2001 From: Sebastian M Date: Sun, 4 Dec 2022 03:57:57 -0600 Subject: [PATCH] Upload config button activates correctly (#1024) --- UI/Panels/Settings/MobiFlightPanel.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/UI/Panels/Settings/MobiFlightPanel.cs b/UI/Panels/Settings/MobiFlightPanel.cs index 98aa9b459..5866c724d 100644 --- a/UI/Panels/Settings/MobiFlightPanel.cs +++ b/UI/Panels/Settings/MobiFlightPanel.cs @@ -222,15 +222,20 @@ private void mfModulesTreeView_AfterSelect(object sender, TreeViewEventArgs e) mfSettingsPanel.Controls.Clear(); if (moduleNode.Tag == null) return; + UpdateToolbarAndPanelAfterNodeHasChanged(moduleNode); + } + + private void UpdateToolbarAndPanelAfterNodeHasChanged(TreeNode moduleNode) + { MobiFlightModule module = (moduleNode.Tag as MobiFlightModule); bool isMobiFlightBoard = module.HasMfFirmware(); mobiflightSettingsToolStrip.Enabled = moduleNode.ImageKey != "module-ignored"; - + // this is the module node // set the add device icon enabled addDeviceToolStripDropDownButton.Enabled = isMobiFlightBoard; - removeDeviceToolStripButton.Enabled = isMobiFlightBoard & (e.Node.Level > 0); + removeDeviceToolStripButton.Enabled = isMobiFlightBoard & (moduleNode.Level > 0); uploadToolStripButton.Enabled = isMobiFlightBoard && ((moduleNode.Nodes.Count > 0) || (moduleNode.ImageKey == "Changed")); openToolStripButton.Enabled = isMobiFlightBoard; saveToolStripButton.Enabled = isMobiFlightBoard && moduleNode.Nodes.Count > 0; @@ -273,7 +278,7 @@ private void mfModulesTreeView_AfterSelect(object sender, TreeViewEventArgs e) var boards = BoardDefinitions.GetBoardsByHardwareId(module.HardwareId); if (boards.Count > 0) { - + foreach (var board in boards) { ToolStripMenuItem item = CreateFirmwareUploadMenuItem(module, board); @@ -284,13 +289,14 @@ private void mfModulesTreeView_AfterSelect(object sender, TreeViewEventArgs e) } UpdateFirmwareToolStripButton.ShowDropDownArrow = true; } - } else + } + else { updateFirmwareToolStripMenuItem.Click += this.updateFirmwareToolStripMenuItem_Click; UpdateFirmwareToolStripButton.Click += this.updateFirmwareToolStripMenuItem_Click; } - syncPanelWithSelectedDevice(e.Node); + syncPanelWithSelectedDevice(moduleNode); } private ToolStripMenuItem CreateFirmwareUploadMenuItem(MobiFlightModule module, Board board) @@ -848,6 +854,8 @@ private void openToolStripButton_Click(object sender, EventArgs e) moduleNode.ImageKey = "Changed"; moduleNode.SelectedImageKey = "Changed"; + moduleNode.Expand(); + UpdateToolbarAndPanelAfterNodeHasChanged(moduleNode); } }