aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Helpers
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-30 00:56:02 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-30 00:56:02 +0300
commit091a4bdeb2feadb4962c6be5deb367ab56d81707 (patch)
tree289a672287063108b851b2831d4c699dcddd26d9 /Software/Visual_Studio/Tango.SharedUI/Helpers
parent3d6a882cf14f36297d8b379e0fdf65376064edf7 (diff)
downloadTango-091a4bdeb2feadb4962c6be5deb367ab56d81707.tar.gz
Tango-091a4bdeb2feadb4962c6be5deb367ab56d81707.zip
Implemented PPC Updates & Packages.
Moved PPC/FSE interfaces to PPC.Shared. Changes Generic Serialization to json.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Helpers')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs b/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs
new file mode 100644
index 000000000..80c847a45
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs
@@ -0,0 +1,67 @@
+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
+ }
+}