Beispiel #1
0
 /// <summary>Initializes a new instance of the <see cref="TextStyle" /> class.</summary>
 public TextStyle()
 {
     textColorState    = new ControlColorState();
     textRenderingHint = Settings.DefaultValue.TextRenderingHint;
     textAlignment     = StringAlignment.Center;
     textLineAlignment = StringAlignment.Center;
 }
Beispiel #2
0
 /// <summary>Initializes a new instance of the <see cref="ControlBoxButton" /> class.</summary>
 public ControlBoxButton()
 {
     _backColorState = new ControlColorState();
     _boxType        = ControlBoxType.Default;
     _foreColorState = new ControlColorState();
     _image          = Resources.VisualPlus;
     MouseState      = MouseStates.Normal;
     _offsetLocation = new Point(0, 0);
 }
Beispiel #3
0
        /// <summary>Initializes a new instance of the <see cref="TextStyle" /> class.</summary>
        /// <param name="colorState">The color State.</param>
        public TextStyle(ControlColorState colorState) : this()
        {
            if (colorState.IsEmpty)
            {
                throw new ArgumentNullException(nameof(colorState));
            }

            textColorState = colorState;
        }
Beispiel #4
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 = GraphicsManager.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 = GraphicsManager.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)
            {
                VisualExceptionDialog.Show(exception);
            }
        }
Beispiel #5
0
        /// <summary>Get the control back color state.</summary>
        /// <param name="controlColorState">The control color state.</param>
        /// <param name="enabled">The enabled toggle.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <returns>The <see cref="Color" />.</returns>
        public static Color BackColorState(ControlColorState controlColorState, bool enabled, MouseStates mouseState)
        {
            Color _color;

            if (enabled)
            {
                switch (mouseState)
                {
                case MouseStates.Normal:
                {
                    _color = controlColorState.Enabled;
                    break;
                }

                case MouseStates.Hover:
                {
                    _color = controlColorState.Hover;
                    break;
                }

                case MouseStates.Pressed:
                {
                    _color = controlColorState.Pressed;
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(mouseState), mouseState, null);
                }
                }
            }
            else
            {
                _color = controlColorState.Disabled;
            }

            return(_color);
        }