Skip to content

Commit

Permalink
Merge pull request #196 from SainsburyWellcomeCentre/aeon-environment
Browse files Browse the repository at this point in the history
Add property grid view configuration properties
  • Loading branch information
glopesdev authored Dec 17, 2023
2 parents e95ff2f + e4c7d29 commit a770efe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Aeon.Environment/Aeon.Environment.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageTags>Bonsai Rx Project Aeon Environment</PackageTags>
<TargetFramework>net472</TargetFramework>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionSuffix>build231208</VersionSuffix>
<VersionSuffix>build231209</VersionSuffix>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/Aeon.Environment/ExperimentProperties.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Bonsai;
using Bonsai.Expressions;
using System.ComponentModel;

namespace Aeon.Environment
{
[TypeVisualizer(typeof(ExternalizedPropertiesVisualizer))]
[Description("Provides a configurable visualizer for global workflow properties.")]
public class ExperimentProperties : UnitBuilder
{
[Description("Specifies whether the help text box is visible.")]
public bool HelpVisible { get; set; } = true;

[Description("Specifies whether the toolbar is visible.")]
public bool ToolbarVisible { get; set; } = true;
}
}
6 changes: 6 additions & 0 deletions src/Aeon.Environment/ExperimentPropertiesVisualizer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Bonsai;
using Bonsai.Design;
using Bonsai.Expressions;
using System;
using System.Drawing;

Expand All @@ -12,8 +13,13 @@ public sealed class ExternalizedPropertiesVisualizer : DialogTypeVisualizer
public override void Load(IServiceProvider provider)
{
var workflowBuilder = (WorkflowBuilder)provider.GetService(typeof(WorkflowBuilder));
var context = (ITypeVisualizerContext)provider.GetService(typeof(ITypeVisualizerContext));
var visualizerElement = ExpressionBuilder.GetVisualizerElement(context.Source);
var source = (ExperimentProperties)ExpressionBuilder.GetWorkflowElement(visualizerElement.Builder);

control = new PropertyGrid();
control.HelpVisible = source.HelpVisible;
control.ToolbarVisible = source.ToolbarVisible;
control.Font = new Font(control.Font.FontFamily, 16.2F);
control.Dock = System.Windows.Forms.DockStyle.Fill;
control.SelectedObject = workflowBuilder.Workflow;
Expand Down

0 comments on commit a770efe

Please sign in to comment.