using Lattice.UI.Docking.Abstractions; namespace Lattice.UI.Docking.Commands; /// /// Базовая реализация команды док-системы. /// public abstract class DockCommandBase : IDockCommand { private bool _canExecute = true; /// public abstract string Id { get; } /// public abstract string Name { get; } /// public virtual string Description => string.Empty; /// public virtual string Icon => string.Empty; /// public virtual string Shortcut => string.Empty; /// /// Получает или задает признак возможности выполнения команды. /// public bool CanExecute { get => _canExecute; set { if (_canExecute != value) { _canExecute = value; OnCanExecuteChanged(); } } } /// public event EventHandler? CanExecuteChanged; /// public virtual bool CanExecute(object? parameter) { return _canExecute; } /// public abstract void Execute(object? parameter); /// /// Вызывает событие изменения возможности выполнения команды. /// protected virtual void OnCanExecuteChanged() { CanExecuteChanged?.Invoke(this, EventArgs.Empty); } } /// /// Базовая команда для закрытия контента. /// public class CloseContentCommand : DockCommandBase { public override string Id => "CloseContent"; public override string Name => "Close"; public override string Description => "Close the current tab"; public override string Icon => "Close"; public override string Shortcut => "Ctrl+F4"; public override void Execute(object? parameter) { if (parameter is Abstractions.IDockLeafControl leafControl && leafControl.ActiveContent != null) { leafControl.CloseContent(leafControl.ActiveContent); } } } /// /// Базовая команда для создания плавающего окна. /// public class FloatWindowCommand : DockCommandBase { public override string Id => "FloatWindow"; public override string Name => "Float"; public override string Description => "Float the window as a separate window"; public override string Icon => "Float"; public override void Execute(object? parameter) { // Реализация зависит от конкретного UI } } /// /// Базовая команда для закрепления окна. /// public class DockWindowCommand : DockCommandBase { public override string Id => "DockWindow"; public override string Name => "Dock"; public override string Description => "Dock the window to the main window"; public override string Icon => "Dock"; public override void Execute(object? parameter) { // Реализация зависит от конкретного UI } }