Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            if (_backImage != null)
            {
                g.DrawImage(_backImage, rect.ClientRect);
            }
            _bar = new Rectangle(rect.Left + 10, rect.Top + rect.Height / 2 - _barThinkness / 2, rect.Width - 20, _barThinkness);

            RoundedRectangle r2 = new RoundedRectangle(_bar, 5);

            if (_collection.Count > 2)
            {
                float temp = r2.Width / (_collection.Count - 1);
                if (temp >= 1)
                {
                    _interval = temp;
                }
            }
            else
            {
                _interval = r2.Width;
            }

            b.LinearColors = new Color[] { Color.Gray, Color.DarkGray };
            g.FillPath(b, r2.GetGraphicsPath());
            DrawMarking(g, _bar);
            if (_drag == null)
            {
                _drag = new Dragger(r2.ClientRect, Dragger.DragPosition.Horizontal);
            }
            if (_drag != null)
            {
                _drag.NormalColor   = _pointerBodyColor;
                _drag.SelectedColor = _pointerHoverColor;
                _drag.PointerColor  = _pointerColor;
            }
            _drag.draw(g);
            e.Graphics.DrawImage(_map, 0, 0);
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            Pen p = new Pen(Color.WhiteSmoke);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            if (_backImage != null)
            {
                g.DrawImage(_backImage, rect.ClientRect);
            }
            g.ResetClip();
            rect.Shrink(10);
            if (_panel != null)
            {
                _panel.Left               = rect.ClientRect.Left;
                _panel.Top                = rect.ClientRect.Top;
                _panel.Width              = rect.ClientRect.Width;
                _panel.Height             = rect.ClientRect.Height;
                _panel.DisplayValue       = _displayValue;
                _panel.DisplayFont        = _font;
                _panel.SweepAngle         = _sweepAngle;
                _panel.StartAngle         = _startGapAngle;
                _panel.PointerColor       = _pointerColor;
                _panel.PointerHandleColor = _pointerHandleColor;
                _panel.FontColor          = _fontColor;
                _panel.InnerBoderRing     = _border;
            }
            _panel.Draw(g);
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }
Exemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            PathGradientBrush pb = new PathGradientBrush(rect.GetGraphicsPath());

            if (_mouseDown == false)
            {
                pb.CenterColor    = Color.White;
                pb.SurroundColors = new Color[] { _backcolor };
                pb.CenterPoint    = new PointF(-2f, -2f);
            }
            else
            {
                pb.CenterColor    = Lighten(_backcolor);
                pb.SurroundColors = new Color[] { _backcolor };
            }
            g.FillPath(pb, rect.GetGraphicsPath());
            if (_offImage != null && _mouseDown == false)
            {
                g.DrawImage(_offImage, Helper.RectangleHelper.Shrink(rect.ClientRect, 5));
            }
            if (_onImage != null && _mouseDown == true)
            {
                g.DrawImage(_onImage, Helper.RectangleHelper.Shrink(rect.ClientRect, 5));
            }
            _light.ClientRect = new Rectangle(rect.Left + 5, 5, rect.Width - 10, 5);
            _light.Draw(g);
            e.Graphics.DrawImage(_map, 0, 0);
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            if (_backgrdImage != null)
            {
                g.DrawImage(_backgrdImage, rect.ClientRect);
            }
            rect.Shrink(10);
            _panel.Left           = rect.ClientRect.Left;
            _panel.Top            = rect.ClientRect.Top;
            _panel.Width          = rect.ClientRect.Width;
            _panel.Height         = rect.ClientRect.Height;
            _panel.Align          = _alignment;
            _panel.FlipMarking    = _flipMarking;
            _panel.MarkingStyle   = _marking;
            _panel.DisplayValue   = _displayValue;
            _panel.IndicatorColor = _indicatorColor;
            _panel.LabelFont      = _font;
            _panel.LabelFontColor = _labelFontColor;

            _panel.Draw(g);
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }
Exemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            //Draw the back image
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            if (_backImage != null)
            {
                g.SetClip(rect.GetGraphicsPath());
                g.DrawImage(_backImage, rect.ClientRect);
                g.ResetClip();
            }
            _panel.Left             = rect.ClientRect.Left;
            _panel.Top              = rect.ClientRect.Top;
            _panel.Width            = rect.ClientRect.Width;
            _panel.Height           = rect.ClientRect.Height;
            _panel.KnobHandleimage  = _knobHandleImage;
            _panel.MarkingType      = _markingType;
            _panel.MarkingImageType = _markingImage;
            _panel.FontColor        = _fontColor;
            _panel.MainFont         = _font;
            _panel.Draw(g);
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }
Exemplo n.º 6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            if (_font == null)
            {
                _font = new Font(FontFamily.GenericMonospace, 5);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backcolor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            GraphicsState state = g.Save();

            g.SetClip(rect.GetGraphicsPath());
            //Fill in backImgae
            if (_backimage != null)
            {
                g.DrawImage(_backimage, rect.ClientRect,
                            new Rectangle(0, 0, _backimage.Width, _backimage.Height), GraphicsUnit.Pixel);
            }
            g.Restore(state);

            int i     = 0;
            int width = CalculateWidth();

            foreach (RollingCounter dispanel  in _collection)
            {
                if (_alignment == Alignment.Center)
                {
                    dispanel.Left = i * width + _edgeOffsetFromX;
                }
                else if (_alignment == Alignment.Left)
                {
                    dispanel.Left = i * width + 7;
                }
                else
                {
                    dispanel.Left = i * width + 2 * _edgeOffsetFromX - 7;
                }
                dispanel.Top    = _edgeOffsetFromY;
                dispanel.Width  = width;
                dispanel.Height = this.Height - 2 * _edgeOffsetFromY;

                dispanel.Font = _font;

                /*dispanel.FontColor = _color;
                 * dispanel.MainColor = _counterColor;*/
                dispanel.ScrollEffect = _scrollEffect;
                dispanel.Draw(g);
                i++;
            }
            g.Dispose();
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }
Exemplo n.º 7
0
        public void Draw(Graphics e)
        {
            int diff = _clientRect.X + _clientRect.Width / 2 - _meterWidth / 2 - _clientRect.X;

            if (_collection.Count > 1)
            {
                int temp = rect.Height / _collection.Count;
                if (temp >= 1)
                {
                    _interval = temp;
                }
            }
            else
            {
                _interval = rect.Height;
            }
            GraphicsState state = e.Save();

            if (_alignment == Alignment.right)
            {
                e.TranslateTransform(diff, 0);
            }
            else if (_alignment == Alignment.left)
            {
                e.TranslateTransform(-diff, 0);
            }

            e.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            int        i = 1;
            RectangleF cRect;
            RectangleF pictRect;
            PointF     p1, p2;

            foreach (MeterLabel ml in _collection)
            {
                Size s = TextRenderer.MeasureText(ml.Desc, _font);
                if (_flipMarking == Flip.Left)
                {
                    p1       = new PointF(rect.Left, rect.Top + rect.Height - (i * _interval));
                    p2       = new PointF(rect.Left - 5, rect.Top + rect.Height - (i * _interval));
                    cRect    = new RectangleF(rect.Left - 5, rect.Top + rect.Height - (i * _interval), 5, _interval);
                    pictRect = new RectangleF(rect.Left - s.Width - 17, rect.Top + rect.Height - (i * _interval) - 6, 12, 12);
                    e.DrawString(ml.Desc, _font, new SolidBrush(LabelFontColor), rect.Left - s.Width - 5, rect.Top + rect.Height - (i * _interval) - s.Height / 2);
                }
                else
                {
                    p1       = new PointF(rect.Left + rect.Width, rect.Top + rect.Height - (i * _interval));
                    p2       = new PointF(rect.Left + rect.Width + 5, rect.Top + rect.Height - (i * _interval));
                    cRect    = new RectangleF(rect.Left + rect.Width, rect.Top + rect.Height - (i * _interval), 5, _interval);
                    pictRect = new RectangleF(rect.Left + rect.Width + s.Width, rect.Top + rect.Height - (i * _interval) - 6, 12, 12);
                    e.DrawString(ml.Desc, _font, new SolidBrush(LabelFontColor), rect.Left + rect.Width + 5, rect.Top + rect.Height - (i * _interval) - s.Height / 2);
                }
                if (ml.Image != null)
                {
                    e.DrawImage(ml.Image, pictRect, new RectangleF(0, 0, ml.Image.Width, ml.Image.Height), GraphicsUnit.Pixel);
                }
                if (_marking == Marking.BOTH || _marking == Marking.CONT)
                {
                    e.FillRectangle(new SolidBrush(Color.FromArgb(200, ml.MainColor)), cRect);
                }
                if (_marking == Marking.BOTH || _marking == Marking.LINE)
                {
                    e.DrawLine(new Pen(_labelFontColor), p1, p2);
                }
                i++;
            }
            Pen p = new Pen(Color.DarkGray, 2);

            e.FillPath(Brushes.White, rect.GetGraphicsPath());
            e.FillRectangle(new SolidBrush(_indicator), new RectangleF((float)rect.Left,
                                                                       (float)(rect.Top + rect.Height - yIndex),
                                                                       (float)rect.Width, yIndex));
            e.DrawPath(p, rect.GetGraphicsPath());
            e.Restore(state);
        }
