示例#1
0
        public override void draw(System.Drawing.Graphics gr, int x, int y)
        {
            int  right, after_left, before_right, after_right;
            bool draw_text;

            X = x;
            Y = y;

            height_of_text = Convert.ToInt32((gr.MeasureString(
                                                  "Yes", PensBrushes.default_times)).Height);

            width_of_text = Convert.ToInt32((gr.MeasureString(
                                                 this.Text + "XX", PensBrushes.default_times)).Width);

            int length_of_yesStr = Convert.ToInt32((gr.MeasureString(
                                                        "Yes", PensBrushes.default_arial)).Width);
            int length_of_noStr = Convert.ToInt32((gr.MeasureString(
                                                       "No", PensBrushes.default_arial)).Width);

            gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            if ((this.scale <= .4) || (this.head_heightOrig < 10))
            {
                draw_text = false;
            }
            else
            {
                draw_text = Component.text_visible;
            }

            System.Drawing.Pen head_pen    = PensBrushes.blue_pen;
            System.Drawing.Pen diamond_pen = PensBrushes.blue_pen;
            System.Drawing.Pen line_pen    = PensBrushes.blue_pen;

            // if the loop is selected make it red and select its children
            if (this.selected)
            {
                head_pen    = PensBrushes.red_pen;
                diamond_pen = PensBrushes.red_pen;
                line_pen    = PensBrushes.red_pen;
            }

            //Make diamond green for running
            else if (this.running && this.light_head == false)
            {
                head_pen    = PensBrushes.blue_pen;
                diamond_pen = PensBrushes.chartreuse_pen;
                line_pen    = PensBrushes.blue_pen;
            }

            //Make head green for running
            else if (this.running && this.light_head)
            {
                head_pen    = PensBrushes.chartreuse_pen;
                diamond_pen = PensBrushes.blue_pen;
                line_pen    = PensBrushes.blue_pen;
            }
            else if (this.is_compressed && this.have_child_running())
            {
                head_pen    = PensBrushes.chartreuse_pen;
                diamond_pen = PensBrushes.chartreuse_pen;
                line_pen    = PensBrushes.blue_pen;
            }

            if (!Component.USMA_mode)
            {
                // Draw the head
                gr.DrawEllipse(head_pen, x - W / 2, y, W, H);
                end_first_connector = Y + H + H / 2;
            }
            else
            {
                gr.DrawEllipse(head_pen, x - W / 8, y, W / 4, W / 4);
                end_first_connector = Y + W / 4 + H / 2;
            }


            if (this.has_breakpoint)
            {
                StopSign.Draw(gr, x - W / 2 - W / 6 - 2, y, W / 6);
            }

            // Draw arrow at top of the head oval
            if (!Component.USMA_mode)
            {
                gr.DrawLine(head_pen, x, y, x + CL / 4, y + CL / 4);     // draw down arrow
                gr.DrawLine(head_pen, x, y, x + CL / 4, y - CL / 4);     // draw up arrow
            }

            //Get the proper width based on the children's width
            // x_left is the location of the vertical connector leaving the loop
            // x_right is the location of the vertical connector going back to the top

            if ((before_Child != null) && (after_Child != null) && !this.is_compressed)
            {
                before_right = before_Child.FP.right;
                after_right  = after_Child.FP.right;
                right        = (before_right > after_right) ? before_right:after_right;
                x_right      = x + W / 2 + right;

                after_left = after_Child.FP.left;
                x_left     = x - W / 2 - after_left;
            }
            else if (before_Child != null && !this.is_compressed)
            {
                before_right = before_Child.FP.right;
                x_right      = x + W / 2 + before_right;

                x_left = x - W / 2 - W / 2;
            }
            else if (after_Child != null && !this.is_compressed)
            {
                after_right = after_Child.FP.right;
                x_right     = x + W / 2 + after_right;

                after_left = after_Child.FP.left;
                x_left     = x - W / 2 - after_left;
            }
            else
            {
                x_right = x + W / 2 + W / 2;
                x_left  = x - W / 2 - W / 2;
            }

            if (draw_text && this.Is_Wide_Diamond())
            {
                int temp_right = x + this.drawing_text_width / 2 + W / 2 + W / 4;
                int temp_left  = x - this.drawing_text_width / 2 - W / 2 - W / 4;

                if (temp_right > x_right)
                {
                    x_right = temp_right;
                }
                if (temp_left < x_left)
                {
                    x_left = temp_left;
                }
            }

            //Because there is a before child, draw a connector from the head to the
            //before child and then from the before child to the diamond.
            int start_first_connector;              // top y coordinate of first connector

            if (!Component.USMA_mode)
            {
                start_first_connector = y + H;
            }
            else
            {
                start_first_connector = y + W / 4;
            }

            // draw connector line
            gr.DrawLine(line_pen, x, start_first_connector, x, end_first_connector);
            // draw left side of arrow
            gr.DrawLine(line_pen, x, end_first_connector, x - CL / 4, end_first_connector - CL / 4);
            // draw right side of arrow
            gr.DrawLine(line_pen, x, end_first_connector, x + CL / 4, end_first_connector - CL / 4);


            if (before_Child != null && !this.is_compressed)
            {
                diamond_top = end_first_connector + before_Child.FP.height + CL;

                //Draw connector from head to before_child

                // Draw the before_Child graphic
                before_Child.draw(gr, x, end_first_connector);
                gr.DrawLine(line_pen, x, end_first_connector + before_Child.FP.height, x, diamond_top); // draw connector line to diamond
                gr.DrawLine(line_pen, x, diamond_top, x - CL / 4, diamond_top - CL / 4);                // draw left side of arrow
                gr.DrawLine(line_pen, x, diamond_top, x + CL / 4, diamond_top - CL / 4);                // draw right side of arrow
            }
            //Because there is not a before child, draw a connector from the head
            //to the diamond.
            else
            {
                diamond_top = end_first_connector;
            }

            // Draw the diamond shape
            this.Draw_Diamond_and_Text(gr, x, diamond_top,
                                       this.Text, diamond_pen,
                                       draw_text);

            if (this.has_diamond_breakpoint)
            {
                StopSign.Draw(gr, x - W / 2 - W / 6 - 2, diamond_top, W / 6);
            }

            // Draw connector from diamond
            gr.DrawLine(line_pen, x, diamond_top + H, x, diamond_top + H + H / 2);                           // draw connector line to top of before child
            gr.DrawLine(line_pen, x, diamond_top + H + H / 2, x - CL / 4, diamond_top + H + H / 2 - CL / 4); // draw left side of arrow
            gr.DrawLine(line_pen, x, diamond_top + H + H / 2, x + CL / 4, diamond_top + H + H / 2 - CL / 4); // draw right side of arrow

            //Because there is an after child, draw the after child and then a connector from the
            //after child to the bottom.
            if (after_Child != null && !this.is_compressed)
            {
                after_bottom = diamond_top + H + H / 2 + after_Child.FP.height + CL;

                // Draw the after_Child graphic
                after_Child.draw(gr, x, diamond_top + H + H / 2);

                //Draw connector from after_child to the bottom
                gr.DrawLine(line_pen, x, diamond_top + H + H / 2 + after_Child.FP.height, x, after_bottom); // draw connector line
                gr.DrawLine(line_pen, x, after_bottom, x - CL / 4, after_bottom - CL / 4);                  // draw left side of arrow
                gr.DrawLine(line_pen, x, after_bottom, x + CL / 4, after_bottom - CL / 4);                  // draw right side of arrow
            }
            //Because there is not an after child, draw the connector from the diamond
            //to the bottom.
            else
            {
                after_bottom = diamond_top + H + H / 2;
            }

            //draw line from bottom center to right, then up, then left to head
            gr.DrawLine(line_pen, x, after_bottom, x_right, after_bottom);         // draw connector line to right
            if (!Component.USMA_mode)
            {
                gr.DrawLine(line_pen, x_right, after_bottom, x_right, y + H / 2);                    // draw connector line up
                gr.DrawLine(line_pen, x_right, y + H / 2, x + W / 2, y + H / 2);                     // draw connector line to head
                gr.DrawLine(line_pen, x + W / 2, y + H / 2, x + W / 2 + CL / 4, y + H / 2 - CL / 4); // draw top side of arrow
                gr.DrawLine(line_pen, x + W / 2, y + H / 2, x + W / 2 + CL / 4, y + H / 2 + CL / 4); // draw bottom side of arrow
            }
            else
            {
                gr.DrawLine(line_pen, x_right, after_bottom, x_right, y + W / 8);                    // draw connector line up
                gr.DrawLine(line_pen, x_right, y + W / 8, x + W / 8, y + W / 8);                     // draw connector line to head
                gr.DrawLine(line_pen, x + W / 8, y + W / 8, x + W / 8 + CL / 4, y + W / 8 - CL / 4); // draw top side of arrow
                gr.DrawLine(line_pen, x + W / 8, y + W / 8, x + W / 8 + CL / 4, y + W / 8 + CL / 4); // draw bottom side of arrow
            }

            // Draw left line from the diamond
            if (draw_text && this.Is_Wide_Diamond())
            {
                gr.DrawLine(line_pen,
                            x_left, diamond_top + H / 2,
                            x - this.drawing_text_width / 2 - W / 4, diamond_top + H / 2); // draw left line
            }
            else
            {
                gr.DrawLine(line_pen,
                            x_left, diamond_top + H / 2,
                            x - W / 2, diamond_top + H / 2);                                  // draw left line
            }
            gr.DrawLine(line_pen, x_left, diamond_top + H / 2, x_left, after_bottom + H / 2); // draw down line
            gr.DrawLine(line_pen, x_left, after_bottom + H / 2, x, after_bottom + H / 2);     // draw line back to right


            if (this.Successor != null)
            {
                // draw connector line to successor
                gr.DrawLine(line_pen, x, after_bottom + H / 2, x, after_bottom + H / 2 + CL);
                // draw left side of arrow
                gr.DrawLine(line_pen, x, after_bottom + H / 2 + CL, x - CL / 4, after_bottom + H / 2 + CL - CL / 4);
                // draw right side of arrow
                gr.DrawLine(line_pen, x, after_bottom + H / 2 + CL, x + CL / 4, after_bottom + H / 2 + CL - CL / 4);
                Successor.draw(gr, x, after_bottom + H / 2 + CL);
            }

            if (this.W > 30)
            {
                LP = "Loop";
            }
            else
            {
                LP = "";
            }
            if (draw_text)
            {
                // swap Yes and No for reversed loop logic
                if (!Component.reverse_loop_logic)
                {
                    if (this.Is_Wide_Diamond())
                    {
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - this.drawing_text_width / 2 - W / 4 - length_of_yesStr / 2,
                                      diamond_top + H / 2 - 4,
                                      PensBrushes.centered_stringFormat);
                    }
                    else
                    {
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush, x - W / 2 - length_of_yesStr,
                                      diamond_top + H / 2 - 4,
                                      PensBrushes.centered_stringFormat);
                    }
                    gr.DrawString("No", PensBrushes.default_arial,
                                  PensBrushes.blackbrush, x + length_of_noStr,
                                  diamond_top + H + 5,
                                  PensBrushes.centered_stringFormat);
                }
                else
                {
                    if (this.Is_Wide_Diamond())
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - this.drawing_text_width / 2 - W / 4 - length_of_noStr / 2,
                                      diamond_top + H / 2 - 4,
                                      PensBrushes.centered_stringFormat);
                    }
                    else
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush, x - W / 2 - length_of_noStr,
                                      diamond_top + H / 2 - 4,
                                      PensBrushes.centered_stringFormat);
                    }
                    gr.DrawString("Yes", PensBrushes.default_arial,
                                  PensBrushes.blackbrush, x + length_of_yesStr,
                                  diamond_top + H + 5,
                                  PensBrushes.centered_stringFormat);
                }
                rect = new System.Drawing.Rectangle(x - W / 2, Y + (H * 6) / 16, W, this.height_of_text);

                // draw "Loop" inside oval if not USMA mode
                if (!Component.USMA_mode)
                {
                    gr.DrawString(LP, PensBrushes.default_times, PensBrushes.blackbrush,
                                  rect, PensBrushes.centered_stringFormat);
                }
            }
            if (draw_text)
            {
                base.draw(gr, x, y);
            }
        }
