code formatting

This commit is contained in:
NaBian committed 2021-06-08 23:11:14 +08:00
1 parent 6a3711e6e0
commit 5afb569d11
43 files changed
+200 -287

No files matched your search

@@ -490,44 +490,26 @@ namespace HandyControl.Interactivity
var layoutSlot = LayoutInformation.GetLayoutSlot(element);
var x = 0.0;
var y = 0.0;
switch (element.HorizontalAlignment)
x = element.HorizontalAlignment switch
{
case HorizontalAlignment.Left:
x = layoutSlot.Left + margin.Left;
break;
case HorizontalAlignment.Center:
x = (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0;
break;
case HorizontalAlignment.Right:
x = layoutSlot.Right - margin.Right - actualWidth;
break;
case HorizontalAlignment.Stretch:
x = Math.Max(layoutSlot.Left + margin.Left,
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0);
break;
}
switch (element.VerticalAlignment)
HorizontalAlignment.Left => layoutSlot.Left + margin.Left,
HorizontalAlignment.Center => (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 -
actualWidth / 2.0,
HorizontalAlignment.Right => layoutSlot.Right - margin.Right - actualWidth,
HorizontalAlignment.Stretch => Math.Max(layoutSlot.Left + margin.Left,
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0),
_ => x
};
y = element.VerticalAlignment switch
{
case VerticalAlignment.Top:
y = layoutSlot.Top + margin.Top;
break;
case VerticalAlignment.Center:
y = (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0;
break;
case VerticalAlignment.Bottom:
y = layoutSlot.Bottom - margin.Bottom - actualHeight;
break;
case VerticalAlignment.Stretch:
y = Math.Max(layoutSlot.Top + margin.Top,
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0);
break;
}
VerticalAlignment.Top => layoutSlot.Top + margin.Top,
VerticalAlignment.Center => (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 -
actualHeight / 2.0,
VerticalAlignment.Bottom => layoutSlot.Bottom - margin.Bottom - actualHeight,
VerticalAlignment.Stretch => Math.Max(layoutSlot.Top + margin.Top,
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0),
_ => y
};
return new Rect(x, y, actualWidth, actualHeight);
}