65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using Lattice.Core.Docking.Abstractions;
|
|
using Lattice.Core.Docking.Models;
|
|
using Lattice.UI.Docking.Abstractions;
|
|
|
|
namespace Lattice.UI.Docking.Factories;
|
|
|
|
/// <summary>
|
|
/// Базовая фабрика для создания UI-контролов док-системы.
|
|
/// </summary>
|
|
public abstract class DockControlFactoryBase : IDockControlFactory
|
|
{
|
|
/// <summary>
|
|
/// Получает или задает сервис перетаскивания для создаваемых контролов.
|
|
/// </summary>
|
|
public Services.IDockDragDropService? DragDropService { get; set; }
|
|
|
|
/// <summary>
|
|
/// Получает или задает менеджер контекста для создаваемых контролов.
|
|
/// </summary>
|
|
public Services.IDockContextManager? ContextManager { get; set; }
|
|
|
|
/// <inheritdoc/>
|
|
public abstract IDockGroupControl CreateGroupControl(DockGroup group);
|
|
|
|
/// <inheritdoc/>
|
|
public abstract IDockLeafControl CreateLeafControl(DockLeaf leaf);
|
|
|
|
/// <inheritdoc/>
|
|
public abstract IFloatingWindowControl CreateFloatingWindowControl(DockWindow window);
|
|
|
|
/// <inheritdoc/>
|
|
public abstract IAutoHidePanelControl CreateAutoHidePanelControl(AutoHidePanel panel);
|
|
|
|
/// <inheritdoc/>
|
|
public abstract IDockSplitterControl CreateSplitterControl(SplitDirection orientation);
|
|
|
|
/// <summary>
|
|
/// Создает контрол для произвольного элемента док-системы.
|
|
/// </summary>
|
|
public virtual IDockControl? CreateControlForElement(IDockElement element)
|
|
{
|
|
return element switch
|
|
{
|
|
DockGroup group => CreateGroupControl(group),
|
|
DockLeaf leaf => CreateLeafControl(leaf),
|
|
_ => null
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Настраивает общие свойства контрола.
|
|
/// </summary>
|
|
protected virtual void ConfigureControl(IDockControl control)
|
|
{
|
|
if (DragDropService != null)
|
|
{
|
|
control.DragDropService = DragDropService;
|
|
}
|
|
|
|
if (ContextManager != null)
|
|
{
|
|
control.ContextManager = ContextManager;
|
|
}
|
|
}
|
|
} |