コード例 #1
0
ファイル: LayoutGraphTable.cs プロジェクト: fence-post/sqrach
        public void AddTable(DbTable t)
        {
            int ct = 0;

            foreach (DbTableConstraint constraint in t.references.Each())
            {
                if ((showExplicit.Checked && constraint.isForeignKey) || (showInferred.Checked && constraint.isSloppyForeignKey))
                {
                    ct++;
                }
            }

            foreach (DbTableConstraint constraint in t.constraints.Values)
            {
                if ((showExplicit.Checked && constraint.isForeignKey) || (showInferred.Checked && constraint.isSloppyForeignKey))
                {
                    ct++;
                }
            }

            if (ct == 0)
            {
                return;
            }

            string leftTable = T.AppendTo(t.name, t.GetAlias(true), " ");

            Microsoft.Msagl.Drawing.Shape shape = Microsoft.Msagl.Drawing.Shape.Box;
            Color       backColor   = Color.DarkKhaki;
            Color       borderColor = backColor;
            int         radius      = 20;
            DrawingNode node        = drawingGraph.AddNode(leftTable);

            node.Attr.FillColor   = node.Attr.FillColor = GraphColor(backColor);
            node.Attr.Color       = GraphColor(borderColor);
            node.Attr.LabelMargin = 10;
            node.Attr.Shape       = shape;
            node.Attr.XRadius     = radius;
            node.Attr.YRadius     = radius;
            node.LabelText        = leftTable;
            foreach (DbTableConstraint constraint in t.constraints.Values)
            {
                if ((showExplicit.Checked && constraint.isForeignKey) || (showInferred.Checked && constraint.isSloppyForeignKey))
                {
                    string rightTable = T.AppendTo(constraint.referencedTable.name, constraint.referencedTable.GetAlias(true), " ");
                    string edgeInfo   = constraint.RenderJoinCols(true);
                    Microsoft.Msagl.Drawing.Edge e = drawingGraph.AddEdge(leftTable, edgeInfo, rightTable);
                    e.Attr.Weight = 6;
                    paths.Add(t.name + "." + constraint.referencedTable.name);
                }
            }
        }
コード例 #2
0
        public void Visit(Token token)
        {
            string label = null; // token.debugText;

            Microsoft.Msagl.Drawing.Shape shape = Microsoft.Msagl.Drawing.Shape.Box;
            Color backColor   = UI.GetTokenBackColor(token);
            Color borderColor = backColor;
            int   radius      = 20;

            if (token.tokenType == TokenType.Column && Showing(token, showColumns.Checked))
            {
                Column c = token as Column;
                shape = Microsoft.Msagl.Drawing.Shape.Msquare;
                label = c.columnName;
            }
            else if (token.tokenType == TokenType.Operator && Showing(token, showOperators.Checked))
            {
                label = token.name;
            }
            else if (token.tokenType == TokenType.Table && Showing(token, showTables.Checked))
            {
                shape = Microsoft.Msagl.Drawing.Shape.Msquare;
                Table t = token as Table;
                label = T.AppendTo(token.name, t.tableAlias, " ");
            }
            else if (token.isPrimaryKeyword && Showing(token, showKeywords.Checked))
            {
                label = token.name;
            }
            else if (token.tokenType == TokenType.Keyword && Showing(token, showKeywords.Checked))
            {
                label = token.name;
            }
            else if (token.tokenType == TokenType.Expression && Showing(token, showExpressions.Checked))
            {
                label  = token.name;
                radius = 10;
            }
            else if (token.tokenType == TokenType.Identifier && Showing(token, showIdentifiers.Checked))
            {
                label  = token.name;
                radius = 5;
            }
            else if (token.tokenType == TokenType.Literal && Showing(token, showLiterals.Checked))
            {
                label  = token.name;
                radius = 5;
                shape  = Microsoft.Msagl.Drawing.Shape.Ellipse;
            }
            else if (token.tokenType == TokenType.Query)
            {
                label       = token.name;
                backColor   = Color.WhiteSmoke;
                borderColor = Color.DarkGray;
            }

            if (label != null)
            {
                label = token.name.LimitToLength(30);
                DrawingNode node = drawingGraph.AddNode(token.id);
                node.Attr.FillColor   = node.Attr.FillColor = GraphColor(backColor);
                node.Attr.Color       = GraphColor(borderColor);
                node.Attr.LabelMargin = 10;
                node.Attr.Shape       = shape;
                node.Attr.XRadius     = radius;
                node.Attr.YRadius     = radius;
                node.LabelText        = label;
                if (token.parentToken != null)
                {
                    drawingGraph.AddEdge(token.id, token.parentToken.id);
                }
                else if (token.parentQuery != null)
                {
                    drawingGraph.AddEdge(token.id, token.parentQuery.id);
                }
            }
        }