示例#2
0
        public override void draw(System.Drawing.Graphics gr, int x, int y)
        {
            bool draw_text;
            int  box_width;

            if ((this.scale <= .4) || (this.head_heightOrig < 10))
            {
                draw_text = false;
            }
            else
            {
                draw_text = Component.text_visible;
            }
            if (draw_text)
            {
                base.draw(gr, x, y);
            }

            int delta = W / 8;

            X = x;
            Y = y;

            height_of_text = Convert.ToInt32((gr.MeasureString(
                                                  "Yes", PensBrushes.default_times)).Height);

            width_of_text = Convert.ToInt32((gr.MeasureString(
                                                 this.getDrawText() + " X", PensBrushes.default_times)).Width);

            gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            System.Drawing.Pen pen;
            if (this.selected)
            {
                pen = PensBrushes.red_pen;
            }
            else if (this.running)
            {
                pen = PensBrushes.chartreuse_pen;
            }
            else
            {
                pen = PensBrushes.blue_pen;
            }
            if (this.drawing_text_width > W)
            {
                box_width = this.drawing_text_width + 3 * delta / 2;
            }
            else
            {
                box_width = W;
            }
            gr.DrawLine(pen, x - box_width / 2 + delta, y,
                        x + box_width / 2, y);             // draw top line
            gr.DrawLine(pen, x + box_width / 2, y,
                        x + box_width / 2 - delta, y + H); // draw right line
            gr.DrawLine(pen, x - box_width / 2, y + H,
                        x + box_width / 2 - delta, y + H); // draw bottom line
            gr.DrawLine(pen, x - box_width / 2, y + H,
                        x - box_width / 2 + delta, y);     // draw bottom line
            if (this.has_breakpoint)
            {
                StopSign.Draw(gr, x - box_width / 2 - W / 6 - 2, y, W / 6);
            }

            if (this.is_input)
            {
                gr.DrawLine(pen, x - box_width / 2 + 3 * W / 32 - W / 4, y + H / 4,
                            x - box_width / 2 + 3 * W / 32, y + H / 4);                 // input line
                gr.DrawLine(pen, x - box_width / 2 + 3 * W / 32, y + H / 4,
                            x - box_width / 2 + 3 * W / 32 - W / 8, y + H / 4 - H / 8); // up arrow
                gr.DrawLine(pen, x - box_width / 2 + 3 * W / 32, y + H / 4,
                            x - box_width / 2 + 3 * W / 32 - W / 8, y + H / 4 + H / 8); // down arrow

/*				gr.DrawLine(pen,x-box_width/2-W/32,y+H/4,
 *                                      x-box_width/2-W/32+W/3,y+H/4); // input line
 *                              gr.DrawLine(pen,x-box_width/2-W/32+W/3,y+H/4,
 *                                      x-box_width/2-W/32+W/3-W/8,y+H/4-H/8); // up arrow
 *                              gr.DrawLine(pen,x-box_width/2-W/32+W/3,y+H/4,
 *                                      x-box_width/2-W/32+W/3-W/8,y+H/4+H/8); // down arrow
 */
            }
            else
            {
                gr.DrawLine(pen, x + box_width / 2 - 3 * W / 32, y + H - H / 4,
                            x + box_width / 2 - 3 * W / 32 + W / 4, y + H - H / 4);                 // output line
                gr.DrawLine(pen, x + box_width / 2 - 3 * W / 32 + W / 4, y + H - H / 4,
                            x + box_width / 2 - 3 * W / 32 + W / 4 - W / 8, y + H - H / 4 - H / 8); // up arrow
                gr.DrawLine(pen, x + box_width / 2 - 3 * W / 32 + W / 4, y + H - H / 4,
                            x + box_width / 2 - 3 * W / 32 + W / 4 - W / 8, y + H - H / 4 + H / 8); // down arrow

/*				gr.DrawLine(pen,x+box_width/2-3*W/16,y+H-H/4,
 *                                      x+box_width/2-3*W/16+W/3,y+H-H/4); // output line
 *                              gr.DrawLine(pen,x+box_width/2-3*W/16+W/3,y+H-H/4,
 *                                      x+box_width/2-3*W/16+W/3-W/8,y+H-H/4-H/8); // up arrow
 *                              gr.DrawLine(pen,x+box_width/2-3*W/16+W/3,y+H-H/4,
 *                                      x+box_width/2-3*W/16+W/3-W/8,y+H-H/4+H/8); // down arrow
 */
            }


            if (draw_text)
            {
                if (Component.full_text)
                {
                    // we get rect from footprint
                    if (drawing_text_width > 0)
                    {
                        rect = new System.Drawing.Rectangle(x - drawing_text_width / 2, Y + (H * 1) / 32,
                                                            drawing_text_width, this.height_of_text * 3);
                    }
                    else
                    {
                        rect = new System.Drawing.Rectangle(x - this.width_of_text / 2, Y + (H * 6) / 16,
                                                            this.width_of_text, this.height_of_text);
                    }
                }
                else
                {
                    rect = new System.Drawing.Rectangle(x - (W * 7) / 16, Y + (H * 6) / 16, W - W / 8, this.height_of_text);
                }

                if (this.Text == "Error")
                {
                    gr.DrawString(this.Text, PensBrushes.default_times, PensBrushes.redbrush, rect, PensBrushes.centered_stringFormat);
                }
                else
                {
                    gr.DrawString(this.getDrawText(),
                                  PensBrushes.default_times,
                                  PensBrushes.blackbrush, rect,
                                  PensBrushes.centered_stringFormat);
                }
            }

            if (Successor != null)
            {
                if (this.selected)
                {
                    pen = PensBrushes.red_pen;
                }
                else
                {
                    pen = PensBrushes.blue_pen;
                }
                gr.DrawLine(pen, x, y + H, x, y + H + CL);                        // draw connector line to successor
                gr.DrawLine(pen, x, y + H + CL, x - CL / 4, y + H + CL - CL / 4); // draw left side of arrow
                gr.DrawLine(pen, x, y + H + CL, x + CL / 4, y + H + CL - CL / 4); // draw right side of arrow

                Successor.scale = this.scale;
                Successor.draw(gr, x, y + H + CL);
            }
        }
