|
@@ -0,0 +1,70 @@
|
|
|
+using System;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Media;
|
|
|
+using InABox.Core;
|
|
|
+
|
|
|
+namespace InABox.DynamicGrid
|
|
|
+{
|
|
|
+ public class BlobEditorControl : DynamicEditorControl<byte[]>
|
|
|
+ {
|
|
|
+ private Button Editor;
|
|
|
+
|
|
|
+ private byte[] _data = new byte[] { };
|
|
|
+
|
|
|
+ public string? Label { get; set; }
|
|
|
+
|
|
|
+ public Action<object,BlobEditorClickArgs> OnClick { get; set; }
|
|
|
+
|
|
|
+ protected override FrameworkElement CreateEditor()
|
|
|
+ {
|
|
|
+ Editor = new Button
|
|
|
+ {
|
|
|
+ Content = Label,
|
|
|
+ HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
|
+ VerticalAlignment = VerticalAlignment.Stretch,
|
|
|
+ VerticalContentAlignment = VerticalAlignment.Center,
|
|
|
+ };
|
|
|
+ Editor.Click += Editor_Click;
|
|
|
+
|
|
|
+ return Editor;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Editor_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var args = new BlobEditorClickArgs() { Cancel = false, Data = _data };
|
|
|
+ OnClick?.Invoke(this, args);
|
|
|
+ if (!args.Cancel)
|
|
|
+ _data = args.Data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override int DesiredHeight()
|
|
|
+ {
|
|
|
+ return 25;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override int DesiredWidth()
|
|
|
+ {
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override byte[] RetrieveValue()
|
|
|
+ {
|
|
|
+ return _data;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void UpdateValue(byte[] value)
|
|
|
+ {
|
|
|
+ _data = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetFocus()
|
|
|
+ {
|
|
|
+ Editor.Focus();
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetColor(Color color)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|