public override void UpdatePath(IPath path, PathOrientation pathOrientation, DimensionScale scale)
        {
            base.UpdatePath(path, pathOrientation, scale);

            //Trace.TraceInformation("HalfSquareTriangleLayout::ResizeChildren");

            // Upper left triangle
            {
                IPath pathUpperLeft = PathGeometries.Triangle.CreatePath(new PathPoint[] { Path.GetSegment(3).Origin, Path.GetSegment(0).Origin, Path.GetSegment(1).Origin });

                //Trace.TraceInformation("Upper left = {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[0];
                layoutSite.UpdatePath(pathUpperLeft, scale);
            }

            // Lower right triangle.
            //
            {
                IPath pathLowerRight = PathGeometries.Triangle.CreatePath(new PathPoint[] { Path.GetSegment(1).Origin, Path.GetSegment(2).Origin, Path.GetSegment(3).Origin });

                //Trace.TraceInformation("Lower right = {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[1];
                layoutSite.UpdatePath(pathLowerRight, scale);
            }
        }
Beispiel #2
0
        public override void UpdatePath(IPath path, PathOrientation pathOrientation, DimensionScale scale)
        {
            base.UpdatePath(path, pathOrientation, scale);

            LayoutSite layoutSite = LayoutSites[0];

            layoutSite.UpdatePath(Path, scale);
        }
Beispiel #3
0
        public override void UpdatePath(IPath path, PathOrientation pathOrientation, DimensionScale scale)
        {
            base.UpdatePath(path, pathOrientation, scale);

            //Trace.TraceInformation("FlyingGooseLayout::ResizeChildren");

            PathPoint topMidpoint    = Path.Interpolate(0, 0.5);
            PathPoint bottomMidpoint = Path.Interpolate(2, 0.5);

            // Upper left triangle
            {
                IPath pathUpperLeft = PathGeometries.Triangle.CreatePath(new PathPoint[] { Path.GetSegment(3).Origin, Path.GetSegment(0).Origin, topMidpoint });

                //Trace.TraceInformation("Upper left = {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[0];
                layoutSite.UpdatePath(pathUpperLeft, scale);
            }

            // Upper right triangle.
            //
            {
                IPath pathUpperRight = PathGeometries.Triangle.CreatePath(new PathPoint[] { topMidpoint, Path.GetSegment(1).Origin, Path.GetSegment(2).Origin });

                //Trace.TraceInformation("Upper right = {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[1];
                layoutSite.UpdatePath(pathUpperRight, scale);
            }

            // Lower left triangle
            {
                IPath pathLowerLeft = PathGeometries.Triangle.CreatePath(new PathPoint[] { topMidpoint, bottomMidpoint, Path.GetSegment(3).Origin });

                //Trace.TraceInformation("Lower left = {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[2];
                layoutSite.UpdatePath(pathLowerLeft, scale);
            }

            // Lower right triangle.
            //
            {
                IPath pathLowerRight = PathGeometries.Triangle.CreatePath(new PathPoint[] { Path.GetSegment(2).Origin, bottomMidpoint, topMidpoint });

                //Trace.TraceInformation("Lower right= {0}", path.ToString());

                LayoutSite layoutSite = LayoutSites[3];
                layoutSite.UpdatePath(pathLowerRight, scale);
            }
        }
Beispiel #4
0
            private static XDesign_LayoutSite XDesign_LayoutSite(LayoutSite layoutSite, FabricStyle fabricStyle)
            {
                var result = new XDesign_LayoutSite()
                {
                    path = XDesign_Path(layoutSite.Path)
                };

                if (fabricStyle != null)
                {
                    result.color = XDesign_Color(fabricStyle.Color);
                }

                return(result);
            }
        private static void PopulateLayoutSite(LayoutSite layoutSite, string cellDefinition, string styleDefinition)
        {
            switch (cellDefinition)
            {
            case "*":
            {
                var style = styleDefinition.Substring(0, 1);

                layoutSite.Node = new RectangleShapeNode(FabricStyle.Default)
                {
                    Style = style
                };
            }
                return;

            case "/":
            {
                var node = CreateHalfSquareTriangleLayoutNode(
                    styleDefinition.Substring(0, 1),
                    styleDefinition.Substring(1, 1));

                layoutSite.Node = node;
            }
                return;

            case "\\":
            {
                var node = CreateHalfSquareTriangleLayoutNode(
                    styleDefinition.Substring(0, 1),
                    styleDefinition.Substring(1, 1));

                layoutSite.Node = node;
                layoutSite.PathOrientation.PointOffset = 1;
            }
                return;

            default:
                throw new InvalidOperationException(string.Format("Unknown cell format {0}", cellDefinition));
            }
        }
