Пример #1
0
        void drawTo(Graphics g)
        {
            Vector center = Vector.Zero;
            Vector dim    = Vector.Zero;

            GraphicsUtil.TextPosition titlePosition = null;
            GraphicsUtil.TextPosition valuePosition = null;

            getLevelCoords(ref center, ref titlePosition, ref valuePosition, ref dim);
            if (titlePosition != null)
            {
                titlePosition.drawText(g, _titleFont, titleBrush, _title);
            }
            if (valuePosition != null)
            {
                string vs = getValueString();
                valuePosition.drawText(g, _valueFont, valueBrush, vs);
            }

            double v = 0;

            try {
                if (_logScale)
                {
                    v = (Math.Log(_value) - Math.Log(_min)) / (Math.Log(_max) - Math.Log(_min));
                }
                else
                {
                    v = (_value - _min) / (_max - _min);
                }
            } catch (Exception e)
            {
                v = 0;
            }

            switch (_levelType)
            {
            case RTLevelType.LinearH:
                GraphicsUtil.drawHBar(g, center, dim, v, framePen, fillBrush);
                break;

            case RTLevelType.LinearV:
                GraphicsUtil.drawVBar(g, center, dim, v, framePen, fillBrush);
                break;

            case RTLevelType.Rotary:
                GraphicsUtil.drawRotor(g, _openAngle, center, dim, v, gridCalculator, framePen, pointPen);
                break;
            }
        }