示例#3
0
        public override void draw(System.Drawing.Graphics gr, int x, int y)
        {
            int  left_bottom, right_bottom;
            bool draw_text;

            if ((this.scale <= .4) || (this.head_heightOrig < 10))
            {
                draw_text = false;
            }
            else
            {
                draw_text = Component.text_visible;
            }

            X = x;
            Y = y;

            height_of_text = Convert.ToInt32((gr.MeasureString(
                                                  "Yes", PensBrushes.default_times)).Height);

            width_of_text = Convert.ToInt32((gr.MeasureString(
                                                 this.Text + "XX", PensBrushes.default_times)).Width);

            int length_of_yesStr = Convert.ToInt32((gr.MeasureString(
                                                        "Yes", PensBrushes.default_arial)).Width);
            int length_of_noStr = Convert.ToInt32((gr.MeasureString(
                                                       "No", PensBrushes.default_arial)).Width);


            //length of line from horizontal to children or bottom
            line_height = H;
            // y coord of top of right child connector or bottom
            left_connector_y  = Y + H / 2 + line_height;
            right_connector_y = Y + H / 2 + line_height;


            // bottom y coord without children
            min_bottom = Y + H / 2 + line_height;
            bottom     = min_bottom;

            x_left = x - W;
            y_left = y + H / 2;

            y_right = y + H / 2;
            x_right = x + W;

            if (draw_text && this.Is_Wide_Diamond())
            {
                x_left  -= this.drawing_text_width / 2 - W / 2;
                x_right += this.drawing_text_width / 2 - W / 2;
            }

            // same for either USMA or regular mode
            if (left_Child != null && !this.is_compressed)
            {
                int temp = x - left_Child.FP.right - W / 2;
                if (temp < x_left)
                {
                    x_left = temp;
                }
            }
            if (right_Child != null && !this.is_compressed)
            {
                int temp = x + right_Child.FP.left + W / 2;
                if (temp > x_right)
                {
                    x_right = temp;
                }
            }

            // for USMA mode, move down the right side below the diamond
            // add room for the connector
            if (Component.USMA_mode)
            {
                x_right            = x;
                y_right            = y + H;
                left_connector_y  -= CL;
                right_connector_y -= CL;

                // don't need to check the left child only case as it is handled above
                if (left_Child != null && right_Child != null && !this.is_compressed)
                {
                    int temp = x - (right_Child.FP.left + left_Child.FP.right + W / 2);
                    if (temp < x_left)
                    {
                        x_left = temp;
                    }
                }
                else if (right_Child != null && !this.is_compressed)
                {
                    int temp = x - (right_Child.FP.left + W / 2);
                    if (temp < x_left)
                    {
                        x_left = temp;
                    }
                }
            }


            if (left_Child != null && !this.is_compressed)
            {
                left_bottom = min_bottom + left_Child.FP.height + CL;
                bottom      = left_bottom;
            }

            if (right_Child != null && !this.is_compressed)
            {
                right_bottom = min_bottom + right_Child.FP.height + CL;
                if (Component.USMA_mode)
                {
                    right_bottom += CL;
                }
                // see also above-- we want bottom to be the max
                // of left, right and min_bottom
                if (right_bottom > bottom)
                {
                    bottom = right_bottom;
                }
            }


            gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            System.Drawing.Pen diamond_pen = PensBrushes.blue_pen;
            System.Drawing.Pen line_pen    = PensBrushes.blue_pen;

            // if the If control is selected make it red
            if (this.selected)
            {
                diamond_pen = PensBrushes.red_pen;
                line_pen    = PensBrushes.red_pen;
            }
            // else if the If control is running make the diamond green
            else if (this.running)
            {
                diamond_pen = PensBrushes.chartreuse_pen;
                line_pen    = PensBrushes.blue_pen;
            }
            else if (this.is_compressed && this.have_child_running())
            {
                diamond_pen = PensBrushes.chartreuse_pen;
                line_pen    = PensBrushes.chartreuse_pen;
            }


            if (this.has_breakpoint)
            {
                StopSign.Draw(gr, x - W / 2 - W / 6 - 2, y, W / 6);
            }

            // Draw the diamond shape
            this.Draw_Diamond_and_Text(gr, x, y, this.Text,
                                       diamond_pen, draw_text);

            // draw the left and right lines that extend horizontally
            if (draw_text && this.Is_Wide_Diamond())
            {
                gr.DrawLine(line_pen,
                            x - this.drawing_text_width / 2 - W / 4, y + H / 2,
                            x_left, y_left);                    // draw left line
                if (!Component.USMA_mode)
                {
                    gr.DrawLine(line_pen,
                                x + this.drawing_text_width / 2 + W / 4, y + H / 2,
                                x_right, y_right);        // draw right line
                }
            }
            else
            {
                gr.DrawLine(line_pen, x - W / 2, y + H / 2, x_left, y_left);     // draw left line
                if (!Component.USMA_mode)
                {
                    gr.DrawLine(line_pen, x + W / 2, y + H / 2, x_right, y_right); // draw right line
                }
            }

            // add extra space at the bottom for USMA mode
            if (!Component.USMA_mode)
            {
                left_bottom  = bottom;
                right_bottom = bottom;
            }
            else
            {
                left_bottom  = bottom - W / 8;
                right_bottom = bottom - W / 4;
            }

            if (left_Child != null && !this.is_compressed)
            {
                // draw the left connector to the left child
                // draw connector line to top of left child
                gr.DrawLine(line_pen, x_left, y_left, x_left, left_connector_y);
                // draw left side of arrow
                gr.DrawLine(line_pen, x_left, left_connector_y, x_left - CL / 4, left_connector_y - CL / 4);
                // draw right side of arrow
                gr.DrawLine(line_pen, x_left, left_connector_y, x_left + CL / 4, left_connector_y - CL / 4);

                // draw the left child
                left_Child.draw(gr, x_left, left_connector_y);

                // draw the left connector to last left child to the bottom
                // draw connector line to bottom left
                gr.DrawLine(line_pen, x_left, left_connector_y + left_Child.FP.height, x_left, left_bottom);
            }
            else
            {
                // draw the left connector to the bottom
                gr.DrawLine(line_pen, x_left, y_left, x_left, left_bottom);             // draw connector line to top of left child
            }
            // draw left side of arrow
            gr.DrawLine(line_pen, x_left, left_bottom, x_left - CL / 4, left_bottom - CL / 4);
            // draw left side of arrow
            gr.DrawLine(line_pen, x_left, left_bottom, x_left + CL / 4, left_bottom - CL / 4);

            if (right_Child != null && !this.is_compressed)
            {
                // draw the right connector to the right child
                gr.DrawLine(line_pen, x_right, y_right, x_right, right_connector_y);                             // draw connector line to top of right child
                gr.DrawLine(line_pen, x_right, right_connector_y, x_right - CL / 4, right_connector_y - CL / 4); // draw right side of arrow
                gr.DrawLine(line_pen, x_right, right_connector_y, x_right + CL / 4, right_connector_y - CL / 4); // draw right side of arrow

                // draw the right child
                right_Child.draw(gr, x_right, right_connector_y);

                // draw the right connector from last right child to the bottom
                gr.DrawLine(line_pen, x_right, right_connector_y + right_Child.FP.height,
                            x_right, right_bottom);            // draw connector line to bottom right
            }
            else
            {
                // draw the right connector to the bottom
                gr.DrawLine(line_pen, x_right, y_right, x_right, right_bottom);             // draw connector line to top of right child
            }
            // draw right side of arrow
            gr.DrawLine(line_pen, x_right, right_bottom, x_right - CL / 4, right_bottom - CL / 4);
            // draw right side of arrow
            gr.DrawLine(line_pen, x_right, right_bottom, x_right + CL / 4, right_bottom - CL / 4);


            if (Component.USMA_mode)
            {
                gr.DrawEllipse(line_pen, x_right - W / 8, right_bottom, W / 4, W / 4);
                // draw the bottom line
                gr.DrawLine(line_pen, x_left, left_bottom, x_right - W / 8, left_bottom);
            }
            else
            {
                // draw the bottom line
                gr.DrawLine(line_pen, x_left, bottom, x_right, bottom);
            }

            if (draw_text)
            {
                if (!Component.USMA_mode)
                {
                    if (this.Is_Wide_Diamond())
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x + this.drawing_text_width / 2 + W / 4 + length_of_noStr / 2,
                                      y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - this.drawing_text_width / 2 - W / 4 - length_of_yesStr / 2,
                                      y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                    }
                    else
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x + W / 2 + length_of_noStr, y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - W / 2 - length_of_yesStr, y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                    }
                }
                else                  // USMA mode
                {
                    if (this.Is_Wide_Diamond())
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - (this.drawing_text_width / 2 + W / 4 + length_of_noStr / 2),
                                      y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - W / 8 - length_of_yesStr / 2,
                                      y + H + 5,
                                      PensBrushes.centered_stringFormat);
                    }
                    else
                    {
                        gr.DrawString("No", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - (W / 2 + length_of_noStr), y + H / 2 - 5,
                                      PensBrushes.centered_stringFormat);
                        gr.DrawString("Yes", PensBrushes.default_arial,
                                      PensBrushes.blackbrush,
                                      x - W / 8 - length_of_yesStr, y + H + 5,
                                      PensBrushes.centered_stringFormat);
                    }
                }
            }

            if (Successor != null)
            {
                gr.DrawLine(line_pen, x, bottom, x, bottom + CL);                        // draw connector line to successor
                gr.DrawLine(line_pen, x, bottom + CL, x - CL / 4, bottom + CL - CL / 4); // draw left side of arrow
                gr.DrawLine(line_pen, x, bottom + CL, x + CL / 4, bottom + CL - CL / 4); // draw right side of arrow
                Successor.draw(gr, x, bottom + CL);
            }
            if (draw_text)
            {
                base.draw(gr, x, y);
            }
        }
