Esempio n. 1
0
        public static Rectangle getRect(Nodes.Node n) {
            int titleWidth = System.Windows.Forms.TextRenderer.MeasureText(n.getName(), nodeTitleFont).Width;
            Rectangle nodeRect = new Rectangle();
            nodeRect.Location = n.getPos();
            nodeRect.Width = Math.Max(100, titleWidth);
            nodeRect.Height = nodeTitleFont.Height;

            //count the lines to cover with text
            if (n.getExtra() != null && n.getExtra() != "") {
                nodeRect.Height += nodeExtraFont.Height;
            }
            foreach (var kvp in n.getProperties()) {
                if (kvp.Value.isInput || kvp.Value.isOutput) {
                    nodeRect.Height += nodeFont.Height;
                }
            }
            return nodeRect;
        }
Esempio n. 2
0
 private static void drawTitle(Graphics g, Nodes.Node n, ref Rectangle nodeRect) {
     //draw title
     g.DrawString(n.getName(), nodeTitleFont, Brushes.Black, nodeRect.X + (nodeRect.Width - System.Windows.Forms.TextRenderer.MeasureText(n.getName(), nodeTitleFont).Width) / 2, nodeRect.Y);
     nodeRect.Y += nodeFont.Height;
     g.DrawLine(Pens.Black, nodeRect.Left, nodeRect.Y, nodeRect.Right, nodeRect.Y);
     
     //draw extra
     if (n.getExtra() != null && n.getExtra() != "") {
         g.DrawString(n.getExtra(), nodeExtraFont, Brushes.Black, nodeRect.Location);
         nodeRect.Y += nodeFont.Height;
         g.DrawLine(Pens.Black, nodeRect.Left, nodeRect.Y, nodeRect.Right, nodeRect.Y);
     }
 }