-
Notifications
You must be signed in to change notification settings - Fork 27
/
MemberSelectorEditorDialog.cs
56 lines (52 loc) · 1.77 KB
/
MemberSelectorEditorDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Windows.Forms;
namespace Bonsai.Design
{
/// <summary>
/// Represents a dialog for selecting members of a workflow expression type.
/// </summary>
public partial class MemberSelectorEditorDialog : Form, IMemberSelectorEditorDialog
{
readonly MemberSelectorEditorController controller;
/// <summary>
/// Initializes a new instance of the <see cref="MemberSelectorEditorDialog"/> class
/// using the specified type.
/// </summary>
/// <param name="type">The type from which to select an inner property.</param>
public MemberSelectorEditorDialog(Type type)
{
InitializeComponent();
controller = new MemberSelectorEditorController(treeView, type);
}
/// <summary>
/// Gets or sets the selected inner property of the expression type.
/// </summary>
public string Selector
{
get
{
return controller.GetSelectedMember();
}
set
{
if (!string.IsNullOrEmpty(value))
{
var memberChain = value.Split(new[] { ExpressionHelper.MemberSeparator }, StringSplitOptions.RemoveEmptyEntries);
controller.InitializeSelection(memberChain);
}
else
{
if (treeView.Nodes.Count == 1) treeView.ExpandAll();
else treeView.CollapseAll();
treeView.SelectedNode = null;
}
}
}
/// <inheritdoc/>
protected override void OnFormClosed(FormClosedEventArgs e)
{
controller.Dispose();
base.OnFormClosed(e);
}
}
}