forked from amkovkov/GranuSightSoftware2
fix: SectionPanel resizing
This commit is contained in:
@@ -241,6 +241,40 @@ public class SectionPanel : Panel
|
|||||||
InvalidateArrange();
|
InvalidateArrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnSizeChanged(SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!_initialized ||
|
||||||
|
e.PreviousSize.Width == 0 ||
|
||||||
|
e.PreviousSize.Height == 0)
|
||||||
|
{
|
||||||
|
base.OnSizeChanged(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"{e.NewSize} {e.PreviousSize}");
|
||||||
|
|
||||||
|
foreach (var (child, i) in _childIndeces)
|
||||||
|
{
|
||||||
|
var transform = child.RenderTransform as TranslateTransform;
|
||||||
|
if (transform is null)
|
||||||
|
{
|
||||||
|
transform = new TranslateTransform();
|
||||||
|
child.RenderTransform = transform;
|
||||||
|
}
|
||||||
|
Console.WriteLine($"{i} {transform}");
|
||||||
|
if (child.RenderTransformOrigin != RelativePoint.TopLeft)
|
||||||
|
child.RenderTransformOrigin = RelativePoint.TopLeft;
|
||||||
|
|
||||||
|
_ = Orientation switch
|
||||||
|
{
|
||||||
|
Orientation.Vertical => transform.Y += transform.Y == 0 ? 0 : e.PreviousSize.Height - e.NewSize.Height,
|
||||||
|
Orientation.Horizontal => transform.X += transform.X == 0 ? 0 : e.PreviousSize.Width - e.NewSize.Width,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
Console.WriteLine($"{i} {transform}");
|
||||||
|
}
|
||||||
|
base.OnSizeChanged(e);
|
||||||
|
}
|
||||||
protected override Size MeasureOverride(Size availableSize)
|
protected override Size MeasureOverride(Size availableSize)
|
||||||
{
|
{
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
@@ -252,6 +286,11 @@ public class SectionPanel : Panel
|
|||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
{
|
{
|
||||||
foreach (var (i, child) in Children.Enumerate())
|
foreach (var (i, child) in Children.Enumerate())
|
||||||
|
_childIndeces.Add(child, i);
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (child, i) in _childIndeces)
|
||||||
{
|
{
|
||||||
var rect = Orientation switch
|
var rect = Orientation switch
|
||||||
{
|
{
|
||||||
@@ -259,12 +298,9 @@ public class SectionPanel : Panel
|
|||||||
Orientation.Horizontal => new Rect(i * finalSize.Width, 0, finalSize.Width, finalSize.Height),
|
Orientation.Horizontal => new Rect(i * finalSize.Width, 0, finalSize.Width, finalSize.Height),
|
||||||
_ => default
|
_ => default
|
||||||
};
|
};
|
||||||
_childIndeces.Add(child, i);
|
|
||||||
child.Arrange(rect);
|
child.Arrange(rect);
|
||||||
}
|
}
|
||||||
_initialized = true;
|
if (Children.Count() > 1)
|
||||||
}
|
|
||||||
else if (Children.Count() > 1)
|
|
||||||
Dispatcher.UIThread.Post(async () => _ = ApplyOffset(finalSize, true), DispatcherPriority.Render);
|
Dispatcher.UIThread.Post(async () => _ = ApplyOffset(finalSize, true), DispatcherPriority.Render);
|
||||||
|
|
||||||
return finalSize;
|
return finalSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user