using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using InABox.Core; using Syncfusion.XlsIO.Parser.Biff_Records.Charts; namespace InABox.DynamicGrid { public class ButtonEditorControl : DynamicEditorControl { private Button Editor; private string _data = ""; public string? Label { get; set; } public ButtonEditorCommand? Command { 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 ButtonEditorCommandArgs() { Cancel = false, Data = _data }; Command?.Execute(this, args); if (!args.Cancel) _data = args.Data; } public override int DesiredHeight() { return 25; } public override int DesiredWidth() { return 100; } protected override string RetrieveValue() { return _data; } protected override void UpdateValue(string value) { _data = value; } public override void SetFocus() { Editor.Focus(); } public override void SetColor(Color color) { } } }