Skip to content

Commit

Permalink
Upload config button activates correctly (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
DocMoebiuz authored Dec 4, 2022
1 parent 3c15eec commit f8ab722
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions UI/Panels/Settings/MobiFlightPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -848,6 +854,8 @@ private void openToolStripButton_Click(object sender, EventArgs e)

moduleNode.ImageKey = "Changed";
moduleNode.SelectedImageKey = "Changed";
moduleNode.Expand();
UpdateToolbarAndPanelAfterNodeHasChanged(moduleNode);
}
}

Expand Down

0 comments on commit f8ab722

Please sign in to comment.