revert CWP changes
MODIFY
WalletWasabi.Fluent/Controls/ConcatenatingWrapPanel.cs
WalletWasabi.Fluent/Controls/ConcatenatingWrapPanel.cs
@@ -10,6 +10,7 @@ namespace WalletWasabi.Fluent.Controls
{
/// Note: Most of this class is a copy paste from Avalonia. So the code style and standard should
/// be kept as is to allow for future maintenance.
+
/// <summary>
/// Works like a wrap panel.. but concatenates the Items in ConcatenatedChildren.
/// Also the very last child in ConcatenatedChildren will fill the remaining space.
@@ -19,21 +20,18 @@ namespace WalletWasabi.Fluent.Controls
/// <summary>
/// Defines the <see cref="Orientation"/> property.
/// </summary>
- // ReSharper disable once MemberCanBePrivate.Global
public static readonly StyledProperty<Orientation> OrientationProperty =
- AvaloniaProperty.Register<ConcatenatingWrapPanel, Orientation>(nameof(Orientation), Orientation.Horizontal);
+ AvaloniaProperty.Register<ConcatenatingWrapPanel, Orientation>(nameof(Orientation), defaultValue: Orientation.Horizontal);
/// <summary>
/// Defines the <see cref="ItemWidth"/> property.
/// </summary>
- // ReSharper disable once MemberCanBePrivate.Global
public static readonly StyledProperty<double> ItemWidthProperty =
AvaloniaProperty.Register<ConcatenatingWrapPanel, double>(nameof(ItemWidth), double.NaN);
/// <summary>
/// Defines the <see cref="ItemHeight"/> property.
/// </summary>
- // ReSharper disable once MemberCanBePrivate.Global
public static readonly StyledProperty<double> ItemHeightProperty =
AvaloniaProperty.Register<ConcatenatingWrapPanel, double>(nameof(ItemHeight), double.NaN);
@@ -57,8 +55,8 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public Orientation Orientation
{
- get => GetValue(OrientationProperty);
- set => SetValue(OrientationProperty, value);
+ get { return GetValue(OrientationProperty); }
+ set { SetValue(OrientationProperty, value); }
}
/// <summary>
@@ -66,8 +64,8 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public double ItemWidth
{
- get => GetValue(ItemWidthProperty);
- set => SetValue(ItemWidthProperty, value);
+ get { return GetValue(ItemWidthProperty); }
+ set { SetValue(ItemWidthProperty, value); }
}
/// <summary>
@@ -75,8 +73,8 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public double ItemHeight
{
- get => GetValue(ItemHeightProperty);
- set => SetValue(ItemHeightProperty, value);
+ get { return GetValue(ItemHeightProperty); }
+ set { SetValue(ItemHeightProperty, value); }
}
/// <summary>
@@ -90,8 +88,8 @@ namespace WalletWasabi.Fluent.Controls
{
var orientation = Orientation;
var children = Children.Concat(ConcatenatedChildren).ToList();
- var horiz = orientation == Orientation.Horizontal;
- var index = Children.IndexOf((IControl) from);
+ bool horiz = orientation == Orientation.Horizontal;
+ int index = Children.IndexOf((IControl)from);
switch (direction)
{
@@ -122,23 +120,27 @@ namespace WalletWasabi.Fluent.Controls
}
if (index >= 0 && index < children.Count)
+ {
return children[index];
-
- return null!;
+ }
+ else
+ {
+ return null;
+ }
}
/// <inheritdoc/>
protected override Size MeasureOverride(Size constraint)
{
- var itemWidth = ItemWidth;
- var itemHeight = ItemHeight;
+ double itemWidth = ItemWidth;
+ double itemHeight = ItemHeight;
var orientation = Orientation;
var children = Children.Concat(ConcatenatedChildren).ToList();
- var curLineSize = new UvSize(orientation);
- var panelSize = new UvSize(orientation);
- var uvConstraint = new UvSize(orientation, constraint.Width, constraint.Height);
- var itemWidthSet = !double.IsNaN(itemWidth);
- var itemHeightSet = !double.IsNaN(itemHeight);
+ var curLineSize = new UVSize(orientation);
+ var panelSize = new UVSize(orientation);
+ var uvConstraint = new UVSize(orientation, constraint.Width, constraint.Height);
+ bool itemWidthSet = !double.IsNaN(itemWidth);
+ bool itemHeightSet = !double.IsNaN(itemHeight);
var childConstraint = new Size(
itemWidthSet ? itemWidth : constraint.Width,
@@ -153,23 +155,21 @@ namespace WalletWasabi.Fluent.Controls
child.Measure(childConstraint);
// This is the size of the child in UV space
- var sz = new UvSize(orientation,
+ var sz = new UVSize(orientation,
itemWidthSet ? itemWidth : child.DesiredSize.Width,
itemHeightSet ? itemHeight : child.DesiredSize.Height);
- if (MathUtilities.GreaterThan(curLineSize.U + sz.U, uvConstraint.U)
- ) // Need to switch to another line
+ if (MathUtilities.GreaterThan(curLineSize.U + sz.U, uvConstraint.U)) // Need to switch to another line
{
panelSize.U = Math.Max(curLineSize.U, panelSize.U);
panelSize.V += curLineSize.V;
curLineSize = sz;
- if (MathUtilities.GreaterThan(sz.U, uvConstraint.U)
- ) // The element is wider then the constraint - give it a separate line
+ if (MathUtilities.GreaterThan(sz.U, uvConstraint.U)) // The element is wider then the constraint - give it a separate line
{
panelSize.U = Math.Max(sz.U, panelSize.U);
panelSize.V += sz.V;
- curLineSize = new UvSize(orientation);
+ curLineSize = new UVSize(orientation);
}
}
else // Continue to accumulate a line
@@ -191,46 +191,43 @@ namespace WalletWasabi.Fluent.Controls
/// <inheritdoc/>
protected override Size ArrangeOverride(Size finalSize)
{
- var itemWidth = ItemWidth;
- var itemHeight = ItemHeight;
+ double itemWidth = ItemWidth;
+ double itemHeight = ItemHeight;
var orientation = Orientation;
var children = Children.Concat(ConcatenatedChildren).ToList();
- var firstInLine = 0;
+ int firstInLine = 0;
double accumulatedV = 0;
- var itemU = orientation == Orientation.Horizontal ? itemWidth : itemHeight;
- var curLineSize = new UvSize(orientation);
- var uvFinalSize = new UvSize(orientation, finalSize.Width, finalSize.Height);
- var itemWidthSet = !double.IsNaN(itemWidth);
- var itemHeightSet = !double.IsNaN(itemHeight);
- var useItemU = orientation == Orientation.Horizontal ? itemWidthSet : itemHeightSet;
+ double itemU = orientation == Orientation.Horizontal ? itemWidth : itemHeight;
+ var curLineSize = new UVSize(orientation);
+ var uvFinalSize = new UVSize(orientation, finalSize.Width, finalSize.Height);
+ bool itemWidthSet = !double.IsNaN(itemWidth);
+ bool itemHeightSet = !double.IsNaN(itemHeight);
+ bool useItemU = orientation == Orientation.Horizontal ? itemWidthSet : itemHeightSet;
- for (var i = 0; i < children.Count; i++)
+ for (int i = 0; i < children.Count; i++)
{
var child = children[i];
if (child != null)
{
- var sz = new UvSize(orientation,
+ var sz = new UVSize(orientation,
itemWidthSet ? itemWidth : child.DesiredSize.Width,
itemHeightSet ? itemHeight : child.DesiredSize.Height);
- if (MathUtilities.GreaterThan(curLineSize.U + sz.U, uvFinalSize.U)
- ) // Need to switch to another line
+ if (MathUtilities.GreaterThan(curLineSize.U + sz.U, uvFinalSize.U)) // Need to switch to another line
{
ArrangeLine(accumulatedV, curLineSize.V, firstInLine, i, useItemU, itemU, uvFinalSize);
accumulatedV += curLineSize.V;
curLineSize = sz;
- if (MathUtilities.GreaterThan(sz.U, uvFinalSize.U)
- ) // The element is wider then the constraint - give it a separate line
+ if (MathUtilities.GreaterThan(sz.U, uvFinalSize.U)) // The element is wider then the constraint - give it a separate line
{
// Switch to next line which only contain one element
ArrangeLine(accumulatedV, sz.V, i, ++i, useItemU, itemU, uvFinalSize);
accumulatedV += sz.V;
- curLineSize = new UvSize(orientation);
+ curLineSize = new UVSize(orientation);
}
-
firstInLine = i;
}
else // Continue to accumulate a line
@@ -243,28 +240,29 @@ namespace WalletWasabi.Fluent.Controls
// Arrange the last line, if any
if (firstInLine < children.Count)
+ {
ArrangeLine(accumulatedV, curLineSize.V, firstInLine, children.Count, useItemU, itemU, uvFinalSize);
+ }
return finalSize;
}
- private void ArrangeLine(double v, double lineV, int start, int end, bool useItemU, double itemU,
- UvSize uvFinalSize)
+ private void ArrangeLine(double v, double lineV, int start, int end, bool useItemU, double itemU, UVSize uvFinalSize)
{
var orientation = Orientation;
var children = Children.Concat(ConcatenatedChildren).ToList();
double u = 0;
- var isHorizontal = orientation == Orientation.Horizontal;
+ bool isHorizontal = orientation == Orientation.Horizontal;
- for (var i = start; i < end; i++)
+ for (int i = start; i < end; i++)
{
var child = children[i];
if (child != null)
{
if (i == children.Count - 1)
{
- var childSize = new UvSize(orientation, uvFinalSize.Width - u, uvFinalSize.Height - u);
- var layoutSlotU = useItemU ? itemU : childSize.U;
+ var childSize = new UVSize(orientation, uvFinalSize.Width - u, uvFinalSize.Height - u);
+ double layoutSlotU = useItemU ? itemU : childSize.U;
child.Arrange(new Rect(
isHorizontal ? u : v,
isHorizontal ? v : u,
@@ -274,8 +272,8 @@ namespace WalletWasabi.Fluent.Controls
}
else
{
- var childSize = new UvSize(orientation, child.DesiredSize.Width, child.DesiredSize.Height);
- var layoutSlotU = useItemU ? itemU : childSize.U;
+ var childSize = new UVSize(orientation, child.DesiredSize.Width, child.DesiredSize.Height);
+ double layoutSlotU = useItemU ? itemU : childSize.U;
child.Arrange(new Rect(
isHorizontal ? u : v,
isHorizontal ? v : u,
@@ -287,9 +285,9 @@ namespace WalletWasabi.Fluent.Controls
}
}
- private struct UvSize
+ private struct UVSize
{
- internal UvSize(Orientation orientation, double width, double height)
+ internal UVSize(Orientation orientation, double width, double height)
{
U = V = 0d;
_orientation = orientation;
@@ -297,7 +295,7 @@ namespace WalletWasabi.Fluent.Controls
Height = height;
}
- internal UvSize(Orientation orientation)
+ internal UVSize(Orientation orientation)
{
U = V = 0d;
_orientation = orientation;
@@ -305,26 +303,17 @@ namespace WalletWasabi.Fluent.Controls
internal double U;
internal double V;
- private readonly Orientation _orientation;
+ private Orientation _orientation;
internal double Width
{
- get => _orientation == Orientation.Horizontal ? U : V;
- set
- {
- if (_orientation == Orientation.Horizontal) U = value;
- else V = value;
- }
+ get { return _orientation == Orientation.Horizontal ? U : V; }
+ set { if (_orientation == Orientation.Horizontal) U = value; else V = value; }
}
-
internal double Height
{
- get => _orientation == Orientation.Horizontal ? V : U;
- set
- {
- if (_orientation == Orientation.Horizontal) V = value;
- else U = value;
- }
+ get { return _orientation == Orientation.Horizontal ? V : U; }
+ set { if (_orientation == Orientation.Horizontal) V = value; else U = value; }
}
}
}

revert CWP changes