Esempio n. 1
0
        void drawTo(Graphics g)
        {
            // Background
            // Brush brushBackground = new SolidBrush(BackColor);
            // g.FillRectangle(brushBackground, this.ClientRectangle);

            Pen       framePen = new Pen(_frameColor);
            Rectangle r        = getSelFrame();

            g.DrawRectangle(framePen, r);
            if ((_title != null) && (_title.Length > 0))
            {
                Brush tBrush = new SolidBrush(_titleColor);
                GraphicsUtil.drawText(g, Vector.V(r.Left, Height / 2), _titleFont, scale, _title, 0, 2, 1, 0, Vector.V(1, 0), tBrush);
            }
            if ((entries != null) && (entries.Count > 0) && (selectedItem >= 0) && (selectedItem < entries.Count))
            {
                string s         = entries[selectedItem];
                Brush  textBrush = new SolidBrush(_textColor);
                r.Width   -= 2;
                r.Height  -= 2;
                r.Location = new Point(r.Location.X + 1, r.Location.Y + 1);
                g.SetClip(r);
                GraphicsUtil.drawText(g, Vector.V(r.Left, Height / 2), _textFont, scale, s, 0, 2, -1, 0, Vector.V(1, 0), textBrush);
            }
        }
Esempio n. 2
0
        void drawTo(Graphics g)
        {
            // Background
            // Brush brushBackground = new SolidBrush(BackColor);
            // g.FillRectangle(brushBackground, this.ClientRectangle);

            if ((_title != null) && (_title.Length > 0))
            {
                Brush  tBrush = new SolidBrush(_titleColor);
                Vector dir = Vector.V(1, 0).rot((double)-_angle * Math.PI / 180);
                Vector anchor = Vector.V(Width / 2, Height / 2);
                int    ax = 0, ay = 0;
                switch (_anchor)
                {
                case LableAnchor.TopLeft: anchor = Vector.V(0, 0); ax = -1; ay = 1; break;

                case LableAnchor.Top: anchor = Vector.V(Width / 2, 0); ax = 0; ay = 1; break;

                case LableAnchor.TopRight: anchor = Vector.V(Width - 1, 0); ax = 1; ay = 1; break;

                case LableAnchor.Left: anchor = Vector.V(0, Height / 2); ax = -1; ay = 0; break;

                case LableAnchor.Center: anchor = Vector.V(Width / 2, Height / 2); ax = 0; ay = 0; break;

                case LableAnchor.Right: anchor = Vector.V(Width - 1, Height / 2); ax = 1; ay = 0; break;

                case LableAnchor.BottomLeft: anchor = Vector.V(0, Height - 1); ax = -1; ay = -1; break;

                case LableAnchor.Bottom: anchor = Vector.V(Width / 2, Height - 1); ax = 0; ay = -1; break;

                case LableAnchor.BottomRight: anchor = Vector.V(Width - 1, Height - 1); ax = 1; ay = -1; break;
                }
                GraphicsUtil.drawText(g, anchor, _titleFont, scale, _title, 0, 2, ax, ay, dir, tBrush);
            }
        }
