From 3aeef2470c7c926ee2218710238ef5bee3a8204a Mon Sep 17 00:00:00 2001 From: glopesdev Date: Thu, 1 Dec 2022 11:50:11 +0000 Subject: [PATCH] Update browsable attributes on selection change --- Bonsai.Editor/EditorForm.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Bonsai.Editor/EditorForm.cs b/Bonsai.Editor/EditorForm.cs index bc99b4db1..929b86a74 100644 --- a/Bonsai.Editor/EditorForm.cs +++ b/Bonsai.Editor/EditorForm.cs @@ -72,6 +72,7 @@ public partial class EditorForm : Form readonly List workflowExtensions; readonly WorkflowRuntimeExceptionCache exceptionCache; readonly string definitionsPath; + AttributeCollection browsableAttributes; DirectoryInfo extensionsPath; WorkflowBuilder workflowBuilder; WorkflowException workflowError; @@ -169,7 +170,7 @@ public EditorForm( editorControl.Workflow = workflowBuilder.Workflow; editorControl.Dock = DockStyle.Fill; workflowSplitContainer.Panel1.Controls.Add(editorControl); - propertyGrid.BrowsableAttributes = DesignTimeAttributes; + propertyGrid.BrowsableAttributes = browsableAttributes = DesignTimeAttributes; propertyGrid.LineColor = SystemColors.InactiveBorder; propertyGrid.Site = editorSite; @@ -1155,7 +1156,6 @@ IDisposable ShutdownSequence() return new ScheduledDisposable(new ControlScheduler(this), Disposable.Create(() => { editorSite.OnWorkflowStopped(EventArgs.Empty); - propertyGrid.BrowsableAttributes = DesignTimeAttributes; undoToolStripButton.Enabled = undoToolStripMenuItem.Enabled = commandExecutor.CanUndo; redoToolStripButton.Enabled = redoToolStripMenuItem.Enabled = commandExecutor.CanRedo; toolboxTreeView.Enabled = true; @@ -1205,7 +1205,6 @@ void StartWorkflow(bool debug) { statusTextLabel.Text = Resources.RunningStatus; statusImageLabel.Image = statusRunningImage; - propertyGrid.BrowsableAttributes = RuntimeAttributes; editorSite.OnWorkflowStarted(EventArgs.Empty); Activate(); })); @@ -1632,6 +1631,13 @@ private void UpdatePropertyGrid() enableToolStripMenuItem.Enabled = canEdit && hasSelectedObjects; disableToolStripMenuItem.Enabled = canEdit && hasSelectedObjects; + var selectionBrowsableAttributes = canEdit ? DesignTimeAttributes : RuntimeAttributes; + if (browsableAttributes != selectionBrowsableAttributes) + { + browsableAttributes = selectionBrowsableAttributes; + propertyGrid.BrowsableAttributes = browsableAttributes; + } + string displayName, description; if (!hasSelectedObjects && selectedView != null) {