diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 13:22:53 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 13:22:53 +0300 |
| commit | c6b01f3e683b83fb0d6bf080efbd24a9a732b9f5 (patch) | |
| tree | 900238695f8c1e0e2ea1f5786e3b847fcfa1ba43 /Software/Visual_Studio/Tango.Editors | |
| parent | df9b2580669472d446e109dff88bdfa247b23b1e (diff) | |
| download | Tango-c6b01f3e683b83fb0d6bf080efbd24a9a732b9f5.tar.gz Tango-c6b01f3e683b83fb0d6bf080efbd24a9a732b9f5.zip | |
Implemented process parameters item on machine studio tech board.
Diffstat (limited to 'Software/Visual_Studio/Tango.Editors')
11 files changed, 7 insertions, 515 deletions
diff --git a/Software/Visual_Studio/Tango.Editors/CustomScrollViewer.cs b/Software/Visual_Studio/Tango.Editors/CustomScrollViewer.cs index e70c374ed..87ba8f0ca 100644 --- a/Software/Visual_Studio/Tango.Editors/CustomScrollViewer.cs +++ b/Software/Visual_Studio/Tango.Editors/CustomScrollViewer.cs @@ -38,7 +38,10 @@ namespace Tango.Editors protected override void OnPreviewKeyDown(KeyEventArgs e) { - e.Handled = true; + if (e.Key == Key.Up || e.Key == Key.Down || e.Key == Key.Right || e.Key == Key.Left) + { + e.Handled = true; + } } protected virtual void OnMouseZooming(MouseWheelEventArgs e) diff --git a/Software/Visual_Studio/Tango.Editors/ElementEditor.cs b/Software/Visual_Studio/Tango.Editors/ElementEditor.cs index 5d90a2b4c..8dfb9000a 100644 --- a/Software/Visual_Studio/Tango.Editors/ElementEditor.cs +++ b/Software/Visual_Studio/Tango.Editors/ElementEditor.cs @@ -13,6 +13,7 @@ using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Animation; +using Tango.Core; using Tango.Editors; namespace Tango.Editors diff --git a/Software/Visual_Studio/Tango.Editors/FrameworkElementEditor.xaml.cs b/Software/Visual_Studio/Tango.Editors/FrameworkElementEditor.xaml.cs index 655edb27c..7e287676c 100644 --- a/Software/Visual_Studio/Tango.Editors/FrameworkElementEditor.xaml.cs +++ b/Software/Visual_Studio/Tango.Editors/FrameworkElementEditor.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Core; using Tango.Editors; namespace Tango.Editors diff --git a/Software/Visual_Studio/Tango.Editors/IElementEditor.cs b/Software/Visual_Studio/Tango.Editors/IElementEditor.cs index dfe539537..eaff358a2 100644 --- a/Software/Visual_Studio/Tango.Editors/IElementEditor.cs +++ b/Software/Visual_Studio/Tango.Editors/IElementEditor.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls.Primitives; +using Tango.Core; using Tango.Editors; namespace Tango.Editors diff --git a/Software/Visual_Studio/Tango.Editors/IParameterized.cs b/Software/Visual_Studio/Tango.Editors/IParameterized.cs deleted file mode 100644 index d0a32f209..000000000 --- a/Software/Visual_Studio/Tango.Editors/IParameterized.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Editors -{ - /// <summary> - /// Represents a component that exposes some of it's properties as an observable collection of <see cref="ParameterItem"/> which can be bound to UI controls. - /// <para> - /// Use the <see cref="T:WpfVideoTools.Editors.ParameterizedEditor"/> to automatically display and edit the collection of parameters. - /// </para> - /// <para> - /// See - /// </para> - /// <list type="bullet"> - /// <item><see cref="T:WpfVideoTools.Editors.ParameterizedEditor"/></item> - /// <item><see cref="T:WpfVideoTools.Editors.IParameterItemEditor"/></item> - /// </list> - /// </summary> - /// <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="T:WpfVideoTools.Editors.ParameterizedEditor" /> - /// <seealso cref="T:WpfVideoTools.Editors.IParameterItemEditor" /> - public interface IParameterized - { - /// <summary> - /// Gets a bind-able observable collection of the component properties. - /// </summary> - [ParameterIgnore] - ReadOnlyObservableCollection<ParameterItem> Parameters { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Editors/IParameterizedExtensions.cs b/Software/Visual_Studio/Tango.Editors/IParameterizedExtensions.cs deleted file mode 100644 index d238cd297..000000000 --- a/Software/Visual_Studio/Tango.Editors/IParameterizedExtensions.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using Tango.Editors; - -/// <summary> -/// Contains extension methods for <see cref="IParameterized"/>. -/// </summary> -public static class IParameterizedExtensions -{ - /// <summary> - /// Creates an observable collection of the parameterized object. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="mode">The parameters update mode.</param> - /// <returns></returns> - public static ObservableCollection<ParameterItem> CreateParametersCollection(this IParameterized instance, ParameterItemMode mode) - { - var ps = new ObservableCollection<ParameterItem>(); - - int index = 0; - - List<Type> types = new List<Type>(); - Type currentType = instance.GetType(); - - while (true) - { - if (typeof(IParameterized).IsAssignableFrom(currentType) && currentType != typeof(IParameterized)) - { - types.Add(currentType); - currentType = currentType.BaseType; - } - else - { - break; - } - } - - List<PropertyInfo> properties = new List<PropertyInfo>(); - - foreach (var type in types) - { - foreach (var prop in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) - { - var paramAtt = prop.GetCustomAttributes(typeof(ParameterItemAttribute), false).Cast<ParameterItemAttribute>().FirstOrDefault(); - var ignore = prop.GetCustomAttributes(typeof(ParameterIgnoreAttribute), false).Cast<ParameterIgnoreAttribute>().FirstOrDefault(); - - if (ignore == null && !properties.Exists(x => x.Name == prop.Name)) - { - var item = instance.CreateParameterItem(prop, paramAtt, index++, mode); - ps.Add(item); - properties.Add(prop); - } - } - } - - return ps; - } - - /// <summary> - /// Creates the parameter item. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="propertyInfo">The property information.</param> - /// <param name="attribute">The attribute.</param> - /// <param name="index">The index.</param> - /// <param name="mode">The mode.</param> - /// <returns></returns> - public static ParameterItem CreateParameterItem(this IParameterized instance, PropertyInfo propertyInfo, ParameterItemAttribute attribute, int index, ParameterItemMode mode) - { - ParameterItem item = new ParameterItem(); - item.Name = propertyInfo.Name.ToTitle(); - item.Index = index; - item.Type = propertyInfo.PropertyType; - item.Value = propertyInfo.GetValue(instance, null); - - if (attribute != null) - { - item.Minimum = attribute.Minimum; - item.Maximum = attribute.Maximum; - item.CustomEditorTypeName = attribute.CustomEditorTypeName; - item.ExtraObject = attribute.ExtraObject; - - if (attribute.Name != null) - { - item.Name = attribute.Name; - } - } - - if (mode == ParameterItemMode.Event) - { - item.ParameterValueChanged += (sender, e) => - { - propertyInfo.SetValue(instance, e.Value); - }; - } - else if (mode == ParameterItemMode.Binding) - { - item.Bind(ParameterItem.ValueProperty, instance as DependencyObject, propertyInfo.Name, System.Windows.Data.BindingMode.TwoWay); - } - - return item; - } - - /// <summary> - /// Creates the parameter item. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="propertyName">Name of the property.</param> - /// <param name="attribute">The attribute.</param> - /// <param name="index">The index.</param> - /// <param name="mode">The mode.</param> - /// <returns></returns> - public static ParameterItem CreateParameterItem(this IParameterized instance, String propertyName, ParameterItemAttribute attribute, int index, ParameterItemMode mode) - { - return instance.CreateParameterItem(instance.GetType().GetProperty(propertyName), attribute, index, mode); - } -} - diff --git a/Software/Visual_Studio/Tango.Editors/ParameterIgnoreAttribute.cs b/Software/Visual_Studio/Tango.Editors/ParameterIgnoreAttribute.cs deleted file mode 100644 index f94f7d354..000000000 --- a/Software/Visual_Studio/Tango.Editors/ParameterIgnoreAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Editors -{ - /// <summary> - /// Represents an attribute for specifying properties to ignore as parameters. - /// </summary> - /// <seealso cref="System.Attribute" /> - public class ParameterIgnoreAttribute : Attribute - { - - } -} diff --git a/Software/Visual_Studio/Tango.Editors/ParameterItem.cs b/Software/Visual_Studio/Tango.Editors/ParameterItem.cs deleted file mode 100644 index 4f08d25d6..000000000 --- a/Software/Visual_Studio/Tango.Editors/ParameterItem.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace Tango.Editors -{ - /// <summary> - /// Represents a component parameter name and value which can be bound to UI elements. - /// </summary> - /// <seealso cref="System.Windows.DependencyObject" /> - public class ParameterItem : DependencyObject - { - /// <summary> - /// Occurs when the parameter value has changed. - /// </summary> - public event EventHandler<ParameterItem> ParameterValueChanged; - - /// <summary> - /// Gets or sets the parameter index. - /// </summary> - public int Index - { - get { return (int)GetValue(IndexProperty); } - set { SetValue(IndexProperty, value); } - } - public static readonly DependencyProperty IndexProperty = - DependencyProperty.Register("Index", typeof(int), typeof(ParameterItem), new PropertyMetadata(0)); - - /// <summary> - /// Gets or sets the parameter value type. - /// </summary> - public Type Type - { - get { return (Type)GetValue(TypeProperty); } - set { SetValue(TypeProperty, value); } - } - public static readonly DependencyProperty TypeProperty = - DependencyProperty.Register("Type", typeof(Type), typeof(ParameterItem), new PropertyMetadata(typeof(double))); - - - /// <summary> - /// Gets or sets the parameter name. - /// </summary> - public String Name - { - get { return (String)GetValue(NameProperty); } - set { SetValue(NameProperty, value); } - } - public static readonly DependencyProperty NameProperty = - DependencyProperty.Register("Name", typeof(String), typeof(ParameterItem), new PropertyMetadata(null)); - - /// <summary> - /// Gets or sets the current parameter value. - /// </summary> - public object Value - { - get { return (object)GetValue(ValueProperty); } - set { SetValue(ValueProperty, value); } - } - public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value", typeof(object), typeof(ParameterItem), new PropertyMetadata(null, new PropertyChangedCallback(OnValueChanged))); - - - /// <summary> - /// Gets or sets the minimum parameter value. - /// </summary> - public object Minimum - { - get { return (object)GetValue(MinimumProperty); } - set { SetValue(MinimumProperty, value); } - } - public static readonly DependencyProperty MinimumProperty = - DependencyProperty.Register("Minimum", typeof(object), typeof(ParameterItem), new PropertyMetadata(0.0d)); - - - /// <summary> - /// Gets or sets the maximum parameter value. - /// </summary> - public object Maximum - { - get { return (object)GetValue(MaximumProperty); } - set { SetValue(MaximumProperty, value); } - } - public static readonly DependencyProperty MaximumProperty = - DependencyProperty.Register("Maximum", typeof(object), typeof(ParameterItem), new PropertyMetadata(1.0d)); - - - /// <summary> - /// Gets or sets an optional extra object. - /// </summary> - public object ExtraObject - { - get { return (object)GetValue(ExtraObjectProperty); } - set { SetValue(ExtraObjectProperty, value); } - } - public static readonly DependencyProperty ExtraObjectProperty = - DependencyProperty.Register("ExtraObject", typeof(object), typeof(ParameterItem), new PropertyMetadata(null)); - - - /// <summary> - /// Gets or sets an optional custom editor. - /// </summary> - public String CustomEditorTypeName - { - get { return (String)GetValue(CustomEditorTypeNameProperty); } - set { SetValue(CustomEditorTypeNameProperty, value); } - } - public static readonly DependencyProperty CustomEditorTypeNameProperty = - DependencyProperty.Register("CustomEditorType", typeof(String), typeof(ParameterItem), new PropertyMetadata(null)); - - - /// <summary> - /// Gets a value indicating whether this instance requires custom editor. - /// </summary> - public bool HasCustomEditor - { - get { return CustomEditorTypeName != null; } - } - - /// <summary> - /// Called when value has changed. - /// </summary> - /// <param name="d">The d.</param> - /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> - private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - (d as ParameterItem).OnParameterChanged(); - } - - /// <summary> - /// Called when the parameter value has changed. - /// </summary> - protected virtual void OnParameterChanged() - { - if (ParameterValueChanged != null) ParameterValueChanged(this, this); - } - - /// <summary> - /// Returns a <see cref="System.String" /> that represents this instance. - /// </summary> - /// <returns> - /// A <see cref="System.String" /> that represents this instance. - /// </returns> - public override string ToString() - { - return Name; - } - } -} diff --git a/Software/Visual_Studio/Tango.Editors/ParameterItemAttribute.cs b/Software/Visual_Studio/Tango.Editors/ParameterItemAttribute.cs deleted file mode 100644 index c914dd156..000000000 --- a/Software/Visual_Studio/Tango.Editors/ParameterItemAttribute.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Editors -{ - /// <summary> - /// Represents a parameter item attribute for used for default, min and max values definition of properties. - /// </summary> - /// <seealso cref="System.Attribute" /> - public class ParameterItemAttribute : Attribute - { - /// <summary> - /// Gets or sets the custom parameter name. - /// </summary> - public String Name { get; set; } - - /// <summary> - /// Gets or sets the default value. - /// </summary> - public object Default { get; set; } - - /// <summary> - /// Gets or sets the minimum value. - /// </summary> - public object Minimum { get; set; } - - /// <summary> - /// Gets or sets the maximum value. - /// </summary> - public object Maximum { get; set; } - - /// <summary> - /// Gets or sets an optional extra object. - /// </summary> - public object ExtraObject { get; set; } - - /// <summary> - /// Gets or sets an optional custom editor type name. - /// </summary> - public String CustomEditorTypeName { get; set; } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - public ParameterItemAttribute() - { - Default = null; - Minimum = 0.0d; - Maximum = 1.0d; - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="minimumValue">The minimum value.</param> - /// <param name="maximumValue">The maximum value.</param> - /// <param name="defaultValue">The default value.</param> - public ParameterItemAttribute(String name, object minimumValue, object maximumValue, object defaultValue) : this() - { - Name = name; - Default = defaultValue; - Minimum = minimumValue; - Maximum = maximumValue; - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="minimumValue">The minimum value.</param> - /// <param name="maximumValue">The maximum value.</param> - public ParameterItemAttribute(String name, object minimumValue, double maximumValue) : this(name, minimumValue, maximumValue, null) - { - - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="minimumValue">The minimum value.</param> - /// <param name="maximumValue">The maximum value.</param> - public ParameterItemAttribute(object minimumValue, object maximumValue) : this() - { - Minimum = minimumValue; - Maximum = maximumValue; - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="customParameterEditorTypeName">Type of the custom parameter editor type name.</param> - public ParameterItemAttribute(String customParameterEditorTypeName) : this() - { - CustomEditorTypeName = customParameterEditorTypeName; - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="customParameterEditorTypeName">Name of the custom parameter editor type.</param> - /// <param name="minimumValue">The minimum value.</param> - /// <param name="maximumValue">The maximum value.</param> - /// <param name="defaultValue">The default value.</param> - /// <param name="extraObject">The extra object.</param> - public ParameterItemAttribute(String name, String customParameterEditorTypeName, object minimumValue, object maximumValue, object defaultValue, object extraObject) : this() - { - Name = name; - Minimum = minimumValue; - Maximum = maximumValue; - Default = defaultValue; - CustomEditorTypeName = customParameterEditorTypeName; - ExtraObject = extraObject; - } - - /// <summary> - /// Initializes a new instance of the <see cref="ParameterItemAttribute"/> class. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="customParameterEditorTypeName">Custom parameter editor type.</param> - /// <param name="minimumValue">The minimum value.</param> - /// <param name="maximumValue">The maximum value.</param> - /// <param name="defaultValue">The default value.</param> - /// <param name="extraObject">The extra object.</param> - public ParameterItemAttribute(String name, Type customParameterEditorType, object minimumValue, object maximumValue, object defaultValue, object extraObject) - : this() - { - Name = name; - Minimum = minimumValue; - Maximum = maximumValue; - Default = defaultValue; - CustomEditorTypeName = customParameterEditorType.AssemblyQualifiedName; - ExtraObject = extraObject; - } - } -} diff --git a/Software/Visual_Studio/Tango.Editors/ParameterItemMode.cs b/Software/Visual_Studio/Tango.Editors/ParameterItemMode.cs deleted file mode 100644 index 2c3ed373c..000000000 --- a/Software/Visual_Studio/Tango.Editors/ParameterItemMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Editors -{ - /// <summary> - /// Represents a <see cref="ParameterItem"/> update mode. - /// </summary> - public enum ParameterItemMode - { - /// <summary> - /// Update by binding. - /// </summary> - Binding, - /// <summary> - /// Update by event. - /// </summary> - Event - } -} diff --git a/Software/Visual_Studio/Tango.Editors/Tango.Editors.csproj b/Software/Visual_Studio/Tango.Editors/Tango.Editors.csproj index 5cb0f7b1d..a328e47b7 100644 --- a/Software/Visual_Studio/Tango.Editors/Tango.Editors.csproj +++ b/Software/Visual_Studio/Tango.Editors/Tango.Editors.csproj @@ -69,13 +69,7 @@ <DependentUpon>CanvasItemEditor.xaml</DependentUpon> </None> <Compile Include="FrameworkElementExtensions.cs" /> - <Compile Include="IParameterized.cs" /> - <Compile Include="IParameterizedExtensions.cs" /> <Compile Include="ObjectExtensions.cs" /> - <Compile Include="ParameterIgnoreAttribute.cs" /> - <Compile Include="ParameterItem.cs" /> - <Compile Include="ParameterItemAttribute.cs" /> - <Compile Include="ParameterItemMode.cs" /> <Compile Include="UIElementExtension.cs" /> <Compile Include="UIHelper.cs" /> <Compile Include="UndoRedoStatesProviderBase.cs" /> |