Esempio n. 3
0
        void drawTo(Graphics g)
        {
            // Background
            //Brush brushBackground = new SolidBrush(BackColor);
            //g.FillRectangle(brushBackground, this.ClientRectangle);

            Vector valueCenter = Vector.V(0, 0);

            GraphicsUtil.TextPosition tpos = new GraphicsUtil.TextPosition();
            GraphicsUtil.dualSplit(ClientSize, _valueSize, scale, ref valueCenter, ref tpos, _titlePos);

            if (_titlePos != GraphicsUtil.TextAlignment.off)
            {
                Brush titleBrush = new SolidBrush(_titleColor);
                tpos.drawText(g, _titleFont, titleBrush, _title);
            }

            Rectangle valueR = VectorRect.FromCenterSize(valueCenter, Vector.V(_valueSize) * scale).rectangle;

            // Frame
            if (_drawFrame)
            {
                Pen framePen = new Pen(_frameColor);
                g.DrawRectangle(framePen, valueR);
                valueR.Inflate(-1, -1);
                g.SetClip(valueR);
            }


            // Value
            Brush  textBrush = new SolidBrush(_valueColor);
            String s         = "";

            switch (_inputType)
            {
            case RTFlexInputType.String:
                s = _stringVal;
                break;

            case RTFlexInputType.Float:
                s = String.Format(getFormat(), _floatVal);
                if ((unit != null) && (unit.Length > 0))
                {
                    s = s + " " + unit;
                }
                break;

            case RTFlexInputType.Integer:
                s = String.Format("{0}", _intVal);
                if ((unit != null) && (unit.Length > 0))
                {
                    s = s + " " + unit;
                }
                break;
            }
            GraphicsUtil.drawText(g, valueCenter, _valueFont, scale, s, 0, 2, 0, 0, Vector.X, textBrush);
        }
Esempio n. 4
0
            public override void draw(Graphics g, Color colorBack, Color colorFront, Rectangle frame)
            {
                Vector center = Vector.V(frame);
                Brush  brush  = new SolidBrush(colorBack);

                g.FillRectangle(brush, frame);
                double scale = (double)frame.Height / 16;

                brush = new SolidBrush(colorFront);
                GraphicsUtil.drawText(g, center, font, scale, text, 0, 2, 0, 0, Vector.X, brush);
            }
Esempio n. 5
0
        public void draw(Graphics g)
        {
            RectangleF rf = getFrame();

            g.FillRectangle(brushBack, rf);
            g.DrawRectangle(penFrame, rf.Left - 1, rf.Top - 1, rf.Width + 2, rf.Height + 2);

            for (int i = 0; i < xAxis.gridLength; i++)
            {
                double pos = xAxis.grid[i].screen;
                g.DrawLine((xAxis.grid[i].isMajor) ? penGridMajor : penGrid,
                           (float)pos, rf.Top, (float)pos, rf.Bottom);
                if (xAxis.grid[i].show)
                {
                    GraphicsUtil.drawText(g, Vector.V(pos, rf.Bottom + 3), _fontText, 1, xAxis.grid[i].name, 0, 0, 0, 1, Vector.X, brushText);
                }
            }

            for (int i = 0; i < yAxis.gridLength; i++)
            {
                double pos = yAxis.grid[i].screen;
                g.DrawLine((yAxis.grid[i].isMajor) ? penGridMajor : penGrid,
                           rf.Left, (float)pos, rf.Right, (float)pos);
                if (yAxis.grid[i].show)
                {
                    GraphicsUtil.drawText(g, Vector.V(rf.Left - 3, pos), _fontText, 1, yAxis.grid[i].name, 1, 0, 1, 0, Vector.X, brushText);
                }
            }

            if (traces.Count > 0)
            {
                Region oldClip = g.Clip;
                g.Clip = new Region(rf);

                foreach (PlotTrace pt in traces)
                {
                    pt.draw(g, this);
                }

                g.Clip = oldClip;
            }
        }
Esempio n. 6
0
        void drawTo(Graphics g)
        {
            // Background
            //Brush brushBackground = new SolidBrush(BackColor);
            // g.FillRectangle(brushBackground, this.ClientRectangle);

            Vector center = Vector.V();
            Vector textpos = Vector.V();
            int    ax = 0, ay = 0;

            getLEDCoords(ref center, ref textpos, ref ax, ref ay);
            if ((_titlePos != RTTitlePos.Off) && (_title != null) && (_title.Length > 0))
            {
                Brush titleBrush = new SolidBrush(_titleColor);
                GraphicsUtil.drawText(g, textpos, _titleFont, scale, _title, 0, 2, ax, ay, Vector.V(1, 0), titleBrush);
            }

            Rectangle btnr      = VectorRect.FromCenterSize(center, Vector.V(_LEDDim) * scale).rectangle;
            Brush     fillBrush = new SolidBrush((_LEDState) ? _fillOnColor : _fillOffColor);
            Pen       framePen  = new Pen((_LEDState) ? _frameOnColor : _frameOffColor);

            g.FillRectangle(fillBrush, btnr);
            g.DrawRectangle(framePen, btnr);

            if (_LEDState && (_onText != null) && (_onText.Length > 0))
            {
                Brush textBrush = new SolidBrush(_textOnColor);
                GraphicsUtil.drawText(g, center, _textFont, scale, _onText, 0, 2, 0, 0, Vector.V(1, 0), textBrush);
            }
            else if (!_LEDState && (_offText != null) && (_offText.Length > 0))
            {
                Brush textBrush = new SolidBrush(_textOffColor);
                GraphicsUtil.drawText(g, center, _textFont, scale, _offText, 0, 2, 0, 0, Vector.V(1, 0), textBrush);
            }

            // needsRedraw = false;
        }
