namespace InABox.Core { public delegate void EditorButtonClick(object editor, object? item); public delegate void EditorButtonClick(object editor, T? item) where T : class; public delegate void EditorButtonEnabled(bool enabled); public class EditorButton { public EditorButton(object? item, string caption, int width, EditorButtonClick onclick, bool disableeditor) { Width = width; Caption = caption; OnClick = onclick; Item = item; DisableEditor = disableeditor; IsEnabled = true; } public int Width { get; } public string Caption { get; } public object? Item { get; } public bool DisableEditor { get; } public bool IsEnabled { get; private set; } public event EditorButtonClick OnClick; public event EditorButtonEnabled OnEnabled; public void Click(object editor) { if (IsEnabled) { OnClick?.Invoke(editor, Item); } } public void SetEnabled(bool enabled) { IsEnabled = enabled; OnEnabled?.Invoke(enabled); } } }