support for .NET framework 3.5
Still have bugs
This commit is contained in:
1 parent
5878039e21
commit
7d6b491f25
704 files changed
+48273
-33
No files matched your search
@@ -0,0 +1,64 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
internal class InternalCanvas : Canvas
|
||||
{
|
||||
internal static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
|
||||
"Orientation", typeof(Orientation), typeof(InternalCanvas), new PropertyMetadata(default(Orientation)));
|
||||
|
||||
internal Orientation Orientation
|
||||
{
|
||||
get => (Orientation) GetValue(OrientationProperty);
|
||||
set => SetValue(OrientationProperty, value);
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size arrangeSize)
|
||||
{
|
||||
foreach (UIElement internalChild in InternalChildren)
|
||||
{
|
||||
if (internalChild == null) continue;
|
||||
|
||||
var x = 0.0;
|
||||
var y = 0.0;
|
||||
|
||||
if (Orientation == Orientation.Horizontal)
|
||||
{
|
||||
x = (arrangeSize.Width - internalChild.DesiredSize.Width) / 2;
|
||||
|
||||
var top = GetTop(internalChild);
|
||||
if (!double.IsNaN(top))
|
||||
{
|
||||
y = top;
|
||||
}
|
||||
else
|
||||
{
|
||||
var bottom = GetBottom(internalChild);
|
||||
if (!double.IsNaN(bottom))
|
||||
y = arrangeSize.Height - internalChild.DesiredSize.Height - bottom;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
y = (arrangeSize.Height - internalChild.DesiredSize.Height) / 2;
|
||||
|
||||
var left = GetLeft(internalChild);
|
||||
if (!double.IsNaN(left))
|
||||
{
|
||||
x = left;
|
||||
}
|
||||
else
|
||||
{
|
||||
var right = GetRight(internalChild);
|
||||
if (!double.IsNaN(right))
|
||||
x = arrangeSize.Width - internalChild.DesiredSize.Width - right;
|
||||
}
|
||||
}
|
||||
|
||||
internalChild.Arrange(new Rect(new Point(x, y), internalChild.DesiredSize));
|
||||
}
|
||||
return arrangeSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user