Пример #1
0
        protected override void OnPaint(PaintEventArgs aPArgs)
        {
            if (_neverinitiated)
            {
                calculateFrame();
            }
            Graphics lGraph = aPArgs.Graphics;

            lGraph.SmoothingMode = SmoothingMode.HighQuality;
            int lMainTop   = (this.ClientRectangle.Height - _barHeight) / 2 - _barHeight * 2;
            int lSubTop    = (this.ClientRectangle.Height - _barHeight) / 2 - _barHeight;
            int lBarTop    = (this.ClientRectangle.Height - _barHeight) / 2;
            int lSubBarTop = (this.ClientRectangle.Height - _barHeight) / 2 + _barHeight + _barHeight / 2;
            int lBarWidth  = this.ClientRectangle.Width - (_leftMargin + _rightMargin);
            int lMainW     = (int)(lBarWidth * ((_cval - _cmin) / (double)(_cmax - _cmin)));
            int lSubW      = (int)(lBarWidth * ((_scval - _scmin) / (double)(_scmax - _scmin)));

            // The background:
            Pen   lPen                 = new Pen(Color.Black);
            Brush lTextBrush           = new SolidBrush(_textColor);
            LinearGradientBrush lBrush = new LinearGradientBrush(
                new Point(0, 0),
                new Point(0, this.ClientRectangle.Height),
                ColorTools.Darken(20, BackColor),
                ColorTools.Brighten(20, BackColor)
                );

            lGraph.FillRectangle(lBrush, ClientRectangle);

            // Main caption:
            lGraph.DrawString(
                "Itt vagyok!",
                new Font(Font, FontStyle.Bold),
                lTextBrush,
                _leftMargin * 2,
                lMainTop
                );

            // Sub caption:
            lGraph.DrawString(
                "Itt vagyok!",
                new Font(Font, FontStyle.Regular),
                lTextBrush,
                _leftMargin * 3,
                lSubTop
                );

            _cval  = 50;
            _scval = 25;
            // The main status bar
            lBrush = new LinearGradientBrush(
                new Point(_leftMargin, lBarTop - 2),
                new Point(_leftMargin, lBarTop + _barHeight + 2),
                ColorTools.Darken(50, BackColor),
                ColorTools.Darken(20, BackColor)
                );
            lGraph.FillRectangle(
                lBrush,
                new Rectangle(
                    _leftMargin, lBarTop,
                    lBarWidth, _barHeight
                    )
                );
            lBrush = new LinearGradientBrush(
                new Point(_leftMargin, lBarTop - 2),
                new Point(_leftMargin, lBarTop + _barHeight + 2),
                ColorTools.SetBrightness(80, _barColor),
                ColorTools.SetBrightness(20, _barColor)
                );
            lGraph.FillRectangle(
                lBrush,
                new Rectangle(
                    _leftMargin, lBarTop,
                    lMainW, _barHeight
                    )
                );

            // The sub status bar (if visible)
            if (_shSub)
            {
                lBrush = new LinearGradientBrush(
                    new Point(_leftMargin, lSubBarTop - 2),
                    new Point(_leftMargin, lSubBarTop + _barHeight + 2),
                    ColorTools.Darken(50, BackColor),
                    ColorTools.Darken(20, BackColor)
                    );
                lGraph.FillRectangle(
                    lBrush,
                    new Rectangle(
                        _leftMargin, lSubBarTop,
                        lBarWidth, _barHeight
                        )
                    );
                lBrush = new LinearGradientBrush(
                    new Point(_leftMargin, lSubBarTop - 2),
                    new Point(_leftMargin, lSubBarTop + _barHeight + 2),
                    ColorTools.SetBrightness(80, _barColor),
                    ColorTools.SetBrightness(20, _barColor)
                    );
                lGraph.FillRectangle(
                    lBrush,
                    new Rectangle(
                        _leftMargin, lSubBarTop,
                        lSubW, _barHeight
                        )
                    );
            }
        }