コード例 #1
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// save as bmp file
        /// </summary>
        /// <param name="n"></param>
        /// <returns>Bitmap of current Node and children</returns>
        public Bitmap drawTree(Node n)
        {
            Bitmap   b;
            Graphics g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth  = 0;
            maxHeight = 0;

            recalc(n);

            b = new Bitmap((int)maxWidth + 20, (int)maxHeight + 20); // 20 pixel border
            g = Graphics.FromImage(b);                               // gets the graphics drawing object
            g.Clear(Color.White);                                    // clears the background
            drawTree(g, n);

            return(b);
        }
コード例 #2
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// Draws the tree from the specified node
        /// </summary>
        /// <param name="g">The Drawing GDI object</param>
        /// <param name="n">Root Node</param>
        public void drawTree(Graphics g, Node n)
        {
            graphics = g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth    = 0;
            maxHeight   = 0;
            g.PageScale = zoom;

            // if(needsRecalc)
            recalc(n);

            // calcStartXY(n,ref x,ref y);

            // for debug
            // g.DrawRectangle(new Pen(Color.Bisque),0,0,maxWidth,maxHeight);
            // g.DrawString("maxHeight & maxWidth:"+maxWidth+" : "+maxHeight,new Font("Courier",8F),new SolidBrush(Color.Black),offsetX,offsetY+maxHeight+margin);

            drawNode(n.x, n.y, n, 0);

            legendY = maxHeight - legendHeight;
            drawLegend(n, true);
        }