Exemplo n.º 1
0
        /// <summary>Draws an arrow button.</summary>
        /// <param name="graphics">The <see cref="Graphics" /> used to paint.</param>
        /// <param name="arrowUp">true for an up arrow, false otherwise.</param>
        /// <param name="border">The border.</param>
        /// <param name="color">The color.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="orientation">The <see cref="Orientation" />.</param>
        /// <param name="rectangle">The rectangle in which to paint.</param>
        /// <param name="state">The <see cref="MouseStates" /> of the arrow button.</param>
        public static void DrawArrowButton(Graphics graphics, bool arrowUp, Border border, ControlColorState color, bool enabled, Orientation orientation, Rectangle rectangle, MouseStates state)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (rectangle.IsEmpty || graphics.IsVisibleClipEmpty || !graphics.VisibleClipBounds.IntersectsWith(rectangle))
            {
                return;
            }

            Color _thumbBackColor = ControlColorState.BackColorState(color, enabled, state);

            VisualBackgroundRenderer.DrawBackground(graphics, _thumbBackColor, state, rectangle, border);

            GraphicsPath _buttonGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _buttonGraphicsPath, state);

            Image _arrowImage = RetrieveButtonArrowImage(enabled);

            _arrowImage = RotateImageByOrientation(_arrowImage, orientation, arrowUp);
            graphics.DrawImage(_arrowImage, rectangle);
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics _graphics = e.Graphics;

            _graphics.SmoothingMode     = SmoothingMode.HighQuality;
            _graphics.TextRenderingHint = TextStyle.TextRenderingHint;
            Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);

            ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);
            Color _backColor = Enabled ? _controlColorState.Enabled : _controlColorState.Disabled;

            _graphics.SetClip(ControlGraphicsPath);

            VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, Border);

            // Determines button/toggle state
            Point _startPoint     = new Point(0 + 2, (_clientRectangle.Height / 2) - (_buttonSize.Height / 2));
            Point _endPoint       = new Point(_clientRectangle.Width - _buttonSize.Width - 2, (_clientRectangle.Height / 2) - (_buttonSize.Height / 2));
            Point _buttonLocation = Toggle ? _endPoint : _startPoint;

            _buttonRectangle = new Rectangle(_buttonLocation, _buttonSize);
            DrawToggleText(_graphics);

            Color _buttonColor = ControlColorState.BackColorState(ButtonColorState, Enabled, MouseState);

            VisualBackgroundRenderer.DrawBackground(e.Graphics, _buttonColor, _buttonRectangle, _buttonBorder);

            VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);
            _graphics.ResetClip();
        }
Exemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics _graphics = e.Graphics;

            _graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            try
            {
                Size _stringSize;

                Color _backColor = ControlColorState.BackColorState(_backColorState, Enabled, MouseState);
                Color _foreColor = ControlColorState.BackColorState(_foreColorState, Enabled, MouseState);

                _graphics.FillRectangle(new SolidBrush(_backColor), ClientRectangle);

                switch (_boxType)
                {
                case ControlBoxType.Default:
                {
                    Font _specialFont = new Font("Marlett", 12);
                    _stringSize = TextManager.MeasureText(Text, _specialFont, _graphics);
                    Point _location = new Point(((Width / 2) - (_stringSize.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_stringSize.Height / 2)) + _offsetLocation.Y);

                    _graphics.DrawString(Text, _specialFont, new SolidBrush(_foreColor), _location);
                    break;
                }

                case ControlBoxType.Image:
                {
                    Point _location = new Point(((Width / 2) - (_image.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_image.Height / 2)) + _offsetLocation.Y);
                    _graphics.DrawImage(_image, _location);
                    break;
                }

                case ControlBoxType.Text:
                {
                    _stringSize = TextManager.MeasureText(Text, Font, _graphics);
                    Point _location = new Point(((Width / 2) - (_stringSize.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_stringSize.Height / 2)) + _offsetLocation.Y);

                    _graphics.DrawString(Text, Font, new SolidBrush(_foreColor), _location);
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(_boxType), _boxType, null);
                }
                }
            }
            catch (Exception exception)
            {
                ConsoleEx.WriteDebug(exception);
            }
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                Color backColor = ControlColorState.BackColorState(backColorState, Enabled, MouseState);

                VisualBackgroundRenderer.RenderBackground(e.Graphics, backColor, BackgroundImage, backgroundLayout, ClientRectangle);
                VisualTileRenderer.RenderTile(e.Graphics, type, ClientRectangle, Image, Text, Font, Enabled, MouseState, TextStyle, offset);
            }
            catch (Exception exception)
            {
                Logger.WriteDebug(exception);
            }

            base.OnPaint(e);
        }
Exemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                Graphics _graphics = e.Graphics;
                _graphics.Clear(Parent.BackColor);
                _graphics.SmoothingMode     = SmoothingMode.HighQuality;
                _graphics.TextRenderingHint = TextStyle.TextRenderingHint;
                Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
                ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);
                _graphics.FillRectangle(new SolidBrush(BackColor), new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 1, ClientRectangle.Height + 1));

                Color _backColor = ControlColorState.BackColorState(BackColorState, Enabled, MouseState);

                e.Graphics.SetClip(ControlGraphicsPath);
                VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, _border);

                Color _textColor = Enabled ? ForeColor : TextStyle.Disabled;

                if (_image != null)
                {
                    VisualControlRenderer.DrawContent(e.Graphics, ClientRectangle, Text, Font, _textColor, _image, _image.Size, _textImageRelation);
                }
                else
                {
                    StringFormat _stringFormat = new StringFormat
                    {
                        Alignment     = _textAlignment,
                        LineAlignment = _textLineAlignment
                    };

                    VisualControlRenderer.DrawContentText(e.Graphics, ClientRectangle, Text, Font, _textColor, _stringFormat);
                }

                VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);
                DrawAnimation(e.Graphics);
                e.Graphics.ResetClip();
            }
            catch (Exception exception)
            {
                VisualExceptionDialog.Show(exception);
            }
        }
Exemplo n.º 6
0
        /// <summary>Draws the control background, with a BackColor and the specified BackgroundImage.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="image">The background image to use for the background.</param>
        /// <param name="border">The shape settings.</param>
        /// <param name="color">The color.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawElement(Graphics graphics, Image image, Border border, ControlColorState color, bool enabled, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath _elementGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            graphics.SetClip(_elementGraphicsPath);
            Color _colorState = ControlColorState.BackColorState(color, enabled, mouseState);

            graphics.FillRectangle(new SolidBrush(_colorState), rectangle);
            graphics.ResetClip();

            if (image != null)
            {
                graphics.SetClip(_elementGraphicsPath);
                graphics.DrawImage(image, rectangle);
                graphics.ResetClip();
            }

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _elementGraphicsPath, mouseState);
        }
Exemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (AutoSize)
            {
                _box = new Rectangle(new Point(Padding.Left, (ClientRectangle.Height / 2) - (_box.Height / 2)), _box.Size);
                AutoFit(Text.MeasureText(Font));
            }
            else
            {
                _box = new Rectangle(new Point(Padding.Left, (ClientRectangle.Height / 2) - (_box.Height / 2)), _box.Size);
            }

            Color _backColor = ControlColorState.BackColorState(BoxColorState, Enabled, MouseState);

            Graphics _graphics = e.Graphics;

            _graphics.Clear(Parent.BackColor);
            _graphics.SmoothingMode     = SmoothingMode.HighQuality;
            _graphics.TextRenderingHint = TextStyle.TextRenderingHint;

            Rectangle _clientRectangle = new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 2, ClientRectangle.Height + 2);
            Shape     _clientShape     = new Shape(ShapeTypes.Rectangle, _backColor, 0);

            GraphicsPath _clientPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _clientShape);

            ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);

            e.Graphics.SetClip(_clientPath);

            _graphics.FillRectangle(new SolidBrush(BackColor), _clientRectangle);

            _textSize = TextManager.MeasureText(Text, Font, _graphics);
            Point _textLocation = new Point(_box.Right + _boxSpacing, (ClientRectangle.Height / 2) - (_textSize.Height / 2));
            Color _textColor    = Enabled ? ForeColor : TextStyle.Disabled;

            VisualToggleRenderer.DrawCheckBox(_graphics, Border, _checkStyle, _box, Checked, Enabled, _backColor, BackgroundImage, MouseState, Text, Font, _textColor, _textLocation);
            DrawAnimation(_graphics);
            e.Graphics.ResetClip();
        }
Exemplo n.º 8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                Graphics _graphics = e.Graphics;

                _graphics.SmoothingMode     = SmoothingMode.HighQuality;
                _graphics.TextRenderingHint = TextStyle.TextRenderingHint;
                Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
                ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);

                Color _backColor = ControlColorState.BackColorState(BackColorState, Enabled, MouseState);

                e.Graphics.SetClip(ControlGraphicsPath);
                VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, _border);

                if (_image != null)
                {
                    Color _textColor = Enabled ? ForeColor : TextStyle.Disabled;
                    VisualControlRenderer.DrawContent(e.Graphics, ClientRectangle, Text, Font, _textColor, _image, _image.Size, _textImageRelation);
                }
                else
                {
                    VisualTextRenderer.RenderText(e.Graphics, ClientRectangle, Text, Font, Enabled, MouseState, TextStyle);
                }

                VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);
                DrawAnimation(e.Graphics);
                e.Graphics.ResetClip();
            }
            catch (Exception exception)
            {
                Logger.WriteDebug(exception);
            }
        }