refactor: ResouceView

Move ResourceView and all related to ui core namespace GSS2.UI.Core
Split ResourceView on separate elements
Make parts folding depended on size
This commit is contained in:
2026-02-06 08:19:18 +03:00
parent c0336a55fd
commit 55260e0360
16 changed files with 528 additions and 545 deletions
@@ -0,0 +1,42 @@
// Оригинальное решение для проблеммы сворачивания колнок в Grid от
// https://github.com/AvaloniaUI/Avalonia/discussions/6773#discussioncomment-1514604
using Avalonia;
using Avalonia.Controls;
namespace GSS2.UI.Core.Behaviors;
public static class GridColumnHideBehavior
{
private readonly static GridLength ZeroWidth = new GridLength(0, GridUnitType.Pixel);
private readonly static AttachedProperty<GridLength?> LastWidthProperty =
AvaloniaProperty.RegisterAttached<ColumnDefinition, GridLength?>("LastWidth", typeof(GridColumnHideBehavior), default);
public readonly static AttachedProperty<bool> IsVisibleProperty =
AvaloniaProperty.RegisterAttached<ColumnDefinition, bool>("IsVisible", typeof(GridColumnHideBehavior), true,
coerce: (element, visibility) =>
{
var lastWidth = element.GetValue(LastWidthProperty);
if (visibility && lastWidth is { })
element.SetValue(ColumnDefinition.WidthProperty, lastWidth);
else if (!visibility)
{
element.SetValue(LastWidthProperty, element.GetValue(ColumnDefinition.WidthProperty));
element.SetValue(ColumnDefinition.WidthProperty, ZeroWidth);
}
return visibility;
}
);
public static bool GetIsVisible(ColumnDefinition columnDefinition)
{
return columnDefinition.GetValue(IsVisibleProperty);
}
public static void SetIsVisible(ColumnDefinition columnDefinition, bool visibility)
{
columnDefinition.SetValue(IsVisibleProperty, visibility);
}
}