Exemplo n.º 8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backgrdColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            if (_backgrdImage != null)
            {
                g.DrawImage(_backgrdImage, rect.ClientRect);
            }
            rect.Shrink(5);
            g.Clip = new Region(rect.GetGraphicsPath());
            int left = 0;

            _panelLength = rect.Width / (_numberOfPanel + 2);
            _panelHeight = rect.Height;
            if (_location == location.FILL)
            {
                _panelLength = rect.Width / (_numberOfPanel) - 1;
                int totalLength = (_numberOfPanel * _panelLength) / 2;
                if (rect.Width / 2 > totalLength)
                {
                    left = rect.Left + (rect.Width / 2 - totalLength);
                }
            }
            else if (_location == location.LEFT)
            {
                left = rect.Left + 3;
            }
            else if (_location == location.CENTER)
            {
                int totalLength = (_numberOfPanel * _panelLength) / 2;
                if (rect.Width / 2 > totalLength)
                {
                    left = rect.Left + (rect.Width / 2 - totalLength);
                }
            }
            else
            {
                left = rect.Left + rect.Width - (_numberOfPanel * _panelLength);
            }
            int i = 0;

            foreach (DigitalPanel dp in _collection)
            {
                dp.Left        = left + i * (_panelLength);
                dp.Top         = rect.Top;
                dp.Width       = _panelLength - 1;
                dp.Height      = _panelHeight;
                dp.MainColor   = _fontColor;
                dp.BackColor   = _panelColor;
                dp.EnableGlare = _enableGlare;
                dp.Draw(g);

                i++;
            }
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }