Пример #1
0
        private void AddConnection(ShapeBase rootShape, ImageRectangle child, Point point,
                                   DependencyGraphData dGraphData)
        {
            IConnector rootConnector = null;
            IConnector childConnector = null;

            if (point.X <= rootShape.X)
            {
                if (point.Y < rootShape.Y)
                {
                    rootConnector = rootShape.Connectors[0];
                    childConnector = child.Connectors[2];
                }
                else if (point.Y < (rootShape.Y + rootShape.Height))
                {
                    rootConnector = rootShape.Connectors[3];
                    childConnector = child.Connectors[1];
                }
                else
                {
                    rootConnector = rootShape.Connectors[2];
                    childConnector = child.Connectors[0];
                }
            }
            else if (point.X > rootShape.X)
            {
                if (point.Y < rootShape.Y)
                {
                    rootConnector = rootShape.Connectors[0];
                    childConnector = child.Connectors[2];
                }
                else if (point.Y < (rootShape.Y + rootShape.Height))
                {
                    rootConnector = rootShape.Connectors[1];
                    childConnector = child.Connectors[3];
                }
                else
                {
                    rootConnector = rootShape.Connectors[2];
                    childConnector = child.Connectors[0];
                }
            }

            var pS = new LinePenStyle {EndCap = LineCap.DiamondAnchor};

            if (dGraphData.SelectedType == SelectionType.INTERFACE || dGraphData.SelectedType == SelectionType.ABSTRACT)
            {
                pS.Color = Color.Chocolate;
                pS.Width = 2;
                pS.DashStyle = DashStyle.Dash;
            }

            IConnection conn;

            if (dGraphData.Arrow == GraphDataArrow.TO)
            {
                conn = canvas.AddConnection(rootConnector, childConnector);
            }
            else
            {
                conn = canvas.AddConnection(childConnector, rootConnector);
            }

            conn.PenStyle = pS;
        }
Пример #2
0
        private void ArrangeDiagram()
        {
            if (RootGraphData == null)
            {
                return;
            }

            Logger.Current.Debug(">> Dependency graph data count:" + RootGraphData.Nodes.Count);

            //// clear the existing diagram
            canvas.NewDocument();
            canvas.BackColor = Color.WhiteSmoke;

            var rootShape = new ImageRectangle(RootGraphData.Value.Title, GetImageList(RootGraphData.Value.SelectedType),
                                               true);
            canvas.AddShape(rootShape);

            // place the main part in the center of the control
            var centerPoint = new Point(canvas.Width/2, canvas.Height/2);
            rootShape.Move(centerPoint);

            DTreeNode<DependencyGraphData> filteredData = GetFilteredNodes(RootGraphData);

            List<Point> pointsToDraw = GetShapeLocationList(filteredData.Nodes.Count, centerPoint);

            Logger.Current.Debug(">> Total Points Selected:" + pointsToDraw.Count);

            int i = 0;
            foreach (var dNode in filteredData.Nodes)
            {
                var child = new ImageRectangle(dNode.Value.Title, GetImageList(dNode.Value.SelectedType));
                //  treeImageList.Images[2]);
                canvas.AddShape(child);
                child.Move(pointsToDraw[i]);

                // add connection from root to the child
                AddConnection(rootShape, child, pointsToDraw[i], dNode.Value);
                i++;
            }
        }