-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from bonsai-rx/feature-dev
Add group box and tab control containers
- Loading branch information
Showing
6 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Bonsai.Gui | ||
{ | ||
/// <summary> | ||
/// Represents an operator that specifies a mashup visualizer that displays a frame | ||
/// around a group of other visualizers with an optional caption. | ||
/// </summary> | ||
[TypeVisualizer(typeof(GroupBoxVisualizer))] | ||
[Description("Specifies a mashup visualizer that displays a frame around a group of other visualizers with an optional caption.")] | ||
public class GroupBoxBuilder : TextControlBuilderBase | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Windows.Forms; | ||
using Bonsai.Design; | ||
using Bonsai.Gui; | ||
using Bonsai; | ||
|
||
[assembly: TypeVisualizer(typeof(DialogTypeVisualizer), Target = typeof(MashupSource<GroupBoxVisualizer>))] | ||
|
||
namespace Bonsai.Gui | ||
{ | ||
/// <summary> | ||
/// Provides a type visualizer that displays a frame around a group of other | ||
/// visualizers with an optional caption. | ||
/// </summary> | ||
public class GroupBoxVisualizer : ContainerControlVisualizerBase<GroupBox, GroupBoxBuilder> | ||
{ | ||
/// <inheritdoc/> | ||
protected override void AddControl(int index, Control control) | ||
{ | ||
Control.Controls.Add(control); | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override GroupBox CreateControl(IServiceProvider provider, GroupBoxBuilder builder) | ||
{ | ||
var groupBox = new GroupBox(); | ||
groupBox.Dock = DockStyle.Fill; | ||
groupBox.Size = new Size(320, 240); | ||
groupBox.SubscribeTo(builder._Text, value => groupBox.Text = value); | ||
return groupBox; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Bonsai.Gui | ||
{ | ||
/// <summary> | ||
/// Represents an operator that specifies a mashup visualizer that can be used | ||
/// to arrange other visualizers using a related set of tab pages. | ||
/// </summary> | ||
[TypeVisualizer(typeof(TabControlVisualizer))] | ||
[Description("Specifies a mashup visualizer that can be used to arrange other visualizers using a related set of tab pages.")] | ||
public class TabControlBuilder : ControlBuilderBase | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Bonsai.Design; | ||
using Bonsai.Gui; | ||
using Bonsai; | ||
using System.Windows.Forms; | ||
using System.Drawing; | ||
|
||
[assembly: TypeVisualizer(typeof(DialogTypeVisualizer), Target = typeof(MashupSource<TabControlVisualizer>))] | ||
|
||
namespace Bonsai.Gui | ||
{ | ||
/// <summary> | ||
/// Provides a type visualizer that can be used to arrange other visualizers | ||
/// using a related set of tab pages. | ||
/// </summary> | ||
public class TabControlVisualizer : ContainerControlVisualizerBase<TabControl, TabControlBuilder> | ||
{ | ||
/// <inheritdoc/> | ||
protected override TabControl CreateControl(IServiceProvider provider, TabControlBuilder builder) | ||
{ | ||
var tabControl = new TabControl(); | ||
tabControl.Dock = DockStyle.Fill; | ||
tabControl.Size = new Size(320, 240); | ||
return tabControl; | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void AddControl(int index, Control control) | ||
{ | ||
var tabPage = new TabPage(control.Name); | ||
tabPage.Controls.Add(control); | ||
Control.Controls.Add(tabPage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.ComponentModel; | ||
using System.Reactive.Subjects; | ||
|
||
namespace Bonsai.Gui | ||
{ | ||
/// <summary> | ||
/// Provides an abstract base class for common UI text control functionality. | ||
/// </summary> | ||
[DefaultProperty(nameof(Text))] | ||
public abstract class TextControlBuilderBase : ControlBuilderBase | ||
{ | ||
internal readonly BehaviorSubject<string> _Text = new(string.Empty); | ||
|
||
/// <summary> | ||
/// Gets or sets the text associated with this control. | ||
/// </summary> | ||
[Category(nameof(CategoryAttribute.Appearance))] | ||
[Description("The text associated with this control.")] | ||
public string Text | ||
{ | ||
get => _Text.Value; | ||
set => _Text.OnNext(value); | ||
} | ||
} | ||
} |