Ejemplo n.º 1
0
        private static void FillGraphConnectorNodes(TreeGraphLabelNode originalGraphNode, TreeGraphLabelNode resutLabelNode, TraverseTreeGraphContext context)
        {
            if (originalGraphNode.Children.Count > 0)
            {
                int startX = originalGraphNode.Children[0].X;
                int endX   = originalGraphNode.Children[originalGraphNode.Children.Count - 1].X;

                for (int i = startX; i <= endX; i++)
                {
                    TreeGraphConnectorNode connector = null;

                    TreeGraphNodeBase child = originalGraphNode.Children.Find(c => c.X == i);

                    if (child != null)
                    {
                        if (originalGraphNode.Children.Count == 1)
                        {
                            connector = new TreeGraphConnectorNode(TreeGraphNodeType.VLine, i, originalGraphNode.Y + 1);
                        }
                        else
                        {
                            if (child == originalGraphNode.Children[0])
                            {
                                connector = new TreeGraphConnectorNode(TreeGraphNodeType.LeftCorner, i, originalGraphNode.Y + 1);
                            }
                            else
                            if (child == originalGraphNode.Children[originalGraphNode.Children.Count - 1])
                            {
                                connector = new TreeGraphConnectorNode(TreeGraphNodeType.RightCorner, i, originalGraphNode.Y + 1);
                            }
                            else
                            if (child.X == originalGraphNode.X)
                            {
                                connector = new TreeGraphConnectorNode(TreeGraphNodeType.Cross, i, originalGraphNode.Y + 1);
                            }
                            else
                            {
                                connector = new TreeGraphConnectorNode(TreeGraphNodeType.Tee, i, originalGraphNode.Y + 1);
                            }
                        }
                    }
                    else
                    {
                        if (i == originalGraphNode.X)
                        {
                            connector = new TreeGraphConnectorNode(TreeGraphNodeType.ReverseTee, i, originalGraphNode.Y + 1);
                        }
                        else
                        {
                            connector = new TreeGraphConnectorNode(TreeGraphNodeType.HLine, i, originalGraphNode.Y + 1);
                        }
                    }

                    context.Width  = Math.Max(context.Width, connector.X + 1);
                    context.Height = Math.Max(context.Height, connector.Y + 1);

                    resutLabelNode.Children.Add(connector);
                }
            }
        }
Ejemplo n.º 2
0
        private static TreeGraphLabelNode GenerateGraphNodeWithConnectors(TreeGraphNodeBase parentGraphNode, TreeGraphLabelNode originalGraphNode, TraverseTreeGraphContext context)
        {
            TreeGraphLabelNode resutLabelNode = new TreeGraphLabelNode()
            {
                Name = originalGraphNode.Name, Description = originalGraphNode.Description, X = originalGraphNode.X, Y = originalGraphNode.Y
            };

            context.Width  = Math.Max(context.Width, resutLabelNode.X + 1);
            context.Height = Math.Max(context.Height, resutLabelNode.Y + 1);

            if (parentGraphNode != null)
            {
                parentGraphNode.Children.Add(resutLabelNode);
            }

            FillGraphConnectorNodes(originalGraphNode, resutLabelNode, context);

            foreach (TreeGraphNodeBase childConnectorNode in resutLabelNode.Children)
            {
                TreeGraphLabelNode matchedLabelNode = (TreeGraphLabelNode)originalGraphNode.Children.Find(n => n.X == childConnectorNode.X);

                if (matchedLabelNode != null)
                {
                    GenerateGraphNodeWithConnectors(childConnectorNode, matchedLabelNode, context);
                }
            }

            return(resutLabelNode);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成图形化的树型图
        /// </summary>
        /// <returns></returns>
        public TreeGraph GenerateGraph()
        {
            TreeGraphLabelNode originalGraphNode = GenerateGraphLabelNode((TNode)this, 0, 0, this.CalculateMaxWidth() * 2);

            TraverseTreeGraphContext context = new TraverseTreeGraphContext();

            return(new TreeGraph()
            {
                Root = GenerateGraphNodeWithConnectors(null, originalGraphNode, context),
                Width = context.Width,
                Height = context.Height
            });
        }
Ejemplo n.º 4
0
        private TreeGraphLabelNode GenerateGraphLabelNode(TNode node, int startX, int startY, int width)
        {
            TreeGraphLabelNode label = new TreeGraphLabelNode(startX + width / 2, startY);

            label.CopyNameInfo(node as INamedTreeNode);

            int childStartX = startX;

            foreach (TNode child in node.Children)
            {
                int childWidth = child.CalculateMaxWidth() * 2;

                TreeGraphLabelNode childLabel = GenerateGraphLabelNode(child, childStartX, startY + 2, childWidth);

                childStartX += childWidth;

                label.Children.Add(childLabel);
            }

            return(label);
        }
Ejemplo n.º 5
0
        private static Control CreateLabelCell(TreeGraphLabelNode label)
        {
            HtmlGenericControl labelNode = new HtmlGenericControl("div");

            labelNode.Attributes["class"] = "org-node";

            HtmlGenericControl labelContainer = new HtmlGenericControl("div");
            labelNode.Controls.Add(labelContainer);

            labelContainer.Attributes["class"] = "org-label";

            HtmlGenericControl textArea = new HtmlGenericControl("div");
            textArea.Attributes["class"] = "org-label-text-area";

            labelContainer.Controls.Add(textArea);

            HtmlGenericControl text = new HtmlGenericControl("div");

            text.Attributes["class"] = "org-label-text";
            text.Attributes["title"] = label.Name;
            text.InnerText = label.Name;
            textArea.Controls.Add(text);

            HtmlGenericControl descriptionArea = new HtmlGenericControl("div");

            descriptionArea.Attributes["class"] = "org-label-description_area";
            labelContainer.Controls.Add(descriptionArea);

            HtmlGenericControl description = new HtmlGenericControl("div");

            description.Attributes["class"] = "org-label-description";
            description.Attributes["title"] = label.Description;
            description.InnerText = label.Description;
            descriptionArea.Controls.Add(description);

            return labelNode;
        }