Esempio n. 7
0
        void drawTo(Graphics g)
        {
            GraphicsUtil.TextPosition titlePos = new GraphicsUtil.TextPosition();
            GraphicsUtil.TextPosition valuePos = new GraphicsUtil.TextPosition();
            VectorRect bar    = new VectorRect();
            VectorRect handle = new VectorRect();
            Vector     vlow   = Vector.Zero;
            Vector     vhigh  = Vector.Zero;

            getPositions(ref titlePos, ref valuePos, ref bar, ref handle, ref vlow, ref vhigh);

            double hlen = 0;

            if (_showScale)
            {
                if (_slideDirection == SlideDirection.Horizontal)
                {
                    hlen = (vhigh.x - vlow.x) / scale;
                    if (grid == null)
                    {
                        grid = new GridCalculator(_minVal, _maxVal, 1e-12, 1e-12, 1.1, _minVal, _maxVal, _logScale, 0, hlen, (double)_scaleFont.Height * _lableLength);
                    }
                    else if (grid.high != hlen)
                    {
                        grid.reScreen(0, hlen);
                    }
                }
                else
                {
                    hlen = (vlow.y - vhigh.y) / scale;
                    if (grid == null)
                    {
                        grid = new GridCalculator(_minVal, _maxVal, 1e-12, 1e-12, 1.1, _minVal, _maxVal, _logScale, 0, hlen, (double)_scaleFont.Height);
                        grid.showEndLables = true;
                    }
                    else if (grid.high != hlen)
                    {
                        grid.reScreen(0, hlen);
                    }
                }
            }

            // Title
            if (_showTitle && (_title != null) && (_title.Length > 0))
            {
                titlePos.drawText(g, _titleFont, titleBrush, _title);
            }

            // Value
            if (_showValue)
            {
                String s = String.Format(getFormat(), _val);
                if ((unit != null) && (unit.Length > 0))
                {
                    s = s + " " + unit;
                }
                valuePos.drawText(g, _valueFont, valueBrush, s);
            }
            g.DrawRectangle(penSlide, bar.rectangle);

            g.FillRectangle(brushSlideMark, handle.rectangle);
            g.DrawRectangle(penSlideMark, handle.rectangle);

            if (_showScale)
            {
                GraphicsUtil.drawLine(g, vlow, vhigh, scalePen);
                Vector vr    = 0.5 * _slideScaleWidth * scale * ((vhigh - vlow).norm).vrot90();
                Vector vtext = Vector.Zero;
                if (_slideDirection == SlideDirection.Horizontal)
                {
                    vtext = Vector.V(0, _slideScaleWidth / 2 * scale);
                }
                else
                {
                    vtext = Vector.V(_slideScaleWidth / 2 * scale, 0);
                }

                for (int i = 0; i < grid.gridLength; i++)
                {
                    Vector vpos = vlow + (vhigh - vlow) * grid.grid[i].screen / hlen;
                    if (grid.grid[i].isMajor)
                    {
                        GraphicsUtil.drawLine(g, vpos - vr, vpos + vr, scalePen);
                    }
                    else
                    {
                        GraphicsUtil.drawLine(g, vpos - vr / 2, vpos + vr / 2, scalePen);
                    }

                    if (_showScaleValues && grid.grid[i].show && (grid.grid[i].name.Length > 0))
                    {
                        if (_slideDirection == SlideDirection.Horizontal)
                        {
                            GraphicsUtil.drawText(g, vpos + vtext, _scaleFont, scale,
                                                  grid.grid[i].name, 0, 2, 0, 1, Vector.V(1, 0), scaleFontBrush);
                        }
                        else
                        {
                            GraphicsUtil.drawText(g, vpos + vtext, _scaleFont, scale,
                                                  grid.grid[i].name, 0, 2, -1, 0, Vector.V(1, 0), scaleFontBrush);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public void draw(Graphics g)
        {
            if (_isNamed)
            {
                bool selected = false;
                foreach (ProcessingConnection pc in connections)
                {
                    if (pc.selected)
                    {
                        selected = true;
                    }
                }

                Pen drawPen = null;
                if (selected)
                {
                    drawPen = penLineSelected;
                }
                else
                {
                    if (valid)
                    {
                        drawPen = penLineOk;
                    }
                    else
                    {
                        drawPen = penLineBad;
                    }
                }
                if (netType == ProcessingNetType.Data)
                {
                    drawPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                }
                else
                {
                    drawPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                foreach (RTIO io in connectedIOs)
                {
                    Vector pstart, pstop, textpos, textdir;
                    getNamedPoints(io, out pstart, out pstop, out textpos, out textdir);
                    Point p1 = pstart.Point;
                    Point p2 = pstop.Point;
                    g.DrawLine(penBack, p1, p2);
                    g.DrawLine(drawPen, p1, p2);
                    GraphicsUtil.drawText(g, textpos,
                                          owner.netNameFont, owner.scale,
                                          _name, 0, 2, -1, -1, textdir, owner.netNameBrush);
                }
            }
            else
            {
                updateConnections();
                foreach (ProcessingConnection pc in connections)
                {
                    Pen drawpen = null;
                    if (pc.selected)
                    {
                        drawpen = penLineSelected;
                    }
                    else
                    {
                        if (valid)
                        {
                            drawpen = penLineOk;
                        }
                        else
                        {
                            drawpen = penLineBad;
                        }
                    }
                    if (netType == ProcessingNetType.Data)
                    {
                        drawpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    }
                    else
                    {
                        drawpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    }
                    pc.bc.draw(g, penBack, drawpen);
                }
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        void drawTo(Graphics g)
        {
            // Background
            // Brush brushBackground = new SolidBrush(BackColor);
            // g.FillRectangle(brushBackground, this.ClientRectangle);
            Rectangle seq      = this.ClientRectangle;
            Pen       framePen = new Pen(frameColor);

            getSequencerGeometry(ref seq);
            g.DrawRectangle(framePen, seq);
            if (_hlCol >= 0)
            {
                int       x1 = seq.X + _hlCol * seq.Width / _columns;
                int       x2 = seq.X + (_hlCol + 1) * seq.Width / _columns;
                Rectangle hl = new Rectangle(x1, seq.Y, x2 - x1 - 1, seq.Height);
                Brush     hb = new SolidBrush(_highLightColor);
                g.FillRectangle(hb, hl);
            }
            if ((dragMode == DragMode.Holding) && (dragcol >= 0) && (dragcol >= 0))
            {
                int   x1 = seq.X + dragcol * seq.Width / _columns;
                int   x2 = seq.X + (dragcol + 1) * seq.Width / _columns;
                int   y1 = seq.Y + (_rows - 1 - (dragrow + 1)) * seq.Height / _rows;
                int   y2 = seq.Y + (_rows - 1 - dragrow) * seq.Height / _rows;
                Brush hs = new SolidBrush(_selectColor);
                g.FillRectangle(hs, new Rectangle(x1, 0, x2 - x1 + 1, seq.Y - 1));
                g.FillRectangle(hs, new Rectangle(0, y2, seq.X - 1, y2 - y1 + 1));
            }

            if (_showColHeads)
            {
                Brush colheadbrush = new SolidBrush(_colHeadColor);
                for (int c = 0; c < _columns; c++)
                {
                    Vector tp = new Vector(seq.X + (double)seq.Width / _columns * (c + 0.5), seq.Y);
                    GraphicsUtil.drawText(g, tp, _colHeadFont, scale, string.Format("{0}", (c % _takt) + 1), 0, 2, 0, -1, Vector.X, colheadbrush);
                }
            }
            if (_showRowHeads)
            {
                Brush rowheadbrush = new SolidBrush(_rowHeadColor);
                for (int r = 0; r < _rows; r++)
                {
                    Vector tp = new Vector(seq.X, seq.Y + (double)seq.Height / _rows * (r + 0.5));
                    GraphicsUtil.drawText(g, tp, _rowHeadFont, scale, notename(_rows - r), 0, 2, 1, 0, Vector.X, rowheadbrush);
                }
            }
            for (int c = 1; c < _columns; c++)
            {
                int cx = seq.X + seq.Width * c / _columns;
                g.DrawLine(framePen, cx, seq.Y, cx, seq.Y + seq.Height - 1);
            }
            for (int r = 1; r < _rows; r++)
            {
                int cy = seq.Y + seq.Height * r / _rows;
                g.DrawLine(framePen, seq.X, cy, seq.X + seq.Width - 1, cy);
            }
            Brush fb = new SolidBrush(fillOnColor);

            for (int r = 0; r < _rows; r++)
            {
                for (int c = 0; c < _columns; c++)
                {
                    if (_data[r, c] > 0)
                    {
                        Vector ctr = Vector.V(seq.X + (c + 0.5) * seq.Width / _columns, seq.Y + (_rows - 1 - r + 0.5) * seq.Height / _rows);
                        // ((SolidBrush)fb).Color = fillOnColor;
                        GraphicsUtil.fillCircle(g, ctr, (double)seq.Width / _columns / 3, fb);
                    }
                }
            }
        }
Esempio n. 11
0
        void drawTo(Graphics g)
        {
            // Background
            //Brush brushBackground = new SolidBrush(BackColor);
            //g.FillRectangle(brushBackground, this.ClientRectangle);

            Rectangle shape = new Rectangle();

            GraphicsUtil.TextPosition tp = new GraphicsUtil.TextPosition();
            getShapeCoords(ref shape, ref tp);

            if ((_titlePos != RTTitlePos.Off) && (_title != null) && (_title.Length > 0))
            {
                Brush titleBrush = new SolidBrush(_titleColor);
                tp.drawText(g, _titleFont, titleBrush, _title);
            }

            Pen       framePen = new Pen(_frameColor);
            Rectangle oshape   = shape;

            shape.Inflate(-1, -1);

            double ymin = 0, ymax = 0;

            Vector[] l = getShape(shape, ref ymin, ref ymax);

            Brush scaleBrush   = new SolidBrush(_scaleColor);
            Pen   majorGridPen = new Pen(_majorGridColor);
            Pen   minorGridPen = new Pen(_minorGridColor);

            for (int i = 0; i < gridY.gridLength; i++)
            {
                double y = shape.Bottom - gridY.grid[i].screen;
                string s = gridY.grid[i].name;
                if (gridY.grid[i].isMajor && _showYScale)
                {
                    GraphicsUtil.drawText(g, Vector.V(shape.Left, y), _scaleFont, scale, s, 0, 2, 1, 0, Vector.X, scaleBrush);
                }
                if (gridY.grid[i].isMajor && _showMajorYGrid)
                {
                    GraphicsUtil.drawLine(g, Vector.V(shape.Left, y), Vector.V(shape.Right, y), majorGridPen);
                }
                if (!gridY.grid[i].isMajor && _showMinorYGrid)
                {
                    GraphicsUtil.drawLine(g, Vector.V(shape.Left, y), Vector.V(shape.Right, y), minorGridPen);
                }
            }
            for (int i = 0; i < gridX.gridLength; i++)
            {
                double x = shape.Left + gridX.grid[i].screen;
                string s = gridX.grid[i].name;
                if (gridX.grid[i].isMajor && showXScale)
                {
                    GraphicsUtil.drawText(g, Vector.V(x, shape.Bottom), _scaleFont, scale, s, 0, 2, -1, 0, Vector.Y, scaleBrush);
                }
                if (gridX.grid[i].isMajor && _showMajorXGrid)
                {
                    GraphicsUtil.drawLine(g, Vector.V(x, shape.Bottom), Vector.V(x, shape.Top), majorGridPen);
                }
                if (!gridX.grid[i].isMajor && _showMinorXGrid)
                {
                    GraphicsUtil.drawLine(g, Vector.V(x, shape.Bottom), Vector.V(x, shape.Top), minorGridPen);
                }
            }

            g.DrawRectangle(framePen, oshape);

            Pen   anchorPen = new Pen(_anchorColor);
            Brush selBrush  = null;

            if (dragMode == DragMode.Holding)
            {
                selBrush = new SolidBrush(Color.Red);
            }
            Point[] p = new Point[l.Length];
            g.SetClip(shape);
            for (int i = 0; i < l.Length; i++)
            {
                p[i] = l[i].Point;
                if (i > 0)
                {
                    Rectangle A = new Rectangle(p[i].X - _anchorSize / 2, p[i].Y - _anchorSize / 2, _anchorSize, _anchorSize);
                    if ((dragMode == DragMode.Holding) && (dragSelect == i))
                    {
                        g.FillRectangle(selBrush, A);
                    }
                    else
                    {
                        g.DrawRectangle(anchorPen, A);
                    }
                }
            }
            Pen shapePen = new Pen(_shapeColor);

            g.DrawLines(shapePen, p);
        }
Esempio n. 12
0
        void drawTo(Graphics g)
        {
            double scl = scale;

            // Background
            //Brush brushBackground = new SolidBrush(BackColor);
            //g.FillRectangle(brushBackground, this.ClientRectangle);

            Vector center = Vector.V(Width / 2, Height / 2);

            // Title
            if (_showTitle && (_title != null) && (_title.Length > 0))
            {
                Brush textBrush = new SolidBrush(_titleColor);
                // g.DrawString(_title, _titleFont, textBrush, Width / 2, Height / 2);
                GraphicsUtil.drawText(g, center - Vector.V(0, _dialDiameter / 2 * scl), _titleFont, scl,
                                      _title, 0, 2, 0, -1, Vector.X, textBrush);
            }


            // Dial
            double     rad     = _dialDiameter * scl / 2;
            RectangleF rf      = Vector.RFC(center, Vector.diag(rad * 2 * 0.8));
            Pen        knobPen = new Pen(_dialColor);

            g.DrawEllipse(knobPen, rf);

            /*Brush brushRotKnob = new SolidBrush(_dialColor);
             * g.FillEllipse(brushRotKnob, rf);
             * Pen penRotKnob = new Pen(Color.AliceBlue);
             * rf = Vector.RFC(center, Vector.diag(rad * 2 * 0.8 * 0.9));
             * g.DrawEllipse(penRotKnob, rf);*/


            double slp        = dialPos();
            double phi        = Math.PI * 1 / 4 - (1 - slp) * Math.PI * 3 / 2;
            Pen    penRotMark = new Pen(_dialMarkColor);
            Vector pointpos   = center + Vector.V(rad * 0.6, 0).rot(phi);

            g.DrawEllipse(penRotMark, VectorRect.FromCenterSize(pointpos, Vector.V(rad / 5, rad / 5)).rectangleF);
            // g.DrawLine(penRotMark, (center + Vector.V(rad * 0.7, 0).rot(phi)).PointF, (center + Vector.V(rad * 0.3, 0).rot(phi)).PointF);


            if (_showScale)
            {
                // Grid
                grid.logScale = _logScale;
                grid.newRange(_minVal, _maxVal);
                Pen penRotScale = new Pen(_scaleColor);
                for (int i = 0; i < grid.gridLength; i++)
                {
                    double alpha = Math.PI / 4 - (1 - grid.grid[i].screen / grid.high) * 1.5 * Math.PI;
                    Vector vin   = Vector.V(rad * 0.85, 0).rot(alpha);
                    Vector vout  = Vector.V(rad * ((grid.grid[i].isMajor) ? (0.98) : (0.9)), 0).rot(alpha);
                    g.DrawLine(penRotScale, (center + vin).PointF, (center + vout).PointF);
                }
            }

            // Value
            if (_showValue)
            {
                String s         = String.Format(getFormat(), _val);
                Brush  textBrush = new SolidBrush(_valueColor);
                if ((unit != null) && (unit.Length > 0))
                {
                    s = s + " " + unit;
                }
                GraphicsUtil.drawText(g, center + Vector.V(0, _dialDiameter / 2 * scl), _valueFont, scl,
                                      s, 0, 2, 0, 1, Vector.X, textBrush);
            }
        }
Esempio n. 13
0
        void drawTo(Graphics g)
        {
            // Background
            // Brush brushBackground = new SolidBrush(BackColor);
            // g.FillRectangle(brushBackground, this.ClientRectangle);

            Rectangle sel, up, down;

            sel  = new Rectangle();
            up   = new Rectangle();
            down = new Rectangle();
            getFrames(ref sel, ref up, ref down);

            if ((_title != null) && (_title.Length > 0))
            {
                Brush tBrush = new SolidBrush(_titleColor);
                GraphicsUtil.drawText(g, Vector.V(sel.Left, Height / 2), _titleFont, scale, _title, 0, 2, 1, 0, Vector.V(1, 0), tBrush);
            }
            Pen framePen = new Pen(frontColor);

            g.DrawRectangle(framePen, sel);
            sel.Inflate(-1, -1);
            switch (_choiceType)
            {
            case ChoiceType.ListDefined:
                if ((_entries != null) && (_entries.Count > 0) && (selectedItem >= 0) && (selectedItem < _entries.Count))
                {
                    _entries[_selectedItem].draw(g, backColor, frontColor, sel);
                }
                if ((_entries != null) && (_entries.Count > 0))
                {
                    if (_selectedItem < _entries.Count - 1)
                    {
                        GraphicsUtil.drawTriangle(g, Vector.V(up), (double)up.Height, Vector.V(0, -1), framePen);
                    }
                    if (_selectedItem > 0)
                    {
                        GraphicsUtil.drawTriangle(g, Vector.V(down), (double)up.Height, Vector.V(0, 1), framePen);
                    }
                }
                break;

            case ChoiceType.Numeric:
                g.FillRectangle(backBrush, sel);
                g.DrawRectangle(framePen, sel);
                GraphicsUtil.drawText(g, Vector.V(sel), _valueFont, scale,
                                      String.Format("{0}", _numericMin + _selectedItem), 0, 2, 0, 0, Vector.X, frontBrush);
                if (_selectedItem < (_numericMax - _numericMin))
                {
                    GraphicsUtil.drawTriangle(g, Vector.V(up), (double)up.Height, Vector.V(0, -1), framePen);
                }
                if (_selectedItem > 0)
                {
                    GraphicsUtil.drawTriangle(g, Vector.V(down), (double)up.Height, Vector.V(0, 1), framePen);
                }
                break;

            case ChoiceType.NumericOff:
                g.FillRectangle(backBrush, sel);
                g.DrawRectangle(framePen, sel);
                if (_selectedItem == -1)
                {
                    GraphicsUtil.drawText(g, Vector.V(sel), _valueFont, scale,
                                          _offString, 0, 2, 0, 0, Vector.X, frontBrush);
                }
                else
                {
                    GraphicsUtil.drawText(g, Vector.V(sel), _valueFont, scale,
                                          String.Format("{0}", _numericMin + _selectedItem), 0, 2, 0, 0, Vector.X, frontBrush);
                }
                if (_selectedItem < (_numericMax - _numericMin))
                {
                    GraphicsUtil.drawTriangle(g, Vector.V(up), (double)up.Height, Vector.V(0, -1), framePen);
                }
                if (_selectedItem >= 0)
                {
                    GraphicsUtil.drawTriangle(g, Vector.V(down), (double)up.Height, Vector.V(0, 1), framePen);
                }
                break;
            }
        }
Esempio n. 14
0
        private void doPaint(Graphics g)
        {
            // Brush backBrush = new SolidBrush(Color.DarkMagenta);
            Rectangle cr           = ClientRectangle;
            Rectangle deleteButton = getDeleteButton();
            Rectangle shrinkButton = getShrinkButton();
            Rectangle activeButton = getActiveButton();

            int x1 = 0;
            int x2 = Width - 1;

            x2 -= deleteButton.Width;
            if (_hasActiveSwitch)
            {
                x1 += activeButton.Width;
            }
            if (_canShrink)
            {
                x2 -= shrinkButton.Width;
            }
            int centerpos = (x1 + x2) / 2;

            cr.Width  -= 1;
            cr.Height -= 1;
            if (_selected)
            {
                g.DrawRectangle(selectPen, cr);
            }
            else
            {
                g.DrawRectangle(framePen, cr);
            }

            if (_shrinked)
            {
                if ((_shrinkTitle != null) && (_shrinkTitle.Length > 0))
                {
                    GraphicsUtil.drawText(g, Vector.V(centerpos, 0), _titleFont, scale,
                                          _shrinkTitle, 0, 2, 0, 1, Vector.X, titleBrush);
                }
            }
            else
            {
                if ((_title != null) && (_title.Length > 0))
                {
                    GraphicsUtil.drawText(g, Vector.V(centerpos, 0), _titleFont, scale,
                                          _title, 0, 2, 0, 1, Vector.X, titleBrush);
                }
            }

            //if (_selected)
            //    framePen = new Pen(Color.Red);
            // g.DrawLine(framePen, new PointF((float)scale * 5, (float)scale * 15), new PointF((float) (Width - scale*5), (float)scale * 15));

            if ((dragMode == DragMode.DeleteBtn) && onDeleteButton)
            {
                GraphicsUtil.drawButton(g, deleteButton, GraphicsUtil.ButtonType.Delete, framePen, symbolOnPen);
            }
            else
            {
                GraphicsUtil.drawButton(g, deleteButton, GraphicsUtil.ButtonType.Delete, framePen, symbolPen);
            }
            if (_canShrink)
            {
                if ((dragMode == DragMode.ShrinkBtn) && onShrinkButton)
                {
                    GraphicsUtil.drawButton(g, shrinkButton, (_shrinked) ? GraphicsUtil.ButtonType.Expand : GraphicsUtil.ButtonType.Shrink, framePen, symbolOnPen);
                }
                else
                {
                    GraphicsUtil.drawButton(g, shrinkButton, (_shrinked) ? GraphicsUtil.ButtonType.Expand : GraphicsUtil.ButtonType.Shrink, framePen, symbolPen);
                }
            }
            if (_hasActiveSwitch)
            {
                bool showActive = _active;
                if ((dragMode == DragMode.ActiveBtn) && onActiveButton)
                {
                    showActive = !_active;
                }
                if (showActive)
                {
                    g.FillRectangle(activeBrush, activeButton);
                    GraphicsUtil.drawButton(g, activeButton, GraphicsUtil.ButtonType.Active, framePen, activePen);
                }
                else
                {
                    GraphicsUtil.drawButton(g, activeButton, GraphicsUtil.ButtonType.InActive, framePen, passivePen);
                }
            }
        }
Esempio n. 15
0
 public void drawText(Graphics g, Font f, Brush b, string s)
 {
     GraphicsUtil.drawText(g, anchor, f, scale, s, bx, spacing, ax, ay, dir, b);
 }