Simplify with tuples

This commit is contained in:
jlewin 2019-05-09 17:26:59 -07:00
parent d6b60e6149
commit 5830f7efb3

View file

@ -62,15 +62,13 @@ namespace MatterHackers.MatterControl
}
// Ensure all or only the active stage is enabled
foreach (var kvp in rowsByStage)
foreach (var (stage, widget) in rowsByStage.Select(x => (x.Key, x.Value))) // project to tuple - deconstruct to named items
{
ISetupWizard stage = kvp.Key;
bool isActiveStage = stage == value;
bool noActiveStage = value == null;
// Enable GuiWidget when no stage is active or when the current stage is active and enabled
var widget = kvp.Value;
widget.Enabled = noActiveStage || isActiveStage;
widget.Enabled = stage.Enabled && (noActiveStage || isActiveStage);
}
// Shutdown the active Wizard