aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-02-16 14:48:33 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-02-16 14:48:33 +0200
commite2fbc8e6047fef09681b994efe2ca1043d25ac9d (patch)
treed51c5787ec50711361d557bb060c976a5b278dcb /Software/Visual_Studio/Tango.SharedUI/Controls
parent1ae720e9052b2419200c113ad1fa42550382e6c7 (diff)
downloadTango-e2fbc8e6047fef09681b994efe2ca1043d25ac9d.tar.gz
Tango-e2fbc8e6047fef09681b994efe2ca1043d25ac9d.zip
Implement Job Runs View. Create 2 views in Statistics. Implements Part of JobRunsView.
Related Work Items: #2509
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs180
1 files changed, 180 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs
new file mode 100644
index 000000000..66eaa4e14
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/MultiSelectComboBox.cs
@@ -0,0 +1,180 @@
+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;
+
+namespace Tango.SharedUI.Controls
+{
+ public class MultiSelectComboBox : Control
+ {
+ static MultiSelectComboBox()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiSelectComboBox), new FrameworkPropertyMetadata(typeof(MultiSelectComboBox)));
+
+ }
+
+ public MultiSelectComboBox() : base()
+ {
+ RemoveAllCommand = new RelayCommand((() => SelectedItemsList.Clear()), () => SelectedItemsList != null && SelectedItemsList.Count > 0);
+ RemoveItemCommand = new RelayCommand<string>((item) => SelectedItemsList.Remove(item), () => SelectedItemsList != null);
+ AddItemCommand = new RelayCommand<string>((item) => SelectedItemsList.Add(item));
+ SearchText = "";
+ }
+
+ #region Properties
+
+ public ObservableCollection<string> SelectedItemsList
+ {
+ get { return (ObservableCollection<string>)GetValue(SelectedItemsListProperty); }
+ set { SetValue(SelectedItemsListProperty, value); }
+ }
+
+ public static readonly DependencyProperty SelectedItemsListProperty =
+ DependencyProperty.Register("SelectedItemsList", typeof(ObservableCollection<string>), typeof(MultiSelectComboBox), new PropertyMetadata(default(ObservableCollection<string>)));
+
+
+ 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 PropertyMetadata(false));
+
+
+
+ private string _searchText;
+ /// <summary>
+ /// Gets or sets the search text of TextBox.
+ /// </summary>
+ public string SearchText
+ {
+ get { return _searchText; }
+ set {_searchText = value;
+ RaisePropertyChanged("SearchText");
+ OnTextChanged();
+ }
+ }
+
+ void OnTextChanged()
+ {
+ if(SearchItemsList != null)
+ {
+ if (String.IsNullOrEmpty(SearchText))
+ SearchItemsList.Filter = null;
+ else
+ SearchItemsList.Filter = new Predicate<object>(o => ((string)o == SearchText));
+ }
+ }
+ /// <summary>
+ /// Occurs when a property has changed.
+ /// </summary>
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ /// <summary>
+ /// Raises the property changed event.
+ /// </summary>
+ /// <param name="propName">Name of the property.</param>
+ protected virtual void RaisePropertyChanged(String propName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
+ }
+
+
+ #endregion
+
+ /// <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<string>();
+ SearchItemsList = new ListCollectionView(this.Items);
+
+ //ItemsControl iControl = FindName("asd") as ItemsControl;
+ //iControl.ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged;
+ //iControl.ItemContainerGenerator.ContainerFromItem(null);
+
+ //for (int i = 0; i < iControl.Items.Count; i++)
+ //{
+ // FrameworkElement a = iControl.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;
+ //}
+ }
+
+ private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
+ {
+
+ }
+
+ #region Commands
+ /// <summary>
+ /// The remove all command property for clear SelectedItemsList
+ /// </summary>
+ public static DependencyProperty RemoveAllCommandProperty = DependencyProperty.Register("RemoveAllCommand", typeof(ICommand), typeof(MultiSelectComboBox));
+ public ICommand RemoveAllCommand
+ {
+ get { return (ICommand)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<string>), typeof(MultiSelectComboBox));
+ public RelayCommand<string> RemoveItemCommand
+ {
+ get { return (RelayCommand<string>)GetValue(RemoveItemCommandProperty); }
+ private set { SetValue(RemoveItemCommandProperty, value); }
+ }
+
+
+ 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); }
+ }
+ #endregion
+
+
+
+ }
+}