aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.SharedUI
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Animations/GridLengthAnimation.cs71
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventArgs.cs39
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventContainer.cs95
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Binding/BindingProperty.cs38
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Components/BindingProxy.cs31
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Components/SelectedObject.cs6
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs44
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/AllSelectedCheckboxList.cs144
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs344
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBoxItem.cs39
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs2
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs366
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml113
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs488
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs269
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs2
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs30
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs31
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/EnumToIntConverter.cs23
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs13
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/FilePathToFileNameConverter.cs36
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs42
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualToVisibilityConverter.cs31
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/IsToStringEqualToVisibilityConverter.cs23
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs49
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs9
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs50
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/StringToTitleCaseConverter.cs30
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToDaysConverter.cs23
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToMinutesConverter.cs23
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToSecondsConverter.cs23
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs3
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs34
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs67
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Images/PinClose_Black.pngbin1230 -> 0 bytes
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj43
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Themes/Generic.xaml142
37 files changed, 736 insertions, 2080 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Animations/GridLengthAnimation.cs b/Software/Visual_Studio/Tango.SharedUI/Animations/GridLengthAnimation.cs
deleted file mode 100644
index 52dcacedf..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Animations/GridLengthAnimation.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows.Media.Animation;
-using System.Windows;
-
-namespace Tango.SharedUI.Animations
-{
- public class GridLengthAnimation : AnimationTimeline
- {
- public static readonly DependencyProperty FromProperty;
- public static readonly DependencyProperty ToProperty;
-
- static GridLengthAnimation()
- {
- FromProperty = DependencyProperty.Register("From", typeof(GridLength), typeof(GridLengthAnimation));
- ToProperty = DependencyProperty.Register("To", typeof(GridLength), typeof(GridLengthAnimation));
- }
-
- protected override Freezable CreateInstanceCore()
- {
- return new GridLengthAnimation();
- }
-
- public override Type TargetPropertyType
- {
- get { return typeof(GridLength); }
- }
-
- public GridLength From
- {
- get
- {
- return (GridLength)GetValue(GridLengthAnimation.FromProperty);
- }
- set
- {
- SetValue(GridLengthAnimation.FromProperty, value);
- }
- }
-
- public GridLength To
- {
- get
- {
- return (GridLength)GetValue(GridLengthAnimation.ToProperty);
- }
- set
- {
- SetValue(GridLengthAnimation.ToProperty, value);
- }
- }
-
- public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
- {
-
- double fromValue = ((GridLength)GetValue(GridLengthAnimation.FromProperty)).Value;
- double toValue = ((GridLength)GetValue(GridLengthAnimation.ToProperty)).Value;
-
- if (fromValue > toValue)
- {
- return new GridLength((1 - animationClock.CurrentProgress.Value) * (fromValue - toValue) + toValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);
- }
- else
- {
- return new GridLength((animationClock.CurrentProgress.Value) * (toValue - fromValue) + fromValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);
- }
-
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventArgs.cs b/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventArgs.cs
deleted file mode 100644
index 06ea61019..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventArgs.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Media;
-
-namespace Tango.SharedUI
-{
- /// <summary>
- /// Represents the <see cref="BindingEventContainer.ValueChanged"/> event arguments.
- /// </summary>
- /// <seealso cref="System.EventArgs" />
- public class BindingEventArgs : EventArgs
- {
- internal Action _renewAction;
-
- /// <summary>
- /// Gets or sets the element.
- /// </summary>
- public DependencyObject DependencyObject { get; set; }
-
- /// <summary>
- /// Gets or sets the binding property.
- /// </summary>
- public BindingProperty BindingProperty { get; set; }
-
- /// <summary>
- /// Gets or sets the value.
- /// </summary>
- public Object Value { get; set; }
-
- public void Renew()
- {
- _renewAction?.Invoke();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventContainer.cs b/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventContainer.cs
deleted file mode 100644
index a74a9b085..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventContainer.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Data;
-using System.Windows.Media;
-
-namespace Tango.SharedUI
-{
- /// <summary>
- /// Represents a binding event container.
- /// </summary>
- /// <seealso cref="System.Windows.DependencyObject" />
- public class BindingEventContainer : DependencyObject
- {
- private Action _renewAction;
-
- /// <summary>
- /// Occurs when the dependency property value has changed.
- /// </summary>
- public event EventHandler<BindingEventArgs> ValueChanged;
-
- /// <summary>
- /// Gets or sets the 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(BindingEventContainer), new PropertyMetadata(null, (d, e) => (d as BindingEventContainer).OnValueChanged()));
-
- /// <summary>
- /// Gets or sets the binding property.
- /// </summary>
- public BindingProperty BindingProperty { get; set; }
-
- /// <summary>
- /// Gets or sets the dependency object.
- /// </summary>
- public DependencyObject DependencyObject { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BindingEventContainer"/> class.
- /// </summary>
- /// <param name="takeElement">The dependency object.</param>
- /// <param name="bindingProperty">The binding property.</param>
- public BindingEventContainer(DependencyObject dependencyObject, BindingProperty bindingProperty)
- {
- DependencyObject = dependencyObject;
- BindingProperty = bindingProperty;
- }
-
- /// <summary>
- /// Called when the value has been changed
- /// </summary>
- protected virtual void OnValueChanged()
- {
- ValueChanged?.Invoke(this, new BindingEventArgs()
- {
- BindingProperty = BindingProperty,
- DependencyObject = DependencyObject,
- Value = Value,
- _renewAction = _renewAction
- });
- }
-
- /// <summary>
- /// Generates a new <see cref="BindingEventContainer"/> for the specified Take element and binding property.
- /// </summary>
- /// <param name="dependencyObject">The take element.</param>
- /// <param name="dependencyProperty">The binding property.</param>
- /// <returns></returns>
- public static BindingEventContainer Generate(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
- {
- BindingEventContainer container = new BindingEventContainer(dependencyObject, new BindingProperty(dependencyProperty));
-
- container._renewAction = () =>
- {
- Binding binding = new Binding();
- binding.Mode = BindingMode.OneWay;
- binding.Source = dependencyObject;
- binding.Path = new PropertyPath(dependencyProperty);
- BindingOperations.SetBinding(container, BindingEventContainer.ValueProperty, binding);
- };
-
- container._renewAction.Invoke();
-
- return container;
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingProperty.cs b/Software/Visual_Studio/Tango.SharedUI/Binding/BindingProperty.cs
deleted file mode 100644
index 79d4f1c71..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Binding/BindingProperty.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Tango.SharedUI
-{
- /// <summary>
- /// Represents a binding property.
- /// </summary>
- public class BindingProperty
- {
- /// <summary>
- /// Gets or sets the dependency property.
- /// </summary>
- public DependencyProperty DependencyProperty { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BindingProperty"/> class.
- /// </summary>
- public BindingProperty()
- {
-
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BindingProperty"/> class.
- /// </summary>
- /// <param name="dp">The dependency property.</param>
- /// <param name="mode">The mode.</param>
- public BindingProperty(DependencyProperty dp) : this()
- {
- DependencyProperty = dp;
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Components/BindingProxy.cs b/Software/Visual_Studio/Tango.SharedUI/Components/BindingProxy.cs
deleted file mode 100644
index e13436900..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Components/BindingProxy.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Tango.SharedUI.Components
-{
- public class BindingProxy : Freezable
- {
- #region Overrides of Freezable
-
- protected override Freezable CreateInstanceCore()
- {
- return new BindingProxy();
- }
-
- #endregion
-
- public object Data
- {
- get { return (object)GetValue(DataProperty); }
- set { SetValue(DataProperty, value); }
- }
-
- public static readonly DependencyProperty DataProperty =
- DependencyProperty.Register("Data", typeof(object),
- typeof(BindingProxy));
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObject.cs b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObject.cs
index d85777292..f91e93b5a 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObject.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObject.cs
@@ -7,20 +7,18 @@ using Tango.Core;
namespace Tango.SharedUI.Components
{
- public class SelectedObject : ExtendedObject
+ public class SelectedObject<T> : ExtendedObject
{
public event EventHandler IsSelectedChanged;
private bool _isSelected;
+
public bool IsSelected
{
get { return _isSelected; }
set { _isSelected = value; RaisePropertyChangedAuto(); IsSelectedChanged?.Invoke(this, new EventArgs()); }
}
- }
- public class SelectedObject<T> : SelectedObject
- {
private T _data;
public T Data
diff --git a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
index 8aa087ed3..e09bb832e 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
@@ -10,69 +10,37 @@ namespace Tango.SharedUI.Components
{
public class SelectedObjectCollection<T> : ObservableCollection<SelectedObject<T>>
{
- private Func<T, T, bool> _compareFunc;
-
public event EventHandler SelectionChanged;
public ObservableCollection<T> Source { get; set; }
public ObservableCollection<T> SynchedSource { get; set; }
- public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource, Func<T, T, bool> compareFunc)
+ public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource)
{
- _compareFunc = compareFunc;
-
SynchedSource = synchedSource;
Source = source;
foreach (var item in source)
{
- var selectedItem = new SelectedObject<T>(item, _compareFunc == null ? synchedSource.Contains(item) : synchedSource.ToList().Exists(x => _compareFunc(x, item)));
+ var selectedItem = new SelectedObject<T>(item, synchedSource.Contains(item));
this.Add(selectedItem);
selectedItem.IsSelectedChanged += SelectedItem_IsSelectedChanged;
}
}
- public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource) : this(source, synchedSource, null)
- {
-
- }
-
private void SelectedItem_IsSelectedChanged(object sender, EventArgs e)
{
SelectedObject<T> item = sender as SelectedObject<T>;
-
+
if (item.IsSelected)
{
- if (_compareFunc == null)
+ if (!SynchedSource.Contains(item.Data))
{
- if (!SynchedSource.Contains(item.Data))
- {
- SynchedSource.Add(item.Data);
- }
- }
- else
- {
- if (!SynchedSource.ToList().Exists(x => _compareFunc(x, item.Data)))
- {
- SynchedSource.Add(item.Data);
- }
+ SynchedSource.Add(item.Data);
}
}
else
{
- if (_compareFunc == null)
- {
- SynchedSource.Remove(item.Data);
- }
- else
- {
- foreach (var s in SynchedSource.ToList())
- {
- if (_compareFunc(s, item.Data))
- {
- SynchedSource.Remove(s);
- }
- }
- }
+ SynchedSource.Remove(item.Data);
}
SelectionChanged?.Invoke(this, new EventArgs());
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/AllSelectedCheckboxList.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/AllSelectedCheckboxList.cs
deleted file mode 100644
index 6e3cb862f..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/AllSelectedCheckboxList.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using System;
-using System.Windows;
-using System.Windows.Controls;
-using Tango.Core.Commands;
-//using System.Collections;
-using System.Linq;
-using System.Collections;
-
-namespace Tango.SharedUI.Controls
-{
- public class AllSelectedCheckboxList : ListBox
- {
- #region Properties
-
- private ItemsControl _itemsControl;
-
- public ItemsControl ItemsControl
- {
- get { return _itemsControl; }
- set { _itemsControl = value; }
- }
-
- public bool? AllSelected
- {
- get { return (bool?)GetValue(AllSelectedProperty); }
- set
- {
- SetValue(AllSelectedProperty, value);
- }
- }
-
- public static readonly DependencyProperty AllSelectedProperty =
- DependencyProperty.Register("AllSelected", typeof(bool?), typeof(AllSelectedCheckboxList), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnAllSelectedChanged)));
-
-
- private static void OnAllSelectedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
- {
- AllSelectedCheckboxList l = o as AllSelectedCheckboxList;
- var nv = e.NewValue;
- l.AllSelectedChanged((bool?)nv);
- }
-
- public static DependencyProperty ClickCheckBoxCommandProperty = DependencyProperty.Register("ClickCheckBoxCommand", typeof(RelayCommand<object>), typeof(AllSelectedCheckboxList));
- public RelayCommand<object> ClickCheckBoxCommand
- {
- get { return (RelayCommand<object>)GetValue(ClickCheckBoxCommandProperty); }
- private set { SetValue(ClickCheckBoxCommandProperty, value); }
- }
-
- #endregion
-
- #region "Constructors"
-
- static AllSelectedCheckboxList()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(AllSelectedCheckboxList), new FrameworkPropertyMetadata(typeof(AllSelectedCheckboxList)));
-
- }
- public AllSelectedCheckboxList() : base()
- {
- ClickCheckBoxCommand = new RelayCommand<object>(ClickCheckBox);
- }
-
- /// <summary>
- /// Clicks the CheckBox.Update Selection ListBoxitem.
- /// </summary>
- /// <param name="obj">The object.</param>
- private void ClickCheckBox(object obj)
- {
- if (obj is ListBoxItem)
- {
- ListBoxItem lbItem = obj as ListBoxItem;
- CheckBox checkBox = lbItem.FindVisualChildren<CheckBox>().FirstOrDefault();
- if (checkBox != null)
- {
- bool? check = checkBox.IsChecked;
- if (check != null)
- {
- lbItem.IsSelected = (bool)check;
- }
- }
- }
-
- if (SelectedItems.Count == 0)
- {
- AllSelected = false;
- }
- else if (Items.Count > 0 && SelectedItems.Count == Items.Count)
- {
- AllSelected = true;
- }
- else
- {
- AllSelected = null;
- }
- }
-
- #endregion
-
- #region Override
-
- /// <summary>
- /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate" />.
- /// </summary>
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- AllSelectedChanged(AllSelected);
-
-
-
- }
-
- protected override void OnSelectionChanged(SelectionChangedEventArgs e)
- {
- base.OnSelectionChanged(e);
- foreach(var addItem in e.AddedItems.OfType<Components.SelectedObject>())
- {
- addItem.IsSelected = true;
- }
- foreach (var removeItem in e.RemovedItems.OfType<Components.SelectedObject>())
- {
- removeItem.IsSelected = false;
- }
- }
-
- #endregion
-
- private void AllSelectedChanged(bool? value)
- {
- if (value == null)
- return;
- SelectionMode = SelectionMode.Multiple;
- if (value == true)
- {
- SelectAll();
- }
- else
- {
- UnselectAll();
- }
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs
deleted file mode 100644
index 153b36804..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-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.Commands;
-using System.ComponentModel;
-using System.Windows.Controls.Primitives;
-using System.Windows.Threading;
-using System.Diagnostics;
-
-namespace Tango.SharedUI.Controls
-{
- internal sealed class MultiSelectComboBoxTemplateSelector : DataTemplateSelector
- {
- public override DataTemplate SelectTemplate(object item, DependencyObject container)
- {
- FrameworkElement element = container as FrameworkElement;
- if (element != null && item != null && item is MultiSelectComboBoxItem)
- return element.FindResource("CheckItem") as DataTemplate;
-
- return element.FindResource("SearchItem") as DataTemplate; ;
-
- }
- }
-
- [TemplatePart(Name = MultiSelectComboBox.PartEditor, Type = typeof(TextBox))]
- [TemplatePart(Name = MultiSelectComboBox.PartPopup, Type = typeof(Popup))]
- public class MultiSelectComboBox : Control
- {
- #region Fields
- public const string PartEditor = "Edit_PART";
- public const string PartPopup = "MultiSel_Popup";
- private ItemsControl _items_control;
- private bool _isLoaded;
- #endregion
- #region "Constructors"
-
- static MultiSelectComboBox()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiSelectComboBox), new FrameworkPropertyMetadata(typeof(MultiSelectComboBox)));
-
- }
- public MultiSelectComboBox() : base()
- {
- SelectedItemsList = new ObservableCollection<object>();
- RemoveAllCommand = new RelayCommand(RemoveAllSelectedItems, CanRemoveAllSelectedItems);
- RemoveItemCommand = new RelayCommand<MultiSelectComboBoxItem>(RemoveSelectedItem);
- AddItemCommand = new RelayCommand<string>(AddSelectedItem);
- SearchText = new MultiSelectComboBoxSearchItem();
- Loaded += MultiSelectComboBox_Loaded;
- _isLoaded = false;
-
-
- }
- #endregion
-
- #region Properties
-
- private TextBox _editor;
-
- public TextBox Editor
- {
- get { return _editor; }
- set { _editor = value; }
- }
-
- private Popup _popup;
-
- public Popup Popup
- {
- get { return _popup; }
- set { _popup = value; }
- }
-
- private DispatcherTimer _fetchTimer;
-
- public DispatcherTimer FetchTimer
- {
- get { return _fetchTimer; }
- set { _fetchTimer = value; }
- }
-
- public ObservableCollection<object> SelectedItemsList
- {
- get { return (ObservableCollection<object>)GetValue(SelectedItemsListProperty); }
- set { SetValue(SelectedItemsListProperty, value); }
- }
-
- public static readonly DependencyProperty SelectedItemsListProperty =
- DependencyProperty.Register("SelectedItemsList", typeof(ObservableCollection<object>), typeof(MultiSelectComboBox), new PropertyMetadata(default(ObservableCollection<object>)));
-
-
- public ListCollectionView SearchItemsList
- {
- get { return (ListCollectionView)GetValue(SearchItemsListProperty); }
- set { SetValue(SearchItemsListProperty, value); }
- }
- /// <summary>
- /// The search items list property for popup items list
- /// </summary>
- public static readonly DependencyProperty SearchItemsListProperty =
- DependencyProperty.Register("SearchItemsList", typeof(ListCollectionView), typeof(MultiSelectComboBox), new PropertyMetadata(default(ObservableCollection<string>)));
-
- public ObservableCollection<string> Items
- {
- get { return (ObservableCollection<string>)GetValue(ItemsProperty); }
- set { SetValue(ItemsProperty, value); }
- }
-
- public static readonly DependencyProperty ItemsProperty =
- DependencyProperty.Register("Items", typeof(ObservableCollection<string>), typeof(MultiSelectComboBox), new PropertyMetadata(default(ObservableCollection<string>)));
-
-
- public bool IsToggleChecked
- {
- get { return (bool)GetValue(IsToggleCheckedProperty); }
- set { SetValue(IsToggleCheckedProperty, value); }
- }
-
- public static readonly DependencyProperty IsToggleCheckedProperty =
- DependencyProperty.Register("IsToggleChecked", typeof(bool), typeof(MultiSelectComboBox), new FrameworkPropertyMetadata(false));
-
- private MultiSelectComboBoxSearchItem _searchText;
- /// <summary>
- /// Gets or sets the search text of TextBox.
- /// </summary>
- public MultiSelectComboBoxSearchItem SearchText
- {
- get { return _searchText; }
- set
- {
- _searchText = value;
- OnTextChanged();
- }
- }
- #endregion
-
- private void MultiSelectComboBox_Loaded(object sender, RoutedEventArgs e)
- {
- if (!_isLoaded)
- {
- ToggleButton b2 = GetTemplateChild("MultiSelToggleButton") as ToggleButton;
- if (b2 != null)
- {
- // ct.LoadContent();
- _items_control = b2.Template.FindName("SelectedItemsControl", b2) as ItemsControl;
- if (_items_control != null)
- {
- var wrapPanel = _items_control.FindChild<WrapPanel>();
- if (wrapPanel != null)
- {
- _items_control.Bind(ItemsControl.HeightProperty, wrapPanel, WrapPanel.ActualHeightProperty, BindingMode.OneWay);
- _isLoaded = true;
-
- var searchItem =(_items_control.ItemContainerGenerator.ContainerFromItem(SearchText));
- Editor = searchItem.FindVisualChildren< TextBox>().FirstOrDefault(x => x.Name == PartEditor);
- if (Editor != null)
- {
- Editor.TextChanged += OnEditorTextChanged;
- Editor.PreviewKeyDown += OnEditorKeyDown;
- Editor.LostFocus += OnEditorLostFocus;
- Editor.GotFocus += OnEditorGotFocus;
- }
- }
- }
- this.GotFocus += SelTextBox_GotFocus;
- }
- }
- }
-
- void OnTextChanged()
- {
- if(SearchItemsList != null)
- {
- if (String.IsNullOrEmpty(SearchText.Text))
- SearchItemsList.Filter = null;
- else
- SearchItemsList.Filter = new Predicate<object>(o => (((string)o).ToLower().Contains(SearchText.Text.ToLower())));
- }
- }
- /// <summary>
- /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate" />.
- /// </summary>
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- if (SelectedItemsList == null)
- SelectedItemsList = new ObservableCollection<object>();
- SelectedItemsList.Add(SearchText);
-
- SearchItemsList = new ListCollectionView(this.Items);
- Popup = Template.FindName(PartPopup, this) as Popup;
-
-
- if (Popup != null)
- {
- Popup.StaysOpen = false;
- Popup.Opened += OnPopupOpened;
- Popup.Closed += OnPopupClosed;
- }
- }
-
- private void OnEditorTextChanged(object sender, TextChangedEventArgs e)
- {
- if (FetchTimer == null)
- {
- FetchTimer = new DispatcherTimer();
- FetchTimer.Interval = TimeSpan.FromMilliseconds(500);
- FetchTimer.Tick += OnFetchTimerTick;
- }
- FetchTimer.IsEnabled = false;
- FetchTimer.Stop();
- IsToggleChecked = true;
-
- FetchTimer.IsEnabled = true;
- FetchTimer.Start();
-
- }
-
- private void OnFetchTimerTick(object sender, EventArgs e)
- {
- FetchTimer.IsEnabled = false;
- FetchTimer.Stop();
- SearchText.Text = Editor.Text;
- OnTextChanged();
- }
-
- private void OnEditorKeyDown(object sender, KeyEventArgs e)
- {
- IsToggleChecked = true;
- }
-
- private void OnEditorLostFocus(object sender, RoutedEventArgs e)
- {
- if (!IsKeyboardFocusWithin)
- {
- IsToggleChecked = false;
- }
- }
-
- private void SelTextBox_GotFocus(object sender, RoutedEventArgs e)
- {
- Editor?.Focus();
- }
-
- private void OnEditorGotFocus(object sender, RoutedEventArgs e)
- {
- IsToggleChecked = true;
- }
-
- private void OnPopupOpened(object sender, EventArgs e)
- {
-
- }
- private void OnPopupClosed(object sender, EventArgs e)
- {
- IsToggleChecked = false;
-
- }
- #region Commands
- /// <summary>
- /// The remove all command property for clear SelectedItemsList
- /// </summary>
- public static DependencyProperty RemoveAllCommandProperty = DependencyProperty.Register("RemoveAllCommand", typeof(RelayCommand), typeof(MultiSelectComboBox));
- public RelayCommand RemoveAllCommand
- {
- get { return (RelayCommand)GetValue(RemoveAllCommandProperty); }
- private set { SetValue(RemoveAllCommandProperty, value); }
- }
-
- /// <summary>
- /// The remove item from SelectedItemsList command property
- /// </summary>
- public static DependencyProperty RemoveItemCommandProperty = DependencyProperty.Register("RemoveItemCommand", typeof(RelayCommand<MultiSelectComboBoxItem>), typeof(MultiSelectComboBox));
- public RelayCommand<MultiSelectComboBoxItem> RemoveItemCommand
- {
- get { return (RelayCommand<MultiSelectComboBoxItem>)GetValue(RemoveItemCommandProperty); }
- private set { SetValue(RemoveItemCommandProperty, value); }
- }
-
- /// <summary>
- /// The add item to SelectedItemsList command property
- /// </summary>
- public static DependencyProperty AddItemCommandProperty = DependencyProperty.Register("AddItemCommand", typeof(RelayCommand<string>), typeof(MultiSelectComboBox));
- public RelayCommand<string> AddItemCommand
- {
- get { return (RelayCommand<string>)GetValue(AddItemCommandProperty); }
- private set { SetValue(AddItemCommandProperty, value); }
- }
-
- /// <summary>
- /// Removes the selected item.
- /// </summary>
- /// <param name="item">The item.</param>
- private void RemoveSelectedItem(IMultiSelectComboBoxItem item)
- {
- SelectedItemsList.Remove(item);
- RemoveAllCommand.RaiseCanExecuteChanged();
- }
-
- /// <summary>
- /// Adds the selected item.
- /// </summary>
- /// <param name="item">The item.</param>
- private void AddSelectedItem(string item)
- {
- if (SelectedItemsList.Any(x => (x as IMultiSelectComboBoxItem).Text == item))
- return;
- SelectedItemsList.Insert(SelectedItemsList.Count - 1, new MultiSelectComboBoxItem(item));
- RemoveAllCommand.RaiseCanExecuteChanged();
- }
- /// <summary>
- /// Removes all selected items.
- /// </summary>
- private void RemoveAllSelectedItems()
- {
- int index = SelectedItemsList.Count - 2;
- while (index >= 0)
- {
- SelectedItemsList.RemoveAt(index--);
- }
- RemoveAllCommand.RaiseCanExecuteChanged();
- }
- private bool CanRemoveAllSelectedItems()
- {
- return (SelectedItemsList != null && SelectedItemsList.Count > 1);
- }
- #endregion
-
-
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBoxItem.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBoxItem.cs
deleted file mode 100644
index 2dcaa977a..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBoxItem.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tango.SharedUI.Controls
-{
- interface IMultiSelectComboBoxItem
- {
- string Text { get; set; }
- }
-
- public class MultiSelectComboBoxItem : IMultiSelectComboBoxItem
- {
- public string Text { get; set; }
- public MultiSelectComboBoxItem(string text)
- {
- Text = text;
- }
- public override string ToString()
- {
- return Text;
- }
- }
-
- public class MultiSelectComboBoxSearchItem : IMultiSelectComboBoxItem
- {
- public string Text { get; set; }
- public MultiSelectComboBoxSearchItem(string text = "")
- {
- Text = text;
- }
- public override string ToString()
- {
- return Text;
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs
index 12c4645e3..8f54a2ce4 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectDataGrid.cs
@@ -9,7 +9,7 @@ using System.Windows.Controls;
namespace Tango.SharedUI.Controls
{
- public class MultiSelectDataGrid : DoubleClickDataGrid
+ public class MultiSelectDataGrid : DataGrid
{
public IList SelectedItemsList
{
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
index cefdbbfd6..b3869daff 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Diagnostics;
using System.Linq;
using System.Text;
-using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -13,7 +11,6 @@ using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
-using Tango.Core;
using Tango.SharedUI.Helpers;
namespace Tango.SharedUI.Controls
@@ -21,17 +18,7 @@ namespace Tango.SharedUI.Controls
[ContentProperty(nameof(Elements))]
public class NavigationControl : UserControl
{
- private event Action NavigationCompleted;
- public event EventHandler<FrameworkElement> SelectedElementChanged;
- private Thread _navigationThread;
- private bool _preventSelectedObjectNavigation;
- private ProducerConsumerQueue<NavigationQueueItem> _navigationQueue;
-
- private class NavigationQueueItem
- {
- public NavigationElement FromElement { get; set; }
- public NavigationElement ToElement { get; set; }
- }
+ private Action _onCompleted;
#region Transition Types
@@ -186,24 +173,6 @@ namespace Tango.SharedUI.Controls
#region Properties
-
-
- public object SelectedObject
- {
- get { return (object)GetValue(SelectedObjectProperty); }
- set { SetValue(SelectedObjectProperty, value); }
- }
- public static readonly DependencyProperty SelectedObjectProperty =
- DependencyProperty.Register("SelectedObject", typeof(object), typeof(NavigationControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, (d, e) => (d as NavigationControl).OnSelectedObjectChanged()));
-
- private void OnSelectedObjectChanged()
- {
- if (SelectedObject != null && !_preventSelectedObjectNavigation)
- {
- NavigateTo(SelectedObject);
- }
- }
-
public ObservableCollection<FrameworkElement> Elements
{
get { return (ObservableCollection<FrameworkElement>)GetValue(ElementsProperty); }
@@ -218,7 +187,7 @@ namespace Tango.SharedUI.Controls
set { SetValue(SelectedElementProperty, value); }
}
public static readonly DependencyProperty SelectedElementProperty =
- DependencyProperty.Register("SelectedElement", typeof(FrameworkElement), typeof(NavigationControl), new FrameworkPropertyMetadata(null, (d, e) => (d as NavigationControl).OnSelectedElementChanged(e.OldValue as FrameworkElement, e.NewValue as FrameworkElement)));
+ DependencyProperty.Register("SelectedElement", typeof(FrameworkElement), typeof(NavigationControl), new PropertyMetadata(null, (d, e) => (d as NavigationControl).OnSelectedElementChanged(e.OldValue as FrameworkElement, e.NewValue as FrameworkElement)));
public TransitionTypes TransitionType
{
@@ -252,13 +221,7 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty KeepElementsAttachedProperty =
DependencyProperty.Register("KeepElementsAttached", typeof(bool), typeof(NavigationControl), new PropertyMetadata(false));
- public bool GalleryMode
- {
- get { return (bool)GetValue(GalleryModeProperty); }
- set { SetValue(GalleryModeProperty, value); }
- }
- public static readonly DependencyProperty GalleryModeProperty =
- DependencyProperty.Register("GalleryMode", typeof(bool), typeof(NavigationControl), new PropertyMetadata(false));
+
public int SelectedIndex
{
@@ -316,9 +279,7 @@ namespace Tango.SharedUI.Controls
/// <returns></returns>
public static String GetNavigationName(FrameworkElement element)
{
- var name = element.GetValue(NavigationName).ToStringSafe();
- if (String.IsNullOrEmpty(name)) name = element.GetType().Name;
- return name;
+ return element.GetValue(NavigationName).ToStringSafe();
}
#endregion
@@ -334,11 +295,6 @@ namespace Tango.SharedUI.Controls
Content = _grid;
Elements = new ObservableCollection<FrameworkElement>();
Loaded += NavigationControl_Loaded;
-
- _navigationQueue = new ProducerConsumerQueue<NavigationQueueItem>();
- _navigationThread = new Thread(NavigationThread);
- _navigationThread.IsBackground = true;
- _navigationThread.Start();
}
#endregion
@@ -391,8 +347,6 @@ namespace Tango.SharedUI.Controls
}
else
{
- Elements.ToList().ForEach(x => x.FocusVisualStyle = null);
-
var toRemove = _grid.Children.OfType<NavigationElement>().ToList().Where(x => !Elements.Contains(x.Element)).ToList();
var toAdd = Elements.Where(x => !_grid.Children.OfType<NavigationElement>().Select(y => y.Element).ToList().Contains(x)).ToList();
@@ -454,181 +408,135 @@ namespace Tango.SharedUI.Controls
private void Navigate(NavigationElement fromElement, NavigationElement toElement)
{
- _navigationQueue.BlockEnqueue(new NavigationQueueItem()
+ if (toElement == null || toElement == fromElement)
{
- FromElement = fromElement,
- ToElement = toElement,
- });
- }
+ _onCompleted?.Invoke();
+ }
- private void NavigationThread()
- {
- try
+ if (fromElement != null)
{
- while (true)
- {
- var item = _navigationQueue.BlockDequeue();
-
- var navigationCompleted = false;
-
- NavigationElement fromElement = item.FromElement;
- NavigationElement toElement = item.ToElement;
-
- Dispatcher.BeginInvoke(new Action(() =>
- {
- if (toElement == null || toElement == fromElement)
- {
- //navigationCompleted = true;
- Debug.WriteLine("NavigationControl: THIS MIGHT CAUSE PROBLEMS !!");
- }
-
- if (fromElement != null)
- {
- DoubleAnimation toAnimation = new DoubleAnimation();
- toAnimation.Duration = TransitionDuration;
-
- DoubleAnimation fromAnimation = new DoubleAnimation();
- fromAnimation.Duration = TransitionDuration;
-
- int fromIndex = Elements.IndexOf(fromElement.Element);
- int toIndex = Elements.IndexOf(toElement.Element);
-
- fromElement.Reset();
- toElement.Reset();
+ DoubleAnimation toAnimation = new DoubleAnimation();
+ toAnimation.Duration = TransitionDuration;
- fromAnimation.Completed += (_, __) =>
- {
- fromElement.Deactivate(!KeepElementsAttached);
- };
+ DoubleAnimation fromAnimation = new DoubleAnimation();
+ fromAnimation.Duration = TransitionDuration;
- bool completed = false;
-
- toAnimation.Completed += (_, __) =>
- {
- if (!completed)
- {
- completed = true;
-
- INavigationView fromNavigationView = fromElement.Element as INavigationView;
- INavigationView toNavigationView = toElement.Element as INavigationView;
-
- if (fromNavigationView != null)
- {
- fromNavigationView.OnNavigatedFrom();
- }
- if (toNavigationView != null)
- {
- toNavigationView.OnNavigatedTo();
- }
+ int fromIndex = Elements.IndexOf(fromElement.Element);
+ int toIndex = Elements.IndexOf(toElement.Element);
- INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel;
- INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
+ fromElement.Reset();
+ toElement.Reset();
- if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom();
- if (toVM != null) toVM.OnNavigatedTo();
+ fromAnimation.Completed += (_, __) =>
+ {
+ fromElement.Deactivate(!KeepElementsAttached);
+ };
- navigationCompleted = true;
- }
- };
+ bool completed = false;
- switch (TransitionType)
- {
- case TransitionTypes.Fade:
- fromAnimation.From = 1;
- fromAnimation.To = 0;
-
- toAnimation.From = 0;
- toAnimation.To = 1;
+ toAnimation.Completed += (_, __) =>
+ {
+ if (!completed)
+ {
+ completed = true;
- fromElement.AnimateOpacity(fromAnimation);
- toElement.AnimateOpacity(toAnimation);
+ INavigationView fromNavigationView = fromElement.Element as INavigationView;
+ INavigationView toNavigationView = toElement.Element as INavigationView;
- break;
- case TransitionTypes.Zoom:
- fromAnimation.From = 1;
- fromAnimation.To = 0;
+ if (fromNavigationView != null)
+ {
+ fromNavigationView.OnNavigatedFrom();
+ }
+ if (toNavigationView != null)
+ {
+ toNavigationView.OnNavigatedTo();
+ }
- toAnimation.From = 0;
- toAnimation.To = 1;
+ INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel;
+ INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
- fromElement.AnimateScale(fromAnimation);
- toElement.AnimateScale(toAnimation);
+ if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom();
+ if (toVM != null) toVM.OnNavigatedTo();
- break;
- case TransitionTypes.Slide:
+ _onCompleted?.Invoke();
+ }
+ };
- if (toIndex > fromIndex || GalleryMode)
- {
- fromAnimation.From = 0;
- fromAnimation.To = -ActualWidth;
+ switch (TransitionType)
+ {
+ case TransitionTypes.Fade:
+ fromAnimation.From = 1;
+ fromAnimation.To = 0;
- toAnimation.From = ActualWidth;
- toAnimation.To = 0;
- }
- else
- {
- fromAnimation.From = 0;
- fromAnimation.To = ActualWidth;
+ toAnimation.From = 0;
+ toAnimation.To = 1;
- toAnimation.From = -ActualWidth;
- toAnimation.To = 0;
- }
+ fromElement.AnimateOpacity(fromAnimation);
+ toElement.AnimateOpacity(toAnimation);
- fromElement.AnimateTranslateX(fromAnimation);
- toElement.AnimateTranslateX(toAnimation);
+ break;
+ case TransitionTypes.Zoom:
+ fromAnimation.From = 1;
+ fromAnimation.To = 0;
- break;
- }
+ toAnimation.From = 0;
+ toAnimation.To = 1;
- if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade)
- {
- DoubleAnimation fromFadeAnimation = new DoubleAnimation();
- fromFadeAnimation.From = 1;
- fromFadeAnimation.To = 0;
- fromFadeAnimation.Duration = TransitionDuration;
+ fromElement.AnimateScale(fromAnimation);
+ toElement.AnimateScale(toAnimation);
- DoubleAnimation toFadeAnimation = new DoubleAnimation();
- toFadeAnimation.From = 0;
- toFadeAnimation.To = 1;
- toFadeAnimation.Duration = TransitionDuration;
+ break;
+ case TransitionTypes.Slide:
- fromElement.AnimateOpacity(fromFadeAnimation);
- toElement.AnimateOpacity(toFadeAnimation);
- }
+ if (toIndex > fromIndex)
+ {
+ fromAnimation.From = 0;
+ fromAnimation.To = -ActualWidth;
- fromElement.Activate();
- toElement.Activate();
+ toAnimation.From = ActualWidth;
+ toAnimation.To = 0;
}
else
{
- toElement.Activate();
- toElement.Reset();
-
- INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
- if (toVM != null) toVM.OnNavigatedTo();
+ fromAnimation.From = 0;
+ fromAnimation.To = ActualWidth;
- navigationCompleted = true;
+ toAnimation.From = -ActualWidth;
+ toAnimation.To = 0;
}
- }));
- for (int i = 0; i < 30; i++)
- {
- if (navigationCompleted)
- {
- break;
- }
- Thread.Sleep(100);
- }
+ fromElement.AnimateTranslateX(fromAnimation);
+ toElement.AnimateTranslateX(toAnimation);
- Dispatcher.BeginInvoke(new Action(() =>
- {
- NavigationCompleted?.Invoke();
- }));
+ break;
}
+
+ if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade)
+ {
+ DoubleAnimation fromFadeAnimation = new DoubleAnimation();
+ fromFadeAnimation.From = 1;
+ fromFadeAnimation.To = 0;
+ fromFadeAnimation.Duration = TransitionDuration;
+
+ DoubleAnimation toFadeAnimation = new DoubleAnimation();
+ toFadeAnimation.From = 0;
+ toFadeAnimation.To = 1;
+ toFadeAnimation.Duration = TransitionDuration;
+
+ fromElement.AnimateOpacity(fromFadeAnimation);
+ toElement.AnimateOpacity(toFadeAnimation);
+ }
+
+ fromElement.Activate();
+ toElement.Activate();
}
- catch
+ else
{
-
+ toElement.Activate();
+ toElement.Reset();
+
+ INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
+ if (toVM != null) toVM.OnNavigatedTo();
}
}
@@ -639,14 +547,6 @@ namespace Tango.SharedUI.Controls
protected virtual void OnSelectedElementChanged(FrameworkElement fromElement, FrameworkElement toElement)
{
Navigate(GetElementContainer(fromElement), GetElementContainer(toElement));
- SelectedElementChanged?.Invoke(this, toElement);
-
- if (toElement != null)
- {
- _preventSelectedObjectNavigation = true;
- SelectedObject = GetNavigationName(toElement);
- _preventSelectedObjectNavigation = false;
- }
}
#endregion
@@ -668,67 +568,27 @@ namespace Tango.SharedUI.Controls
return NavigateTo(navigationName, null);
}
- public FrameworkElement NavigateTo(Object obj)
- {
- return NavigateTo(obj.ToString(), null);
- }
-
public FrameworkElement NavigateTo(String navigationName, Action onCompleted = null)
{
- Action completed = null;
-
- completed = () =>
- {
- try
- {
- onCompleted?.Invoke();
- }
- catch { }
- NavigationCompleted -= completed;
- };
-
- NavigationCompleted += completed;
+ _onCompleted = onCompleted;
var element = Elements.SingleOrDefault(x => GetNavigationName(x) == navigationName || x.GetType().Name == navigationName);
- Task.Factory.StartNew(() =>
+ if (element != null)
{
- Thread.Sleep(10);
-
- Dispatcher.BeginInvoke(new Action(async () =>
+ if (SelectedElement == element)
{
- if (element != null)
- {
- if (SelectedElement == element)
- {
- await Task.Delay((int)TransitionDuration.TimeSpan.TotalMilliseconds * 2);
- NavigationCompleted?.Invoke();
- }
- else
- {
- SelectedElement = element;
- }
- }
- }));
- });
+ _onCompleted?.Invoke();
+ }
+ else
+ {
+ SelectedElement = element;
+ }
+ }
return element;
}
- public Task<FrameworkElement> NavigateToAsync(String navigationName)
- {
- TaskCompletionSource<FrameworkElement> source = new TaskCompletionSource<FrameworkElement>();
-
- FrameworkElement view = null;
-
- view = NavigateTo(navigationName, () =>
- {
- source.SetResult(view);
- });
-
- return source.Task;
- }
-
public FrameworkElement GetElement(String navigationName)
{
return Elements.SingleOrDefault(x => GetNavigationName(x) == navigationName || x.GetType().Name == navigationName);
@@ -741,11 +601,6 @@ namespace Tango.SharedUI.Controls
return element;
}
- public String GetSelectedElementNavigationName()
- {
- return GetNavigationName(SelectedElement);
- }
-
/// <remarks>
/// This method needs to be called in order for
// the element to print visibly at the correct size.
@@ -768,6 +623,7 @@ namespace Tango.SharedUI.Controls
catch { }
}
}
+
#endregion
}
}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml
new file mode 100644
index 000000000..817297191
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml
@@ -0,0 +1,113 @@
+<UserControl x:Class="Tango.SharedUI.Controls.ScriptEditorControl"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:fa="http://schemas.fontawesome.io/icons/"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d"
+ d:DesignHeight="400" d:DesignWidth="600" Background="#151515">
+
+ <UserControl.InputBindings>
+ <KeyBinding Key="F5" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=RunCommand}" />
+ </UserControl.InputBindings>
+
+ <Grid>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="40"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <Border BorderThickness="0 0 0 1" BorderBrush="#545454">
+ <ToolBar Background="#202020">
+ <StackPanel Margin="20 0 0 0" Orientation="Horizontal">
+ <Button Cursor="Hand" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SaveCommand}" ToolTip="Save" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="16">
+ <fa:ImageAwesome Icon="Save" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Rectangle Margin="20 7 10 5" HorizontalAlignment="Center" VerticalAlignment="Stretch" Stroke="#3E3E3E" StrokeThickness="2"></Rectangle>
+ <Button Cursor="Hand" Command="Undo" Margin="10 0 0 0" ToolTip="Undo" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="16">
+ <fa:ImageAwesome Icon="Undo" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Button Cursor="Hand" Command="Redo" Margin="10 0 0 0" ToolTip="Redo" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="16">
+ <fa:ImageAwesome Icon="Repeat" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Rectangle Margin="20 7 10 5" HorizontalAlignment="Center" VerticalAlignment="Stretch" Stroke="#3E3E3E" StrokeThickness="2"></Rectangle>
+ <Button Cursor="Hand" Command="Cut" Margin="10 0 0 0" ToolTip="Cut" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="16">
+ <fa:ImageAwesome Icon="Cut" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Button Cursor="Hand" Command="Copy" Margin="10 0 0 0" ToolTip="Copy" Style="{DynamicResource MetroCircleButtonStyle}" Width="20" Height="16">
+ <fa:ImageAwesome Icon="Copy" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Button Cursor="Hand" Command="Paste" Margin="10 0 0 0" ToolTip="Paste" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="20">
+ <fa:ImageAwesome Icon="Paste" Foreground="LightGray"></fa:ImageAwesome>
+ </Button>
+ <Rectangle Margin="20 7 10 5" HorizontalAlignment="Center" VerticalAlignment="Stretch" Stroke="#3E3E3E" StrokeThickness="2"></Rectangle>
+ <Button Cursor="Hand" Margin="10 0 0 0" ToolTip="Run (F5)" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=RunCommand}" Style="{DynamicResource MetroCircleButtonStyle}" Width="16" Height="16">
+ <fa:ImageAwesome Icon="Play">
+ <fa:ImageAwesome.Style>
+ <Style TargetType="fa:ImageAwesome">
+ <Setter Property="Foreground" Value="#8DD28A"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Foreground" Value="Gray"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </fa:ImageAwesome.Style>
+ </fa:ImageAwesome>
+ </Button>
+ <Button Cursor="Hand" Margin="15 0 0 0" ToolTip="Stop" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=StopCommand}" Style="{DynamicResource MetroCircleButtonStyle}" Width="14" Height="14">
+ <fa:ImageAwesome Icon="Stop">
+ <fa:ImageAwesome.Style>
+ <Style TargetType="fa:ImageAwesome">
+ <Setter Property="Foreground" Value="#F38B76"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Foreground" Value="Gray"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </fa:ImageAwesome.Style>
+ </fa:ImageAwesome>
+ </Button>
+ </StackPanel>
+ </ToolBar>
+ </Border>
+
+ <Border Grid.Row="1" CornerRadius="5" BorderThickness="0" BorderBrush="#404040">
+ <avalonEdit:TextEditor Padding="5" TextChanged="textEditor_TextChanged" Background="#151515" Foreground="Gainsboro" Margin="5 5 0 0" ScrollViewer.HorizontalScrollBarVisibility="Auto"
+ Name="textEditor"
+ FontFamily="Consolas"
+ FontSize="10pt"
+ SyntaxHighlighting="C#"
+ ShowLineNumbers="True">
+ <avalonEdit:TextEditor.ContextMenu>
+ <ContextMenu>
+ <ContextMenu.Resources>
+ <Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
+ <Setter Property="Foreground" Value="Gainsboro"></Setter>
+ </Style>
+ </ContextMenu.Resources>
+ <MenuItem Header="Cut" MinWidth="150" Command="Cut">
+ <MenuItem.Icon>
+ <fa:ImageAwesome Icon="Cut" Width="12" Foreground="Gainsboro" Margin="2" />
+ </MenuItem.Icon>
+ </MenuItem>
+ <Separator/>
+ <MenuItem Header="Copy" Command="Copy">
+ <MenuItem.Icon>
+ <fa:ImageAwesome Icon="Copy" Width="12" Foreground="Gainsboro" Margin="2" />
+ </MenuItem.Icon>
+ </MenuItem>
+ <MenuItem Header="Paste" Command="Paste">
+ <MenuItem.Icon>
+ <fa:ImageAwesome Icon="Paste" Width="12" Foreground="Gainsboro" Margin="2" />
+ </MenuItem.Icon>
+ </MenuItem>
+ </ContextMenu>
+ </avalonEdit:TextEditor.ContextMenu>
+ </avalonEdit:TextEditor>
+ </Border>
+ </Grid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
new file mode 100644
index 000000000..3fe87c7e2
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
@@ -0,0 +1,488 @@
+using ICSharpCode.AvalonEdit.CodeCompletion;
+using ICSharpCode.AvalonEdit.Document;
+using ICSharpCode.AvalonEdit.Editing;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+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 System.Windows.Threading;
+using System.Xml;
+using Tango.Core.Commands;
+using Tango.Scripting;
+using Tango.SharedUI;
+using Tango.SharedUI.Helpers;
+
+namespace Tango.SharedUI.Controls
+{
+ /// <summary>
+ /// Represents a C# script editor control.
+ /// </summary>
+ /// <seealso cref="System.Windows.Controls.UserControl" />
+ /// <seealso cref="System.Windows.Markup.IComponentConnector" />
+ public partial class ScriptEditorControl : UserControl
+ {
+ #region Completion
+
+ /// <summary>
+ /// Represents an auto complete item.
+ /// </summary>
+ /// <seealso cref="ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData" />
+ internal class CompletionData : ICompletionData
+ {
+ private String _description;
+
+ /// <summary>
+ /// Gets or sets the icon source.
+ /// </summary>
+ public BitmapSource Source { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CompletionData"/> class.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ /// <param name="description">The description.</param>
+ public CompletionData(string text, String description)
+ {
+ this.Text = text;
+ _description = description;
+ }
+
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ public System.Windows.Media.ImageSource Image
+ {
+ get { return Source; }
+ }
+
+ /// <summary>
+ /// Gets the text. This property is used to filter the list of visible elements.
+ /// </summary>
+ public string Text { get; private set; }
+
+ // Use this property if you want to show a fancy UIElement in the drop down list.
+ public object Content
+ {
+ get { return this.Text; }
+ }
+
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ public object Description
+ {
+ get { return _description; }
+ }
+
+ /// <summary>
+ /// Gets the priority. This property is used in the selection logic. You can use it to prefer selecting those items
+ /// which the user is accessing most frequently.
+ /// </summary>
+ public double Priority { get { return 0; } }
+
+ /// <summary>
+ /// Perform the completion.
+ /// </summary>
+ /// <param name="textArea">The text area on which completion is performed.</param>
+ /// <param name="completionSegment">The text segment that was used by the completion window if
+ /// the user types (segment between CompletionWindow.StartOffset and CompletionWindow.EndOffset).</param>
+ /// <param name="insertionRequestEventArgs">The EventArgs used for the insertion request.
+ /// These can be TextCompositionEventArgs, KeyEventArgs, MouseEventArgs, depending on how
+ /// the insertion was triggered.</param>
+ public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
+ {
+ textArea.Document.Replace(completionSegment, this.Text);
+ }
+
+ /// <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 Text;
+ }
+ }
+
+ #endregion
+
+ private CompletionWindow completionWindow; //Holds the auto-complete window instance.
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScriptEditorControl"/> class.
+ /// </summary>
+ public ScriptEditorControl()
+ {
+ InitializeComponent();
+
+ textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy();
+ textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
+ textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
+
+ this.Loaded += ScriptEditorControl_Loaded;
+ }
+
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the TextEntered event of the textEditor_TextArea control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="TextCompositionEventArgs"/> instance containing the event data.</param>
+ private void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
+ {
+ if (e.Text == ".")
+ {
+ String keyword = textEditor.TextArea.GetJustCurrentWord();
+
+ if (keyword != null)
+ {
+ completionWindow = new CompletionWindow(textEditor.TextArea);
+ completionWindow.WindowStyle = WindowStyle.None;
+ completionWindow.AllowsTransparency = true;
+ completionWindow.ResizeMode = ResizeMode.NoResize;
+
+ IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
+
+ bool ok = false;
+
+ List<KeyValuePair<String, Type>> types = new List<KeyValuePair<String, Type>>();
+
+ types.AddRange(IntellisenseTypes);
+
+
+ if (IntellisenseTypes != null)
+ {
+ ScriptParser parser = new ScriptParser();
+
+ try
+ {
+ var variables = parser.ParseScript(textEditor.Text);
+
+ foreach (var v in variables)
+ {
+ var hT = IntellisenseTypes.SingleOrDefault(x => x.Key == v.Type);
+
+ if (hT.Value != null)
+ {
+ types.Add(new KeyValuePair<string, Type>(v.Name, hT.Value));
+ }
+ }
+
+ }
+ catch { }
+ }
+
+ KeyValuePair<String, Type> type = types.LastOrDefault(x => keyword == x.Key);
+
+ if (type.Key != null)
+ {
+ ok = true;
+ FillType(type.Value, data);
+ }
+
+ if (ok)
+ {
+ completionWindow.Show();
+ completionWindow.Closed += delegate
+ {
+ completionWindow = null;
+ };
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Handles the TextEntering event of the textEditor_TextArea control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="TextCompositionEventArgs"/> instance containing the event data.</param>
+ private void textEditor_TextArea_TextEntering(object sender, TextCompositionEventArgs e)
+ {
+ if (e.Text.Length > 0 && completionWindow != null)
+ {
+ if (!char.IsLetterOrDigit(e.Text[0]))
+ {
+ // Whenever a non-letter is typed while the completion window is open,
+ // insert the currently selected element.
+ completionWindow.CompletionList.RequestInsertion(e);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Handles the TextChanged event of the textEditor control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
+ private void textEditor_TextChanged(object sender, EventArgs e)
+ {
+ Text = textEditor.Text;
+ }
+
+ private void ScriptEditorControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (HighlightTypes != null)
+ {
+ Stream xshd_stream = typeof(ScriptEditorControl).Assembly.GetManifestResourceStream("Tango.SharedUI.CSharp-Mode.xshd");
+
+ String text = String.Empty;
+
+ using (StreamReader reader = new StreamReader(xshd_stream))
+ {
+ text = reader.ReadToEnd();
+ }
+
+ String code = String.Empty;
+
+
+
+ foreach (var name in HighlightTypes.Select(x => x.Key))
+ {
+ code += String.Format("<Word>{0}</Word>", name) + Environment.NewLine;
+ }
+
+ text = text.Replace("@CUSTOM_TYPES@", code);
+
+ using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(text)))
+ {
+ XmlTextReader xshd_reader = new XmlTextReader(ms);
+ textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(xshd_reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance);
+ xshd_reader.Close();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Fills the type.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="data">The data.</param>
+ private void FillType(Type type, IList<ICompletionData> data)
+ {
+ List<CompletionData> items = new List<CompletionData>();
+
+ foreach (var method in type.GetMethods().Where(x => x.IsPublic && !x.IsSpecialName))
+ {
+ String desc = method.ReturnType.Name + " " + method.Name + "(" + String.Join(", ", method.GetParameters().Select(x => x.ParameterType.Name + " " + x.Name).ToArray()) + ")";
+ items.Add(new CompletionData(method.Name, desc) { Source = ResourceHelper.GetImageFromResources("Images/pubmethod.gif") });
+ }
+ foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
+ {
+ String desc = property.PropertyType.Name + " " + property.Name;
+ items.Add(new CompletionData(property.Name, desc) { Source = ResourceHelper.GetImageFromResources("Images/pubproperty.gif") });
+ }
+ foreach (var ev in type.GetEvents(BindingFlags.Instance | BindingFlags.Public))
+ {
+ try
+ {
+ String desc = ev.Name + " " + "(" + String.Join(", ", ev.EventHandlerType.GetMethod("Invoke").GetParameters().Select(x => x.ParameterType.Name + " " + x.Name).ToArray()) + ")";
+ items.Add(new CompletionData(ev.Name, desc) { Source = ResourceHelper.GetImageFromResources("Images/pubevent.gif") });
+ }
+ catch { }
+ }
+
+ foreach (var item in items.OrderBy(x => x.Text))
+ {
+ data.Add(item);
+ }
+ }
+
+ /// <summary>
+ /// Fills the assembly.
+ /// </summary>
+ /// <param name="asm">The asm.</param>
+ /// <param name="data">The data.</param>
+ private void FillAssembly(Assembly asm, IList<ICompletionData> data)
+ {
+ var q = from t in asm.GetTypes()
+ where t.IsClass
+ select t;
+
+ foreach (var type in q)
+ {
+ data.Add(new CompletionData(type.Name, "Class") { Source = ResourceHelper.GetImageFromResources("Images/pubclass.gif") });
+ }
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the text.
+ /// </summary>
+ public String Text
+ {
+ get { return (String)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+ public static readonly DependencyProperty TextProperty =
+ DependencyProperty.Register("Text", typeof(String), typeof(ScriptEditorControl), new PropertyMetadata(null, (d, e) => (d as ScriptEditorControl).OnTextChanged()));
+
+ /// <summary>
+ /// Gets or sets the highlight types.
+ /// </summary>
+ public ObservableCollection<KeyValuePair<string, Type>> HighlightTypes
+ {
+ get { return (ObservableCollection<KeyValuePair<string, Type>>)GetValue(HighlightTypesProperty); }
+ set { SetValue(HighlightTypesProperty, value); }
+ }
+ public static readonly DependencyProperty HighlightTypesProperty =
+ DependencyProperty.Register("HighlightTypes", typeof(ObservableCollection<KeyValuePair<string, Type>>), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the intellisense types.
+ /// </summary>
+ public ObservableCollection<KeyValuePair<String,Type>> IntellisenseTypes
+ {
+ get { return (ObservableCollection<KeyValuePair<String,Type>>)GetValue(IntellisenseTypesProperty); }
+ set { SetValue(IntellisenseTypesProperty, value); }
+ }
+ public static readonly DependencyProperty IntellisenseTypesProperty =
+ DependencyProperty.Register("IntellisenseTypes", typeof(ObservableCollection<KeyValuePair<String,Type>>), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+
+ #endregion
+
+ #region Virtual Methods
+
+ /// <summary>
+ /// Called when the text has changed.
+ /// </summary>
+ protected virtual void OnTextChanged()
+ {
+ if (textEditor.Text != Text)
+ {
+ textEditor.Text = Text;
+ }
+ }
+
+ /// <summary>
+ /// Called when the insert script command has changed.
+ /// </summary>
+ protected virtual void OnInsertScriptCommandChanged()
+ {
+ if (InsertSnippetCommand != null)
+ {
+ InsertSnippetCommand.Executed += (x, snippet) =>
+ {
+ textEditor.Document.Insert(textEditor.TextArea.Caret.Offset, snippet);
+ };
+ }
+ }
+
+ #endregion
+
+ #region Commands
+
+ /// <summary>
+ /// Gets or sets the run command.
+ /// </summary>
+ public RelayCommand RunCommand
+ {
+ get { return (RelayCommand)GetValue(RunCommandProperty); }
+ set { SetValue(RunCommandProperty, value); }
+ }
+ public static readonly DependencyProperty RunCommandProperty =
+ DependencyProperty.Register("RunCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the stop command.
+ /// </summary>
+ public RelayCommand StopCommand
+ {
+ get { return (RelayCommand)GetValue(StopCommandProperty); }
+ set { SetValue(StopCommandProperty, value); }
+ }
+ public static readonly DependencyProperty StopCommandProperty =
+ DependencyProperty.Register("StopCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the save command.
+ /// </summary>
+ public RelayCommand SaveCommand
+ {
+ get { return (RelayCommand)GetValue(SaveCommandProperty); }
+ set { SetValue(SaveCommandProperty, value); }
+ }
+ public static readonly DependencyProperty SaveCommandProperty =
+ DependencyProperty.Register("SaveCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the insert snippet command.
+ /// </summary>
+ public RelayCommand<String> InsertSnippetCommand
+ {
+ get { return (RelayCommand<String>)GetValue(InsertSnippetCommandProperty); }
+ set { SetValue(InsertSnippetCommandProperty, value); }
+ }
+ public static readonly DependencyProperty InsertSnippetCommandProperty =
+ DependencyProperty.Register("InsertSnippetCommand", typeof(RelayCommand<String>), typeof(ScriptEditorControl), new PropertyMetadata(null, (d, e) => (d as ScriptEditorControl).OnInsertScriptCommandChanged()));
+
+ #endregion
+ }
+
+ internal static class DocumentUtils
+ {
+ private static Regex _wordRegex = new Regex(@"[^\W\d][\w]*(?<=\w)", RegexOptions.Compiled);
+
+ public static string GetJustCurrentWord(this TextArea textArea)
+ {
+ try
+ {
+ DocumentLine line = textArea.Document.GetLineByNumber(textArea.Caret.Line);
+ if (line.Length == 0)
+ return null;
+
+ int lineCaretPosition = textArea.Caret.Offset - line.Offset;
+ String l = textArea.Document.GetText(line);
+
+ String trimmed = l.Remove(lineCaretPosition, l.Length - lineCaretPosition);
+
+ return SplitToWords(trimmed).LastOrDefault(x => !String.IsNullOrWhiteSpace(x));
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public static List<String> SplitToWords(String text)
+ {
+ text = text.Replace(".", " ");
+ text = text.Replace("(", " ");
+ text = text.Replace(")", " ");
+ text = text.Replace(",", " ");
+ var punctuation = text.Where(Char.IsPunctuation).Distinct().ToArray();
+ var words = text.Split().Select(x => x.Trim(punctuation));
+ return words.ToList();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs
deleted file mode 100644
index 1f2856a32..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
-using System.Windows.Data;
-using System.Windows.Input;
-using System.Linq;
-using System.Windows.Media;
-using System.Windows.Threading;
-using Tango.Core.ExtensionMethods;
-
-namespace Tango.SharedUI.Controls
-{
- public class SearchComboBox : ComboBox
- {
- private TextBox _textBox;
- private ListBox _listBox;
- private ICollectionView _view;
-
- public bool IsOpened
- {
- get { return (bool)GetValue(IsOpenedProperty); }
- set { SetValue(IsOpenedProperty, value); }
- }
- public static readonly DependencyProperty IsOpenedProperty =
- DependencyProperty.Register("IsOpened", typeof(bool), typeof(SearchComboBox), new PropertyMetadata(false, (d, e) => (d as SearchComboBox).OnIsOpenedChanged()));
-
- public String SearchProperty
- {
- get { return (String)GetValue(SearchPropertyProperty); }
- set { SetValue(SearchPropertyProperty, value); }
- }
- public static readonly DependencyProperty SearchPropertyProperty =
- DependencyProperty.Register("SearchProperty", typeof(String), typeof(SearchComboBox), new PropertyMetadata(null));
-
- public String SearchFilter
- {
- get { return (String)GetValue(SearchFilterProperty); }
- set { SetValue(SearchFilterProperty, value); }
- }
- public static readonly DependencyProperty SearchFilterProperty =
- DependencyProperty.Register("SearchFilter", typeof(String), typeof(SearchComboBox), new PropertyMetadata(null, (d, e) => (d as SearchComboBox).OnFilterChanged()));
-
- public IEnumerable ListItemsSource
- {
- get { return (IEnumerable)GetValue(ListItemsSourceProperty); }
- set { SetValue(ListItemsSourceProperty, value); }
- }
- public static readonly DependencyProperty ListItemsSourceProperty =
- DependencyProperty.Register("ListItemsSource", typeof(IEnumerable), typeof(SearchComboBox), new PropertyMetadata(null));
-
-
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- _textBox = GetTemplateChild("txt") as TextBox;
- _listBox = GetTemplateChild("list") as ListBox;
- _textBox.PreviewKeyDown += _textBox_KeyDown;
- _listBox.PreviewKeyDown += _listBox_PreviewKeyDown;
-
- _listBox.PreviewMouseLeftButtonUp += _listBox_PreviewMouseLeftButtonUp;
-
- KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.Once);
- }
-
- private void _listBox_PreviewKeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Return)
- {
- IsOpened = false;
- SelectedItem = _listBox.SelectedItem;
-
- if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null)
- {
- SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath);
- }
- }
- else if (e.Key == Key.Up && _listBox.SelectedIndex == 0)
- {
- _textBox.Focus();
- Keyboard.Focus(_textBox);
- }
- }
-
- private void _textBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Down)
- {
- e.Handled = true;
- FocusList();
- }
- }
-
- private void FocusList()
- {
- if (!String.IsNullOrWhiteSpace(SearchFilter))
- {
- _listBox.SelectedIndex = 0;
- }
-
- Keyboard.Focus(_listBox);
-
- if (_listBox.SelectedIndex != -1)
- {
- var container = _listBox.ItemContainerGenerator.ContainerFromIndex(_listBox.SelectedIndex) as UIElement;
- if (container != null)
- {
- container.Focus();
- Keyboard.Focus(container);
- }
- }
-
- _listBox.ScrollIntoView(_listBox.SelectedItem);
- }
-
- private void _listBox_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- if (_listBox.SelectedItem != null)
- {
- if (SelectedItem != _listBox.SelectedItem)
- {
- IsOpened = false;
- SelectedItem = _listBox.SelectedItem;
-
- if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null)
- {
- SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath);
- }
- }
- }
- }
-
- private async void OnIsOpenedChanged()
- {
- if (IsOpened)
- {
- SearchFilter = String.Empty;
- _listBox.SelectedItem = SelectedItem;
- _listBox.ScrollIntoView(_listBox.SelectedItem);
- await Task.Delay(100);
- _textBox.Focus();
- Keyboard.Focus(_textBox);
- }
- }
-
- protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
- {
- base.OnItemsSourceChanged(oldValue, newValue);
-
- if (ItemsSource != null)
- {
- ListItemsSource = ItemsSource.Cast<Object>().ToList();
-
- _view = CollectionViewSource.GetDefaultView(ListItemsSource);
- _view.Filter = (x) =>
- {
- if (String.IsNullOrWhiteSpace(SearchFilter) || SearchFilter == null) return true;
-
- if (x != null)
- {
- if (!String.IsNullOrWhiteSpace(SearchProperty))
- {
- var prop = x.GetType().GetProperty(SearchProperty, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
- if (prop != null)
- {
- String propValue = prop.GetValue(x).ToString();
- return propValue.ToLower().Contains(SearchFilter.ToLower());
- }
- }
-
- return x.ToStringSafe().ToLower().Contains(SearchFilter.ToLower());
- }
-
- return false;
- };
- }
- }
-
- private void OnFilterChanged()
- {
- _view?.Refresh();
-
- if (_listBox != null && _listBox.Items.Count > 0)
- {
- _listBox.ScrollIntoView(_listBox.Items[0]);
- }
- }
-
- protected override void OnPreviewKeyDown(KeyEventArgs e)
- {
- //base.OnPreviewKeyDown(e);
- e.Handled = false;
- }
-
- protected override void OnPreviewKeyUp(KeyEventArgs e)
- {
- //base.OnPreviewKeyUp(e);
- e.Handled = false;
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- //base.OnKeyDown(e);
- e.Handled = false;
- }
-
- protected override void OnKeyUp(KeyEventArgs e)
- {
- //base.OnKeyUp(e);
- e.Handled = false;
- }
-
- protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
- {
- e.Handled = true;
-
- if (!_listBox.IsFocused)
- {
- FocusList();
- }
-
- if (e.Delta > 0)
- {
- _listBox.RaiseEvent(
- new KeyEventArgs(
- System.Windows.Input.Keyboard.PrimaryDevice,
- PresentationSource.FromVisual(_listBox), 0, Key.Down)
- { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent });
-
- _listBox.RaiseEvent(
- new KeyEventArgs(
- System.Windows.Input.Keyboard.PrimaryDevice,
- PresentationSource.FromVisual(_listBox), 0, Key.Down)
- { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent });
- }
- else
- {
- _listBox.RaiseEvent(
- new KeyEventArgs(
- System.Windows.Input.Keyboard.PrimaryDevice,
- PresentationSource.FromVisual(_listBox), 0, Key.Up)
- { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent });
-
- _listBox.RaiseEvent(
- new KeyEventArgs(
- System.Windows.Input.Keyboard.PrimaryDevice,
- PresentationSource.FromVisual(_listBox), 0, Key.Up)
- { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent });
- }
- //base.OnPreviewMouseWheel(e);
- }
-
- protected override void OnMouseWheel(MouseWheelEventArgs e)
- {
- e.Handled = true;
- //base.OnMouseWheel(e);
- }
-
- static SearchComboBox()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchComboBox), new FrameworkPropertyMetadata(typeof(SearchComboBox)));
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs
index d26ea5a0a..5a2975535 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs
@@ -39,7 +39,7 @@ namespace Tango.SharedUI.Converters
long bytes = Math.Abs(byteCount);
int place = System.Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
- return (Math.Sign(byteCount) * num).ToString() + " " + suf[place];
+ return (Math.Sign(byteCount) * num).ToString() + suf[place];
}
}
}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs
deleted file mode 100644
index 7ce4a6532..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/DateTimeUtcToLocalDateTime.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class DateTimeUtcToLocalDateTime : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- return ((DateTime)value).ToLocalTime();
- }
- catch
- {
- return value;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs
deleted file mode 100644
index 8d62178c7..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class EmptyStringToNullConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value != null)
- {
- if (String.IsNullOrWhiteSpace(value.ToString()))
- {
- return null;
- }
- }
-
- return value;
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToIntConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToIntConverter.cs
deleted file mode 100644
index 43caff16c..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToIntConverter.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class EnumToIntConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (int)value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return Enum.ToObject(targetType, value);
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs
index 5c725e524..c551f7d49 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs
@@ -10,17 +10,6 @@ namespace Tango.SharedUI.Converters
{
public class EnumToItemsSourceConverter : IValueConverter
{
- public class EnumValue
- {
- public Object Value { get; set; }
- public String DisplayName { get; set; }
-
- public override string ToString()
- {
- return DisplayName;
- }
- }
-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Type result = value as Type;
@@ -31,7 +20,7 @@ namespace Tango.SharedUI.Converters
}
else
{
- return Enum.GetValues(result).Cast<object>().Select(e => new EnumValue() { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList();
+ return Enum.GetValues(result).Cast<object>().Select(e => new { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList();
}
}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/FilePathToFileNameConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/FilePathToFileNameConverter.cs
deleted file mode 100644
index 7c59f8de7..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/FilePathToFileNameConverter.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class FilePathToFileNameConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- if (value != null)
- {
- return Path.GetFileName(value.ToString());
- }
- }
- catch
- {
- return value;
- }
-
- return value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs
deleted file mode 100644
index 11b58d3fd..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-using Tango.PMR.Integration;
-
-namespace Tango.SharedUI.Converters
-{
- public class GenericMessageProtocolToStringConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- if (value != null)
- {
- GenericMessageProtocol protocol = (GenericMessageProtocol)value;
-
- if (protocol == GenericMessageProtocol.Json)
- {
- return "v1";
- }
- else
- {
- return "v2";
- }
- }
- }
- catch { }
-
- return "Unspecified";
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualToVisibilityConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualToVisibilityConverter.cs
deleted file mode 100644
index 846e0505f..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualToVisibilityConverter.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class IsEqualToVisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- return value.Equals(System.Convert.ChangeType(parameter, value.GetType())) ? Visibility.Visible : Visibility.Collapsed;
- }
- catch
- {
- return Visibility.Collapsed;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/IsToStringEqualToVisibilityConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/IsToStringEqualToVisibilityConverter.cs
deleted file mode 100644
index 478b21c09..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/IsToStringEqualToVisibilityConverter.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class IsToStringEqualToVisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value.ToStringSafe().Equals(parameter.ToStringSafe());
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs
deleted file mode 100644
index a2363575a..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class ObservableCollectionToViewSourceConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- String sortMember = parameter != null ? parameter.ToString() : null;
- IList list = value as IList;
- if (list != null)
- {
- var view = CollectionViewSource.GetDefaultView(list);
- view.SortDescriptions.Clear();
-
- //Delay because the DataGrid clears the sort description after source change.
- Task.Factory.StartNew(() =>
- {
- Thread.Sleep(10);
-
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- view.SortDescriptions.Add(new SortDescription(sortMember, ListSortDirection.Ascending));
- view.Refresh();
- }));
- });
- return view;
- }
-
- return value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs
index 7e534d7f0..f5b4dea87 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs
@@ -14,14 +14,7 @@ namespace Tango.SharedUI.Converters
{
try
{
- if (value != null)
- {
- return value.ToString().Ellipsis(System.Convert.ToInt32(parameter));
- }
- else
- {
- return value;
- }
+ return value.ToString().Ellipsis(System.Convert.ToInt32(parameter));
}
catch
{
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs
deleted file mode 100644
index da5717875..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class StringToOneLineConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value != null)
- {
- string str = value.ToString();
- int newLineIndex = str.IndexOf("\n");
-
- if (newLineIndex == -1)
- {
- newLineIndex = str.IndexOf(Environment.NewLine);
- }
-
- string firstline = str;
-
- if (newLineIndex > 0)
- {
- firstline = str.Substring(0, newLineIndex);
- }
-
- if (parameter != null)
- {
- firstline = firstline.Ellipsis(System.Convert.ToInt32(parameter));
- }
-
- return firstline.Trim();
- }
- else
- {
- return value;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToTitleCaseConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToTitleCaseConverter.cs
deleted file mode 100644
index 6bafd1fd0..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToTitleCaseConverter.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class StringToTitleCaseConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value != null)
- {
- return value.ToString().ToTitleCase();
- }
- else
- {
- return value;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToDaysConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToDaysConverter.cs
deleted file mode 100644
index d9256ac08..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToDaysConverter.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class TimeSpanToDaysConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return ((TimeSpan)value).TotalDays;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return TimeSpan.FromDays(double.Parse(value.ToString()));
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToMinutesConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToMinutesConverter.cs
deleted file mode 100644
index c81c54eed..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToMinutesConverter.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class TimeSpanToMinutesConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return ((TimeSpan)value).TotalMinutes;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return TimeSpan.FromMinutes(double.Parse(value.ToString()));
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToSecondsConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToSecondsConverter.cs
deleted file mode 100644
index 6632ac27d..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToSecondsConverter.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
-
-namespace Tango.SharedUI.Converters
-{
- public class TimeSpanToSecondsConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return ((TimeSpan)value).TotalSeconds;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return TimeSpan.FromSeconds(double.Parse(value.ToString()));
- }
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs
index 8946020bf..fb162d29b 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs
@@ -12,9 +12,6 @@ namespace Tango.SharedUI.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (value == null)
- return "";
-
TimeSpan time = (TimeSpan)value;
if (time.TotalHours > 1)
diff --git a/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs b/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs
index ae6d54bc6..3154be545 100644
--- a/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs
@@ -24,7 +24,7 @@ namespace Tango.SharedUI
{
CanClose = true;
CloseCommand = new RelayCommand(Cancel, (x) => CanClose);
- OKCommand = new RelayCommand(Accept, (x) => CanOK());
+ OKCommand = new RelayCommand(Accept, (x) => CanClose && CanOK());
}
private bool _canClose;
@@ -37,17 +37,6 @@ namespace Tango.SharedUI
set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
- private bool _isVisible;
- /// <summary>
- /// Gets or sets a value indicating whether this instance is visible.
- /// </summary>
- public bool IsVisible
- {
- get { return _isVisible; }
- set { _isVisible = value; RaisePropertyChangedAuto(); }
- }
-
-
/// <summary>
/// Determines whether this instance can invoke the OK command.
/// </summary>
@@ -76,7 +65,7 @@ namespace Tango.SharedUI
/// </summary>
public virtual void OnShow()
{
- IsVisible = true;
+
}
/// <summary>
@@ -84,7 +73,6 @@ namespace Tango.SharedUI
/// </summary>
protected virtual void Accept()
{
- IsVisible = false;
DialogResult = true;
Accepted?.Invoke();
}
@@ -94,25 +82,7 @@ namespace Tango.SharedUI
/// </summary>
protected virtual void Cancel()
{
- IsVisible = false;
Canceled?.Invoke();
}
-
- /// <summary>
- /// Closes the dialog with the specified result.
- /// </summary>
- /// <param name="result">if set to <c>true</c> accepted.</param>
- public void Close(bool result)
- {
- DialogResult = result;
- if (result)
- {
- Accept();
- }
- else
- {
- Cancel();
- }
- }
}
}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs b/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs
deleted file mode 100644
index 80c847a45..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-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.Input;
-
-namespace Tango.SharedUI.Helpers
-{
- public static class DataGridHelper
- {
- #region DoubleClickCommand
-
- /// <summary>
- /// Determines whether an element is DoubleClickCommand by the drag and drop service.
- /// </summary>
- public static readonly DependencyProperty DoubleClickCommandProperty =
- DependencyProperty.RegisterAttached("DoubleClickCommand",
- typeof(ICommand), typeof(DataGridHelper),
- new FrameworkPropertyMetadata(null, DoubleClickCommandChanged));
-
- /// <summary>
- /// DoubleClickCommand changed.
- /// </summary>
- /// <param name="d">The d.</param>
- /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
- private static void DoubleClickCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs xx)
- {
- if (xx.NewValue != null)
- {
- var dataGrid = d as DataGrid;
-
- dataGrid.MouseDoubleClick += (x, e) =>
- {
- if (dataGrid.SelectedItem != null && (e.OriginalSource as UIElement != null) && (e.OriginalSource as FrameworkElement).DataContext == dataGrid.SelectedItem)
- {
- (xx.NewValue as ICommand)?.Execute(dataGrid.SelectedItem);
- }
- };
- }
- }
-
- /// <summary>
- /// Sets the DoubleClickCommand attached property.
- /// </summary>
- /// <param name="dataGrid">The element.</param>
- /// <param name="value">if set to <c>true</c> [value].</param>
- public static void SetDoubleClickCommand(DataGrid dataGrid, ICommand value)
- {
- dataGrid.SetValue(DoubleClickCommandProperty, value);
- }
-
- /// <summary>
- /// Gets the DoubleClickCommand attached property.
- /// </summary>
- /// <param name="dataGrid">The element.</param>
- /// <returns></returns>
- public static ICommand GetDoubleClickCommand(DataGrid dataGrid)
- {
- return (ICommand)dataGrid.GetValue(DoubleClickCommandProperty);
- }
-
- #endregion
- }
-}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Images/PinClose_Black.png b/Software/Visual_Studio/Tango.SharedUI/Images/PinClose_Black.png
deleted file mode 100644
index abf709cb5..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Images/PinClose_Black.png
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
index e4dc72746..4ee00a06e 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
+++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
@@ -64,30 +64,25 @@
<Compile Include="..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
- <Compile Include="Binding\BindingEventArgs.cs" />
- <Compile Include="Binding\BindingEventContainer.cs" />
- <Compile Include="Binding\BindingProperty.cs" />
- <Compile Include="Components\BindingProxy.cs" />
<Compile Include="Components\SelectedObject.cs" />
<Compile Include="Components\SelectedObjectCollection.cs" />
<Compile Include="Components\TextController.cs" />
<Compile Include="Controls\AdornerContentPresenter.cs" />
- <Compile Include="Controls\AllSelectedCheckboxList.cs" />
<Compile Include="Controls\DoubleClickDataGrid.cs" />
<Compile Include="Controls\FastTextBlock.cs" />
<Compile Include="Controls\HexagonControl.cs" />
<Compile Include="Controls\HiveControl.xaml.cs">
<DependentUpon>HiveControl.xaml</DependentUpon>
</Compile>
- <Compile Include="Controls\MultiSelectComboBox.cs" />
- <Compile Include="Controls\MultiSelectComboBoxItem.cs" />
<Compile Include="Controls\MultiSelectDataGrid.cs" />
<Compile Include="Controls\MultiSelectListBox.cs" />
<Compile Include="Controls\MultiTransitionControl.xaml.cs">
<DependentUpon>MultiTransitionControl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\NavigationControl.cs" />
- <Compile Include="Controls\SearchComboBox.cs" />
+ <Compile Include="Controls\ScriptEditorControl.xaml.cs">
+ <DependentUpon>ScriptEditorControl.xaml</DependentUpon>
+ </Compile>
<Compile Include="Controls\SpannedUniformGrid.cs" />
<Compile Include="Controls\TableGrid.cs" />
<Compile Include="Controls\TransitionTypeEnum.cs" />
@@ -100,33 +95,25 @@
<Compile Include="Converters\ColorComponentToOpacityConverter.cs" />
<Compile Include="Converters\ColorToComponentsConverter.cs" />
<Compile Include="Converters\ColorToIntegerConverter.cs" />
- <Compile Include="Converters\DateTimeUtcToLocalDateTime.cs" />
<Compile Include="Converters\DateTimeUTCToShortDateConverter.cs" />
<Compile Include="Converters\DateTimeUTCToShortDateTimeConverter.cs" />
<Compile Include="Converters\DateTimeUTCToStringConverter.cs" />
<Compile Include="Converters\DisplayMemberPathConverter.cs" />
<Compile Include="Converters\DoubleToIntConverter.cs" />
- <Compile Include="Converters\EmptyStringToNullConverter.cs" />
<Compile Include="Converters\EnumToBooleanConverter.cs" />
<Compile Include="Converters\EnumToDescriptionConverter.cs" />
- <Compile Include="Converters\EnumToIntConverter.cs" />
<Compile Include="Converters\EnumToItemsSourceConverter.cs" />
<Compile Include="Converters\EnumToVisibilityConverter.cs" />
<Compile Include="Converters\EnumToXamlVectorConverter.cs" />
- <Compile Include="Converters\FilePathToFileNameConverter.cs" />
- <Compile Include="Converters\GenericMessageProtocolToStringConverter.cs" />
<Compile Include="Converters\IsEqualConverter.cs" />
- <Compile Include="Converters\IsEqualToVisibilityConverter.cs" />
<Compile Include="Converters\IsNotConverter.cs" />
<Compile Include="Converters\IsNullToVisibilityConverter.cs" />
<Compile Include="Converters\IsSegmentGradientConverter.cs" />
<Compile Include="Converters\IsSegmentGradientToVisibilityConverter.cs" />
- <Compile Include="Converters\IsToStringEqualToVisibilityConverter.cs" />
<Compile Include="Converters\LastItemInContainerToBooleanConverter.cs" />
<Compile Include="Converters\MathOperatorConverter.cs" />
<Compile Include="Converters\NumberToFileSizeConverter.cs" />
<Compile Include="Converters\ObjectToObjectTypeConverter.cs" />
- <Compile Include="Converters\ObservableCollectionToViewSourceConverter.cs" />
<Compile Include="Converters\OneToPercentConverter.cs" />
<Compile Include="Converters\SegmentLengthToWidthConverter.cs" />
<Compile Include="Converters\SegmentToBrushConverter.cs" />
@@ -142,12 +129,7 @@
<Compile Include="Converters\StringFormatConverter.cs" />
<Compile Include="Converters\StringNullOrEmptyToBooleanConverter.cs" />
<Compile Include="Converters\StringToLinesConverter.cs" />
- <Compile Include="Converters\StringToOneLineConverter.cs" />
- <Compile Include="Converters\StringToTitleCaseConverter.cs" />
<Compile Include="Converters\StringToWordsConverter.cs" />
- <Compile Include="Converters\TimeSpanToDaysConverter.cs" />
- <Compile Include="Converters\TimeSpanToMinutesConverter.cs" />
- <Compile Include="Converters\TimeSpanToSecondsConverter.cs" />
<Compile Include="Converters\TimeSpanToTwoDigitsTimeConverter.cs" />
<Compile Include="Converters\VersionToShortVersionConverter.cs" />
<Compile Include="Converters\WidthHeightToRectConverter.cs" />
@@ -162,8 +144,6 @@
</Compile>
<Compile Include="Effects\DisplaySettingEffect.cs" />
<Compile Include="ExtensionMethods\FrameworkElementExtensions.cs" />
- <Compile Include="Animations\GridLengthAnimation.cs" />
- <Compile Include="Helpers\DataGridHelper.cs" />
<Compile Include="Helpers\PasswordHelper.cs" />
<Compile Include="Helpers\ResourceHelper.cs" />
<Compile Include="Helpers\UIHelper.cs" />
@@ -210,19 +190,19 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="Editors\ParameterItemNumericUpDownEditor.xaml">
+ <Page Include="Controls\ScriptEditorControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="Editors\ParameterizedEditor.xaml">
+ <Page Include="Editors\ParameterItemNumericUpDownEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="Rendering\RenderWindow.xaml">
+ <Page Include="Editors\ParameterizedEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="Themes\Generic.xaml">
+ <Page Include="Rendering\RenderWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
@@ -250,14 +230,11 @@
<Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project>
<Name>Tango.DragAndDrop</Name>
</ProjectReference>
- <ProjectReference Include="..\Tango.PMR\Tango.PMR.csproj">
- <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project>
- <Name>Tango.PMR</Name>
+ <ProjectReference Include="..\Tango.Scripting\Tango.Scripting.csproj">
+ <Project>{401989E7-AE1E-4002-B0EE-9A9F63740B97}</Project>
+ <Name>Tango.Scripting</Name>
</ProjectReference>
</ItemGroup>
- <ItemGroup>
- <Resource Include="Images\PinClose_Black.png" />
- </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
diff --git a/Software/Visual_Studio/Tango.SharedUI/Themes/Generic.xaml b/Software/Visual_Studio/Tango.SharedUI/Themes/Generic.xaml
deleted file mode 100644
index ec9e86d07..000000000
--- a/Software/Visual_Studio/Tango.SharedUI/Themes/Generic.xaml
+++ /dev/null
@@ -1,142 +0,0 @@
-<ResourceDictionary
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:fa="http://schemas.fontawesome.io/icons/"
- xmlns:local="clr-namespace:Tango.SharedUI.Controls">
-
- <local:MultiSelectComboBoxTemplateSelector x:Key="MultiSelectComboBoxTemplateSelector" />
-
- <Style TargetType="{x:Type local:MultiSelectComboBox}">
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type local:MultiSelectComboBox}">
- <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto"/>
- </Grid.ColumnDefinitions>
- <ToggleButton x:Name="MultiSelToggleButton" Grid.Column="0" MinHeight="40" Height="Auto"
- VerticalAlignment="Center"
- HorizontalAlignment="Stretch" Margin="4,0,0,0" SnapsToDevicePixels="True"
- Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}"
- IsChecked="{Binding IsToggleChecked, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
- >
- <ToggleButton.Template>
- <ControlTemplate TargetType="ToggleButton">
- <Grid x:Name="grid" >
- <ScrollViewer VerticalScrollBarVisibility="Auto" >
- <ScrollViewer.Resources>
- <Style TargetType="ScrollBar">
- <Setter Property="Width" Value="6"/>
- <Setter Property="MinWidth" Value="6" />
- </Style>
- </ScrollViewer.Resources>
- <ItemsControl x:Name="SelectedItemsControl" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=SelectedItemsList}"
- ItemTemplateSelector="{StaticResource MultiSelectComboBoxTemplateSelector}" MinHeight="20" VerticalAlignment="Stretch">
- <ItemsControl.Resources>
- <DataTemplate x:Key="CheckItem">
- <Button Margin="2" Height="25" Width="Auto" Background="Transparent" BorderThickness="0.5" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=BorderBrush}"
- Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=RemoveItemCommand}" CommandParameter="{Binding}">
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Text}" VerticalAlignment="Center" Margin="2"/>
- <Image Source="/Tango.SharedUI;component/Images/PinClose_Black.png" Width="10" Margin="2 2 2 0" VerticalAlignment="Center" HorizontalAlignment="Right" />
- </StackPanel>
- </Button>
- </DataTemplate>
- <DataTemplate x:Key="SearchItem">
- <TextBox x:Name="Edit_PART" Height="25" MinWidth="20" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" BorderBrush="Transparent" VerticalContentAlignment="Center" BorderThickness="0"
- Text="{Binding Text}" Margin="2" Background="{Binding Path=BorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}"/>
- </DataTemplate>
- </ItemsControl.Resources>
- <ItemsControl.Template>
- <ControlTemplate TargetType="{x:Type ItemsControl}">
- <ItemsPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
- </ControlTemplate>
- </ItemsControl.Template>
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel IsItemsHost="True" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left"/>
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- </ItemsControl>
- </ScrollViewer>
- </Grid>
- </ControlTemplate>
- </ToggleButton.Template>
- </ToggleButton>
- <Button Grid.Column=" 1" BorderBrush="Transparent" Opacity="0.2" VerticalContentAlignment="Top" Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=RemoveAllCommand}" Width="20">
- <Grid VerticalAlignment="Top">
- <Grid.RowDefinitions>
- <RowDefinition Height="15" />
- <RowDefinition Height="*" />
- </Grid.RowDefinitions>
- <Image Grid.Row="0" Source="/Tango.SharedUI;component/Images/PinClose_Black.png" MinWidth="10" Margin="0" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
- </Grid>
- <Button.Style>
- <Style TargetType="Button">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border Background="{TemplateBinding Background}">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="Transparent" />
- <Setter Property="BorderBrush" Value="Transparent"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="False">
- <Setter Property="Background" Value="Transparent" />
- <Setter Property="BorderBrush" Value="Transparent"/>
- </Trigger>
- <EventTrigger RoutedEvent="Control.MouseEnter">
- <BeginStoryboard>
- <Storyboard >
- <DoubleAnimation Duration="0:0:1" To="1" Storyboard.TargetProperty="Opacity"/>
- </Storyboard>
- </BeginStoryboard>
- </EventTrigger>
- <EventTrigger RoutedEvent="Control.MouseLeave">
- <BeginStoryboard>
- <Storyboard >
- <DoubleAnimation Duration="0:0:1" To="0.05" Storyboard.TargetProperty="Opacity"/>
- </Storyboard>
- </BeginStoryboard>
- </EventTrigger>
- </Style.Triggers>
- </Style>
- </Button.Style>
- </Button>
- <Popup x:Name="MultiSel_Popup" Tag="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}}" MinHeight="25" MaxHeight="600" HorizontalOffset="0" MinWidth="{TemplateBinding ActualWidth}" MaxWidth="800" Grid.ColumnSpan="2"
- PlacementTarget="{Binding ElementName=MultiSelToggleButton}" Placement="Bottom" AllowsTransparency="True"
- IsOpen="{Binding ElementName=MultiSelToggleButton,Path=IsChecked}" StaysOpen="True" PopupAnimation="Slide" >
- <Border Opacity="1" Background="{TemplateBinding Background}" Padding="3" BorderThickness="1" BorderBrush="Beige">
- <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
- <ItemsControl x:Name="PropertyDisplay" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=SearchItemsList}">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Button Margin="4,2" Height="Auto" Width="Auto" Background="Transparent" BorderThickness="0.5" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=BorderBrush}"
- Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=AddItemCommand}" CommandParameter="{Binding}">
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding}" VerticalAlignment="Center" />
- </StackPanel>
- </Button>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </Border>
- </Popup>
- </Grid>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
-</ResourceDictionary>