using System; using System.ComponentModel; namespace InABox.Core { public class ButtonEditorCommandArgs : CancelEventArgs { public String Data { get; set; } } public abstract class ButtonEditorCommand { public abstract void Execute(object sender, ButtonEditorCommandArgs args); } public class ButtonEditor : BaseEditor { private Type _commandtype; public String Label { get; set; } public ButtonEditor(Type commandtype) { if (!typeof(ButtonEditorCommand).IsAssignableFrom(commandtype)) throw new InvalidCastException("Command must be of type ButtonEditorCommand"); _commandtype = commandtype; Label = "Edit"; Alignment = Alignment.NotSet; } protected override BaseEditor DoClone() { return new ButtonEditor(_commandtype); } public ButtonEditorCommand? CreateCommand() => Activator.CreateInstance(_commandtype) as ButtonEditorCommand; } }