Пример #1
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);
        }
Пример #2
0
        void getWfCoords(ref Vector wfCenter, ref Vector wfSize, ref GraphicsUtil.TextPosition titlePosition)
        {
            GraphicsUtil.TextAlignment ta = _titlePos;
            if ((_title == null) || (_title.Length < 1))
            {
                ta = GraphicsUtil.TextAlignment.off;
            }
            Size sz = new Size(_displaySize.Width + 4, _displaySize.Height + 4);

            wfSize = Vector.V(_displaySize) * scale;
            GraphicsUtil.dualSplit(ClientSize, sz, scale, ref wfCenter, ref titlePosition, _titlePos);
        }
Пример #3
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

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

            GraphicsUtil.TextPosition tpos = new GraphicsUtil.TextPosition();
            GraphicsUtil.dualSplit(ClientSize, _valueSize, scale, ref valueCenter, ref tpos, _titlePos);
            Rectangle valueR = VectorRect.FromCenterSize(valueCenter, Vector.V(_valueSize)).rectangle;

            if (valueR.Contains(e.Location))
            {
                // Hit in Value
                // Show Value Selector Window
                FlexibleInputWin dw;
                switch (_inputType)
                {
                case RTFlexInputType.String:
                    dw = new FlexibleInputWin(_title, _stringVal);
                    dw.StartPosition = FormStartPosition.Manual;
                    dw.Location      = PointToScreen(new Point(0, 0));
                    dw.ShowDialog();
                    _stringVal = dw.stringValue;
                    break;

                case RTFlexInputType.Integer:
                    if (_minVal < _maxVal)
                    {
                        dw = new FlexibleInputWin(_title, ((_unit != null) && (_unit.Length > 0))?_unit:null, (int)_minVal, (int)_maxVal, _intVal);
                    }
                    else
                    {
                        dw = new FlexibleInputWin(_title, ((_unit != null) && (_unit.Length > 0)) ? _unit : null, _intVal);
                    }
                    dw.StartPosition = FormStartPosition.Manual;
                    dw.Location      = PointToScreen(new Point(0, 0));
                    dw.ShowDialog();
                    _intVal = dw.intValue;
                    break;

                case RTFlexInputType.Float:
                    if (_minVal < _maxVal)
                    {
                        dw = new FlexibleInputWin(_title, ((_unit != null) && (_unit.Length > 0)) ? _unit : null, _minVal, _maxVal, _floatVal, _format);
                    }
                    else
                    {
                        dw = new FlexibleInputWin(_title, ((_unit != null) && (_unit.Length > 0)) ? _unit : null, _floatVal, _format);
                    }
                    dw.StartPosition = FormStartPosition.Manual;
                    dw.Location      = PointToScreen(new Point(0, 0));
                    dw.ShowDialog();
                    _floatVal = dw.floatValue;
                    break;
                }
                newValue();
                Invalidate();
            }
        }