Under the covers, the Visio shape sheet uses four other cells to render the shape's positioning transform -- Width, Height, LocPinX and LocPinY. This can be managed in the following function LocalPin():
public virtual void DoArrange(Size finalSize)
{
foreach (UIElement oChild in Children)
{
double dX = (double)oChild.GetValue(SketchPanel.PinXProperty);
double dY = (double)oChild.GetValue(SketchPanel.PinYProperty);
double dAngle = (double)oChild.GetValue(SketchPanel.AngleProperty);
Point oLocal = (Point)LocalPin(oChild);
dX -= oLocal.X;
dY -= oLocal.Y;
Point oPoint = new Point(dX, dY);
SetRenderTransform(oChild, dAngle, oPoint);
oChild.Arrange(new Rect(0, 0, oChild.DesiredSize.Width, oChild.DesiredSize.Height));
}
}
public Point LocalPin(UIElement oChild)
{
double dWidth = (double)oChild.GetValue(SketchPanel.WidthProperty);
double dHeight = (double)oChild.GetValue(SketchPanel.HeightProperty);
Point oOrigin = (Point)oChild.GetValue(SketchPanel.RenderTransformOriginProperty);
double dLocPinX = double.NaN.Equals(dWidth) ? 0.0 : dWidth * oOrigin.X;
double dLocPinY = double.NaN.Equals(dHeight) ? 0.0 : dHeight * oOrigin.Y;
return new Point(dLocPinX, dLocPinY);
}
No comments:
Post a Comment