Esempio n. 1
0
        void drawTo(Graphics g)
        {
            // Contact Point
            Vector    center = Vector.V(0, 0);
            Vector    textdir = Vector.V(1, 0);
            Vector    textpos = Vector.V(1, 0);
            Vector    dos = Vector.V(1, 0);
            int       alx = 0; int aly = 0;
            int       cwidth = 1;
            Rectangle r      = getRectangle();

            center = Vector.V(r);
            switch (_orientation)
            {
            case RTOrientation.East:
                cwidth  = Height;
                dos     = Vector.V(1, 0);
                textdir = Vector.V(1, 0);
                textpos = Vector.V(Width - cwidth, Height / 2);
                alx     = 1;
                aly     = 0;
                break;

            case RTOrientation.North:
                cwidth  = Width;
                dos     = Vector.V(0, -1);
                textdir = Vector.V(0, -1);
                textpos = Vector.V(Width / 2, cwidth);
                alx     = 1;
                aly     = 0;
                break;

            case RTOrientation.West:
                cwidth  = Height;
                dos     = Vector.V(-1, 0);
                textdir = Vector.V(1, 0);
                textpos = Vector.V(cwidth, Height / 2);
                alx     = -1;
                aly     = 0;
                break;

            case RTOrientation.South:
                cwidth  = Width;
                dos     = Vector.V(0, 1);
                textdir = Vector.V(0, -1);
                textpos = Vector.V(Width / 2, Height - 1 - cwidth);
                alx     = -1;
                aly     = 0;
                break;
            }
            g.DrawRectangle(contactPen, r);
            switch (_IOtype)
            {
            case ProcessingIOType.SignalInput:
                GraphicsUtil.drawArrow(g, center + dos * cwidth / 2 * 0.8, center - dos * cwidth / 2 * 0.8,
                                       (_highlighted) ? contactHighlightPen : contactPen);
                break;

            case ProcessingIOType.SignalOutput:
                GraphicsUtil.drawArrow(g, center - dos * cwidth / 2 * 0.8, center + dos * cwidth / 2 * 0.8,
                                       (_highlighted) ? contactHighlightPen : contactPen);
                break;

            case ProcessingIOType.DataInput:
                GraphicsUtil.drawDoubleArrow(g, center + dos * cwidth / 2 * 0.8, center - dos * cwidth / 2 * 0.8,
                                             (_highlighted) ? contactHighlightPen : contactPen);
                break;

            case ProcessingIOType.DataOutput:
                GraphicsUtil.drawDoubleArrow(g, center - dos * cwidth / 2 * 0.8, center + dos * cwidth / 2 * 0.8,
                                             (_highlighted) ? contactHighlightPen : contactPen);
                break;
            }

            // Title
            if (_showTitle && (_title != null) && (_title.Length > 0))
            {
                GraphicsUtil.drawText(g, textpos, _titleFont, scale,
                                      _title, 0, 2, alx, aly, textdir, titleBrush);
            }
        }