protected RectangleShapeNode(RectangleShapeNode prototype) : base(prototype)
 {
 }
Beispiel #2
0
        public override void UpdatePath(IPath path, PathOrientation pathOrientation, DimensionScale scale)
        {
            base.UpdatePath(path, pathOrientation, scale);

            var scaledWidth = (m_width * scale).Value;

            // Outer points
            //
            var p1 = path.Offset(0, scaledWidth);
            var p2 = path.Offset(0, -scaledWidth);
            var p3 = path.Offset(1, scaledWidth);
            var p4 = path.Offset(1, -scaledWidth);
            var p5 = path.Offset(2, scaledWidth);
            var p6 = path.Offset(2, -scaledWidth);
            var p7 = path.Offset(3, scaledWidth);
            var p8 = path.Offset(3, -scaledWidth);

            // Inner points
            //
            var q1 = new PathPoint(p1.X, p3.Y);
            var q2 = new PathPoint(p2.X, p3.Y);
            var q3 = new PathPoint(p5.X, p4.Y);
            var q4 = new PathPoint(p6.X, p4.Y);

            // Resize layout site.
            //
            var pathInner = PathGeometries.Rectangle.CreatePath(
                new PathPoint[] { q1, q2, q3, q4 });

            LayoutSites[0].UpdatePath(pathInner, scale);

            // Recompute border shapes.
            //
            var borderTop = PathGeometries.Rectangle.CreatePath(
                new PathPoint[] {
                path.GetSegment(0).Origin,
                path.GetSegment(1).Origin,
                p3,
                p8
            });

            var borderRight = PathGeometries.Rectangle.CreatePath(
                new PathPoint[] {
                p3,
                p4,
                q3,
                q2
            });

            var borderBottom = PathGeometries.Rectangle.CreatePath(
                new PathPoint[] {
                path.GetSegment(2).Origin,
                path.GetSegment(3).Origin,
                p7,
                p4
            });

            var borderLeft = PathGeometries.Rectangle.CreatePath(
                new PathPoint[] {
                p7,
                p8,
                q1,
                q4
            });

            var borderPaths          = new List <IPath>();
            var maxBorderPieceLength = new Dimension(20, DimensionUnits.Inch) * scale;

            borderPaths.AddRange(SplitPath(borderTop, maxBorderPieceLength));
            borderPaths.AddRange(SplitPath(borderRight, maxBorderPieceLength));
            borderPaths.AddRange(SplitPath(borderBottom, maxBorderPieceLength));
            borderPaths.AddRange(SplitPath(borderLeft, maxBorderPieceLength));

            m_borderShapes.Clear();
            foreach (var borderPath in borderPaths)
            {
                var shape = new RectangleShapeNode(m_fabricStyle);
                shape.UpdatePath(borderPath, pathOrientation, scale);
                m_borderShapes.Add(shape);
            }
        }