Beispiel #6
0
        private void AddGridInputs(BuildComponentFactory factory, GridLayoutNode grid, bool trimTriangles)
        {
            List <Tuple <int, int> > consumedNodes = new List <Tuple <int, int> >();

            for (int row = 0; row < grid.RowCount; ++row)
            {
                for (int column = 0; column < grid.ColumnCount; ++column)
                {
                    if (!consumedNodes.Exists(r => r.Item1 == row && r.Item2 == column))
                    {
                        var layoutSite = grid.GetLayoutSite(row, column);
                        var columnSpan = grid.GetColumnSpan(row, column);
                        var rowSpan    = grid.GetRowSpan(row, column);

                        var fingerprint = GetFlyingGooseFingerprint(layoutSite.Node, layoutSite.PathOrientation.PointOffset);
                        if (fingerprint != null)
                        {
                            bool flyingGooseCreated = false;

                            LayoutSite layoutSiteRight = null; // Assume layout site does not exist.
                            if (column + columnSpan < grid.ColumnCount)
                            {
                                if (grid.GetLayoutSite(row, column + columnSpan).Node != null)
                                {
                                    if (grid.GetColumnSpan(row, column + columnSpan) == columnSpan &&
                                        grid.GetRowSpan(row, column + columnSpan) == rowSpan)
                                    {
                                        layoutSiteRight = grid.GetLayoutSite(row, column + columnSpan);
                                    }
                                }
                            }

                            if (layoutSiteRight != null)
                            {
                                var matchingRightFingerprint = GetFlyingGooseMatchingHorizontalFingerprint(layoutSite.Node, layoutSite.PathOrientation.PointOffset);

                                var rightFingerprint = GetFlyingGooseFingerprint(layoutSiteRight.Node, layoutSiteRight.PathOrientation.PointOffset);

                                if (rightFingerprint == matchingRightFingerprint)
                                {
                                    var halfSquareTriangle = (HalfSquareTriangleLayoutNode)layoutSite.Node;

                                    FabricStyle fabricStyleBody;
                                    FabricStyle fabricStyleCorner;
                                    switch (layoutSite.PathOrientation.PointOffset)
                                    {
                                    case 0:
                                    case 1:
                                        fabricStyleCorner = ((ShapeNode)halfSquareTriangle.LayoutSites[0].Node).FabricStyle;
                                        fabricStyleBody   = ((ShapeNode)halfSquareTriangle.LayoutSites[1].Node).FabricStyle;
                                        break;

                                    case 2:
                                    case 3:
                                        fabricStyleCorner = ((ShapeNode)halfSquareTriangle.LayoutSites[1].Node).FabricStyle;
                                        fabricStyleBody   = ((ShapeNode)halfSquareTriangle.LayoutSites[0].Node).FabricStyle;
                                        break;

                                    default:
                                        throw new InvalidOperationException("Unexpected point offset.");
                                    }

                                    var nodeBounds = halfSquareTriangle.Path.GetBounds();
                                    var width      = nodeBounds.MaximumX - nodeBounds.MinimumX;
                                    var height     = nodeBounds.MaximumY - nodeBounds.MinimumY;
                                    var area       = new Area(width * 2, height).Round();

                                    AddFlyingGooseInputs(factory, fabricStyleBody, fabricStyleCorner, area, trimTriangles);

                                    consumedNodes.Add(new Tuple <int, int>(row, column));
                                    consumedNodes.Add(new Tuple <int, int>(row, column + columnSpan));

                                    flyingGooseCreated = true;
                                }
                            }

                            LayoutSite layoutSiteDown = null; // Assume layout site does not exist.
                            if (row + rowSpan < grid.RowCount)
                            {
                                if (grid.GetLayoutSite(row + rowSpan, column).Node != null)
                                {
                                    if (grid.GetColumnSpan(row + rowSpan, column) == columnSpan &&
                                        grid.GetRowSpan(row + rowSpan, column) == rowSpan)
                                    {
                                        layoutSiteDown = grid.GetLayoutSite(row + rowSpan, column);
                                    }
                                }
                            }

                            if (!flyingGooseCreated && layoutSiteDown != null)
                            {
                                var matchingDownFingerprint = GetFlyingGooseMatchingVerticalFingerprint(layoutSite.Node, layoutSite.PathOrientation.PointOffset);

                                var downFingerprint = GetFlyingGooseFingerprint(layoutSiteDown.Node, layoutSiteDown.PathOrientation.PointOffset);

                                if (downFingerprint == matchingDownFingerprint)
                                {
                                    var halfSquareTriangle = (HalfSquareTriangleLayoutNode)layoutSite.Node;

                                    FabricStyle fabricStyleBody;
                                    FabricStyle fabricStyleCorner;
                                    switch (layoutSite.PathOrientation.PointOffset)
                                    {
                                    case 0:
                                    case 3:
                                        fabricStyleCorner = ((ShapeNode)halfSquareTriangle.LayoutSites[0].Node).FabricStyle;
                                        fabricStyleBody   = ((ShapeNode)halfSquareTriangle.LayoutSites[1].Node).FabricStyle;
                                        break;

                                    case 1:
                                    case 2:
                                        fabricStyleCorner = ((ShapeNode)halfSquareTriangle.LayoutSites[1].Node).FabricStyle;
                                        fabricStyleBody   = ((ShapeNode)halfSquareTriangle.LayoutSites[0].Node).FabricStyle;
                                        break;

                                    default:
                                        throw new InvalidOperationException("Unexpected point offset.");
                                    }

                                    var nodeBounds = halfSquareTriangle.Path.GetBounds();
                                    var width      = nodeBounds.MaximumX - nodeBounds.MinimumX;
                                    var height     = nodeBounds.MaximumY - nodeBounds.MinimumY;
                                    var area       = new Area(width * 2, height).Round();

                                    AddFlyingGooseInputs(factory, fabricStyleBody, fabricStyleCorner, area, trimTriangles);

                                    consumedNodes.Add(new Tuple <int, int>(row, column));
                                    consumedNodes.Add(new Tuple <int, int>(row + rowSpan, column));
                                }
                            }
                        }
                    }
                }
            }

            for (int row = 0; row < grid.RowCount; ++row)
            {
                for (int column = 0; column < grid.ColumnCount; ++column)
                {
                    if (!consumedNodes.Exists(r => r.Item1 == row && r.Item2 == column))
                    {
                        var child = grid.GetLayoutSite(row, column).Node;
                        if (child != null)
                        {
                            AddNodeInputs(factory, child, trimTriangles);
                        }
                    }
                }
            }
        }