DragAndDrop core
This commit is contained in:
82
Lattice.Layout.UI.WinUI/Visuals/WinUISplitVisual.cs
Normal file
82
Lattice.Layout.UI.WinUI/Visuals/WinUISplitVisual.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Lattice.Layout.Abstractions;
|
||||
using Lattice.Layout.UI.WinUI.Controls;
|
||||
using Lattice.Layout.UI.WinUI.Docking;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Lattice.Layout.UI.WinUI.Visuals;
|
||||
|
||||
/// <summary>
|
||||
/// Визуальное представление сплит-элемента для WinUI.
|
||||
/// Управляет жизненным циклом соответствующего <see cref="WinUISplitControl"/>.
|
||||
/// </summary>
|
||||
public sealed class WinUISplitVisual : LayoutVisual, IWinUIVisual
|
||||
{
|
||||
/// <summary>
|
||||
/// Реальный WinUI-контрол, отображающий сплит.
|
||||
/// </summary>
|
||||
public WinUISplitControl SplitControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Контрол, используемый рендерером и докингом.
|
||||
/// </summary>
|
||||
public FrameworkElement Control => SplitControl;
|
||||
|
||||
/// <summary>
|
||||
/// Дочерние визуальные элементы.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ILayoutVisual> Children { get; }
|
||||
|
||||
public WinUISplitVisual(ILayoutSplit model, IReadOnlyList<ILayoutVisual> children)
|
||||
: base(model)
|
||||
{
|
||||
Children = children;
|
||||
|
||||
SplitControl = new WinUISplitControl
|
||||
{
|
||||
LayoutOrientation = model.Orientation switch
|
||||
{
|
||||
Lattice.Layout.Abstractions.Orientation.Horizontal => Microsoft.UI.Xaml.Controls.Orientation.Horizontal,
|
||||
Lattice.Layout.Abstractions.Orientation.Vertical => Microsoft.UI.Xaml.Controls.Orientation.Vertical,
|
||||
_ => Microsoft.UI.Xaml.Controls.Orientation.Horizontal
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Attach()
|
||||
{
|
||||
SplitControl.Children.Clear();
|
||||
|
||||
foreach (var child in Children)
|
||||
{
|
||||
child.Attach();
|
||||
|
||||
switch (child)
|
||||
{
|
||||
case WinUISplitVisual splitVisual:
|
||||
SplitControl.Children.Add(splitVisual.Control);
|
||||
break;
|
||||
|
||||
case WinUIGroupVisual groupVisual:
|
||||
SplitControl.Children.Add(groupVisual.Control);
|
||||
break;
|
||||
|
||||
case WinUIItemVisual itemVisual:
|
||||
SplitControl.Children.Add(itemVisual.Control);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SplitControl.RebuildGrid();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Detach()
|
||||
{
|
||||
foreach (var child in Children)
|
||||
child.Detach();
|
||||
|
||||
SplitControl.Children.Clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user