aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml.cs
blob: f24cdb9af3432405d3cb405b2eb76de47b841d4a (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Core;
using Tango.SharedUI;

namespace Tango.SharedUI.Editors
{
    /// <summary>
    /// <para><img class="classImage" src="../Media/ParameterizedEditor.png" /></para>
    /// Represents a scrollable list of auto generated editable controls for objects which inherits from <see cref="IParameterized"/>.
    /// </summary>
    /// <remarks>
    /// <para>
    /// The following types are natively supported for display and edit:
    /// </para>
    /// <list type="bullet">
    /// <item>Double</item>
    /// <item>Single</item>
    /// <item>Int32</item>
    /// <item>Boolean</item>
    /// <item>String</item>
    /// <item>Point</item>
    /// <item>Enum</item>
    /// <item>Color</item>
    /// <item>Brush</item>
    /// </list>
    /// <para>
    /// See <see cref="IParameterItemEditor"/> to implement other property types using custom editors.
    /// </para>
    /// </remarks>
    /// <example>
    /// <para class="example-title">
    /// <img class="exampleIcon" src="../Icons/CodeExample.png" />
    /// <i>
    /// The following example demonstrates how to implement the IParameterized interface, implement a custom parameter editor and use the ParameterizedEditor to display/edit the object.
    /// </i>
    /// </para>
    /// <para><img class="exampleImage" src="../Media/ParameterizedEditorExample.png" /></para>
    /// <i>Implement IParameterized.</i>
    /// <code lang="C#" source="../FullAPIExamples/Examples/Core/IParameterizedExample.cs" title="Implement IParameterized interface." />
    /// <i>Custom editor.</i>
    /// <code lang="XAML" source="../FullAPIExamples/Examples/Core/CustomEditor.xaml" title="Implement custom editor." />
    /// <i>Custom editor code behind.</i>
    /// <code lang="C#" source="../FullAPIExamples/Examples/Core/CustomEditor.xaml.cs" title="Implement custom editor." />
    /// <i>Use the ParameterizedEditor to display the parameterized object.</i>
    /// <code lang="XAML" source="../FullAPIExamples/Examples/Core/ParameterizedEditorExample.xaml" title="Use ParameterizedEditor." />
    /// <i>Code-Behind.</i>
    /// <code lang="C#" source="../FullAPIExamples/Examples/Core/ParameterizedEditorExample.xaml.cs" title="Use ParameterizedEditor." />
    /// </example>
    /// <seealso cref="Tango.SharedUI.HybridControl" />
    public partial class ParameterizedEditor : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterizedEditor"/> class.
        /// </summary>
        public ParameterizedEditor()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the parameterized object.
        /// </summary>
        public IParameterized ParameterizedObject
        {
            get { return (IParameterized)GetValue(ParameterizedObjectProperty); }
            set { SetValue(ParameterizedObjectProperty, value); }
        }
        public static readonly DependencyProperty ParameterizedObjectProperty =
            DependencyProperty.Register("ParameterizedObject", typeof(IParameterized), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets a single item padding.
        /// </summary>
        public Thickness ItemPadding
        {
            get { return (Thickness)GetValue(ItemPaddingProperty); }
            set { SetValue(ItemPaddingProperty, value); }
        }
        public static readonly DependencyProperty ItemPaddingProperty =
            DependencyProperty.Register("ItemPadding", typeof(Thickness), typeof(ParameterizedEditor), new PropertyMetadata(new Thickness()));

        /// <summary>
        /// Gets or sets a single item margin.
        /// </summary>
        public Thickness ItemMargin
        {
            get { return (Thickness)GetValue(ItemMarginProperty); }
            set { SetValue(ItemMarginProperty, value); }
        }
        public static readonly DependencyProperty ItemMarginProperty =
            DependencyProperty.Register("ItemMargin", typeof(Thickness), typeof(ParameterizedEditor), new PropertyMetadata(new Thickness()));

        /// <summary>
        /// Gets or sets a single item minimum height.
        /// </summary>
        public double ItemMinHeight
        {
            get { return (double)GetValue(ItemMinHeightProperty); }
            set { SetValue(ItemMinHeightProperty, value); }
        }
        public static readonly DependencyProperty ItemMinHeightProperty =
            DependencyProperty.Register("ItemMinHeight", typeof(double), typeof(ParameterizedEditor), new PropertyMetadata(0.0));

        /// <summary>
        /// Gets or sets a single item label margin.
        /// </summary>
        public Thickness ItemLabelMargin
        {
            get { return (Thickness)GetValue(ItemLabelMarginProperty); }
            set { SetValue(ItemLabelMarginProperty, value); }
        }
        public static readonly DependencyProperty ItemLabelMarginProperty =
            DependencyProperty.Register("ItemLabelMargin", typeof(Thickness), typeof(ParameterizedEditor), new PropertyMetadata(new Thickness()));

        #region Templates

        /// <summary>
        /// Gets or sets the double template.
        /// </summary>
        public DataTemplate DoubleTemplate
        {
            get { return (DataTemplate)GetValue(DoubleTemplateProperty); }
            set { SetValue(DoubleTemplateProperty, value); }
        }
        public static readonly DependencyProperty DoubleTemplateProperty =
            DependencyProperty.Register("DoubleTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the int32 template.
        /// </summary>
        public DataTemplate Int32Template
        {
            get { return (DataTemplate)GetValue(Int32TemplateProperty); }
            set { SetValue(Int32TemplateProperty, value); }
        }
        public static readonly DependencyProperty Int32TemplateProperty =
            DependencyProperty.Register("Int32Template", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the single template.
        /// </summary>
        public DataTemplate SingleTemplate
        {
            get { return (DataTemplate)GetValue(SingleTemplateProperty); }
            set { SetValue(SingleTemplateProperty, value); }
        }
        public static readonly DependencyProperty SingleTemplateProperty =
            DependencyProperty.Register("SingleTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the double up down template.
        /// </summary>
        public DataTemplate DoubleUpDownTemplate
        {
            get { return (DataTemplate)GetValue(DoubleUpDownTemplateProperty); }
            set { SetValue(DoubleUpDownTemplateProperty, value); }
        }
        public static readonly DependencyProperty DoubleUpDownTemplateProperty =
            DependencyProperty.Register("DoubleUpDownTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the boolean template.
        /// </summary>
        public DataTemplate BooleanTemplate
        {
            get { return (DataTemplate)GetValue(BooleanTemplateProperty); }
            set { SetValue(BooleanTemplateProperty, value); }
        }
        public static readonly DependencyProperty BooleanTemplateProperty =
            DependencyProperty.Register("BooleanTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the enum template.
        /// </summary>
        public DataTemplate EnumTemplate
        {
            get { return (DataTemplate)GetValue(EnumTemplateProperty); }
            set { SetValue(EnumTemplateProperty, value); }
        }
        public static readonly DependencyProperty EnumTemplateProperty =
            DependencyProperty.Register("EnumTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the color template.
        /// </summary>
        public DataTemplate ColorTemplate
        {
            get { return (DataTemplate)GetValue(ColorTemplateProperty); }
            set { SetValue(ColorTemplateProperty, value); }
        }
        public static readonly DependencyProperty ColorTemplateProperty =
            DependencyProperty.Register("ColorTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the brush template.
        /// </summary>
        public DataTemplate BrushTemplate
        {
            get { return (DataTemplate)GetValue(BrushTemplateProperty); }
            set { SetValue(BrushTemplateProperty, value); }
        }
        public static readonly DependencyProperty BrushTemplateProperty =
            DependencyProperty.Register("BrushTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the point template.
        /// </summary>
        public DataTemplate PointTemplate
        {
            get { return (DataTemplate)GetValue(PointTemplateProperty); }
            set { SetValue(PointTemplateProperty, value); }
        }
        public static readonly DependencyProperty PointTemplateProperty =
            DependencyProperty.Register("PointTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the string template.
        /// </summary>
        public DataTemplate StringTemplate
        {
            get { return (DataTemplate)GetValue(StringTemplateProperty); }
            set { SetValue(StringTemplateProperty, value); }
        }
        public static readonly DependencyProperty StringTemplateProperty =
            DependencyProperty.Register("StringTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null));
        
        #endregion
    }
}