示例#4
0
        public override void draw(System.Drawing.Graphics gr, int x, int y)
        {
            bool draw_text;
            int  box_width;

            // determine whether or not to draw the text
            if ((this.scale <= .4) || (this.head_heightOrig < 10))
            {
                draw_text = false;
            }
            else
            {
                draw_text = Component.text_visible;
            }

            X = x;
            Y = y;

            height_of_text = Convert.ToInt32((gr.MeasureString(
                                                  "Yes", PensBrushes.default_times)).Height);

            width_of_text = Convert.ToInt32((gr.MeasureString(
                                                 this.Text + "XX", PensBrushes.default_times)).Width);

            gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            System.Drawing.Pen pen_color;
            if (this.selected)
            {
                pen_color = PensBrushes.red_pen;
            }
            else if (this.running)
            {
                pen_color = PensBrushes.chartreuse_pen;
            }
            else
            {
                pen_color = PensBrushes.blue_pen;
            }
            if (this.drawing_text_width > W)
            {
                box_width = this.drawing_text_width;
            }
            else
            {
                box_width = W;
            }
            if (this.has_breakpoint)
            {
                StopSign.Draw(gr, x - box_width / 2 - W / 6 - 2, y, W / 6);
            }

            // draw box if not USMA or not call
            if (this.kind != Kind_Of.Call || !Component.USMA_mode)
            {
                gr.DrawRectangle(pen_color, x - box_width / 2,
                                 y, box_width, H);
            }
            else
            {
                // top line
                gr.DrawLine(pen_color,
                            x - box_width / 2, y,
                            x + box_width / 2, y);
                // left line
                gr.DrawLine(pen_color,
                            x - box_width / 2, y,
                            x - box_width / 2, y + 3 * H / 4);
                // right line
                gr.DrawLine(pen_color,
                            x + box_width / 2, y,
                            x + box_width / 2, y + 3 * H / 4);
                // left bottom
                gr.DrawLine(pen_color,
                            x - box_width / 2, y + 3 * H / 4,
                            x, y + H);
                // right bottom
                gr.DrawLine(pen_color,
                            x, y + H,
                            x + box_width / 2, y + 3 * H / 4);
            }

            if (this.kind == Kind_Of.Call && !Component.USMA_mode)
            {
                gr.DrawLine(pen_color,
                            x + box_width / 2, y + 5 * H / 12,
                            x + box_width / 2 + W / 8, y + 5 * H / 12);
                gr.DrawLine(pen_color,
                            x + box_width / 2 + W / 8, y + 5 * H / 12,
                            x + box_width / 2 + W / 8, y + H / 4);
                gr.DrawLine(pen_color,
                            x + box_width / 2 + W / 8, y + H / 4,
                            x + box_width / 2 + 2 * W / 8, y + H / 2);
                gr.DrawLine(pen_color,
                            x + box_width / 2, y + 7 * H / 12,
                            x + box_width / 2 + W / 8, y + 7 * H / 12);
                gr.DrawLine(pen_color,
                            x + box_width / 2 + W / 8, y + 7 * H / 12,
                            x + box_width / 2 + W / 8, y + 3 * H / 4);
                gr.DrawLine(pen_color,
                            x + box_width / 2 + W / 8, y + 3 * H / 4,
                            x + box_width / 2 + 2 * W / 8, y + H / 2);
            }


            if ((draw_text) && (this.Text.Length > 0))
            {
                if (Component.full_text)
                {
                    // we get rect from footprint
                    if (drawing_text_width > W)
                    {
                        rect = new System.Drawing.Rectangle(x - drawing_text_width / 2, Y + (H * 1) / 32, drawing_text_width, this.height_of_text * 3);
                    }
                    else
                    {
                        rect = new System.Drawing.Rectangle(x - this.width_of_text / 2, Y + (H * 6) / 16, this.width_of_text, this.height_of_text);
                    }
                }
                else
                {
                    rect = new System.Drawing.Rectangle(x - W / 2, Y + (H * 6) / 16, W, this.height_of_text);
                }

                if (this.Text == "Error")
                {
                    gr.DrawString(this.Text, PensBrushes.default_times, PensBrushes.redbrush, rect, PensBrushes.centered_stringFormat);
                }
                else
                {
                    gr.DrawString(this.getDrawText(),
                                  PensBrushes.default_times,
                                  PensBrushes.blackbrush,
                                  rect, PensBrushes.centered_stringFormat);
                }
            }

            if (this.Successor != null)
            {
                // color for connector line
                System.Drawing.Pen pen;

                if (this.selected)
                {
                    pen = PensBrushes.red_pen;
                }
                else
                {
                    pen = PensBrushes.blue_pen;
                }
                gr.DrawLine(pen, x, y + H, x, y + H + CL);                        // draw connector line to successor
                gr.DrawLine(pen, x, y + H + CL, x - CL / 4, y + H + CL - CL / 4); // draw left side of arrow
                gr.DrawLine(pen, x, y + H + CL, x + CL / 4, y + H + CL - CL / 4); // draw right side of arrow

                Successor.scale = this.scale;
                Successor.draw(gr, x, y + H + CL);
            }

            if (draw_text)
            {
                base.draw(gr, x, y);
            }
        }