|
|
|
@ -9,6 +9,7 @@ using System.Linq; |
|
|
|
using System.Collections.Specialized; |
|
|
|
using System.Collections.Specialized; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
|
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
|
|
|
|
namespace MultiTerm.Wpf.CustomControl; |
|
|
|
namespace MultiTerm.Wpf.CustomControl; |
|
|
|
|
|
|
|
|
|
|
|
@ -57,6 +58,9 @@ public class MultiFormatDataView : Control |
|
|
|
|
|
|
|
|
|
|
|
public static readonly RoutedEvent ClearRequestedEvent; |
|
|
|
public static readonly RoutedEvent ClearRequestedEvent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty CopyCommandProperty = |
|
|
|
|
|
|
|
DependencyProperty.Register("CopyCommand", |
|
|
|
|
|
|
|
typeof(RoutedCommand), typeof(MultiFormatDataView)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// .NET Property for <see cref="DataSourceProperty"/>. |
|
|
|
/// .NET Property for <see cref="DataSourceProperty"/>. |
|
|
|
@ -114,8 +118,29 @@ public class MultiFormatDataView : Control |
|
|
|
add { this.AddHandler(ClearRequestedEvent, value); } |
|
|
|
add { this.AddHandler(ClearRequestedEvent, value); } |
|
|
|
remove { this.RemoveHandler(ClearRequestedEvent, value); } |
|
|
|
remove { this.RemoveHandler(ClearRequestedEvent, value); } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static RoutedCommand? copyCommand; |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// .NET Property for <see cref="CopyCommandProperty"/> |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public static RoutedCommand? CopyCommand |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return copyCommand; } |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MultiFormatDataView() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// register copy command |
|
|
|
|
|
|
|
copyCommand = new RoutedCommand("CopyCommand", typeof(MultiFormatDataView)); |
|
|
|
|
|
|
|
var binding = new CommandBinding |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Command = copyCommand |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
binding.Executed += CopyCommand_Executed; ; |
|
|
|
|
|
|
|
CommandBindings.Add(binding); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static MultiFormatDataView() |
|
|
|
static MultiFormatDataView() |
|
|
|
{ |
|
|
|
{ |
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiFormatDataView), new FrameworkPropertyMetadata(typeof(MultiFormatDataView))); |
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiFormatDataView), new FrameworkPropertyMetadata(typeof(MultiFormatDataView))); |
|
|
|
@ -229,6 +254,24 @@ public class MultiFormatDataView : Control |
|
|
|
RaiseEvent(args); |
|
|
|
RaiseEvent(args); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void CopyCommand_Executed(object sender, ExecutedRoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (e.Parameter.ToString()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case "Character": |
|
|
|
|
|
|
|
Clipboard.SetText(this.DataSource.GetSelectedDataAsString(Core.Types.FormatType.Character)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "Hexadecimal": |
|
|
|
|
|
|
|
Clipboard.SetText(this.DataSource.GetSelectedDataAsString(Core.Types.FormatType.Hexadecimal)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "Binary": |
|
|
|
|
|
|
|
Clipboard.SetText(this.DataSource.GetSelectedDataAsString(Core.Types.FormatType.Binary)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new ArgumentException($"'{CopyCommand_Executed}()' does not have handling implemented for CommandParameter={e.Parameter}"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region Selected Items handling |
|
|
|
#region Selected Items handling |
|
|
|
private void ItemsControl_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
|
|
private void ItemsControl_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|