Esempio n. 1
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                backColorState = new ControlColorState
                {
                    Disabled = theme.ColorPalette.ControlDisabled,
                    Enabled  = theme.ColorPalette.ControlEnabled,
                    Hover    = theme.ColorPalette.ItemHover,
                    Pressed  = theme.ColorPalette.Pressed
                };

                TextStyle.Enabled  = theme.ColorPalette.TextEnabled;
                TextStyle.Disabled = theme.ColorPalette.TextDisabled;
                TextStyle.Hover    = theme.ColorPalette.TextHover;
                TextStyle.Pressed  = theme.ColorPalette.TextPressed;
            }
            catch (Exception e)
            {
                ConsoleEx.WriteDebug(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Esempio n. 2
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _buttonColorState = new ControlColorState();
                _backColorState   = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type4,
                    Disabled = theme.BackgroundSettings.Type2
                };

                _borderButton.BackColor = theme.OtherSettings.Line;
                _borderImage.BackColor  = theme.OtherSettings.Line;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        /// <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);
        }
Esempio n. 4
0
        /// <summary>Initializes a new instance of the <see cref="VisualToggle" /> class.</summary>
        public VisualToggle()
        {
            Size = new Size(50, 25);
            Font = StyleManager.Font;

            _animationTimer = new Timer
            {
                Interval = 1
            };

            _animationTimer.Tick += AnimationTimerTick;
            _controlColorState    = new ColorState();
            _buttonColorState     = new ControlColorState();
            _toggleType           = ToggleTypes.YesNo;
            _buttonSize           = new Size(20, 20);

            _border = new Border
            {
                Rounding = Settings.DefaultValue.Rounding.ToggleBorder
            };

            _buttonBorder = new Border
            {
                Rounding = Settings.DefaultValue.Rounding.ToggleButton
            };

            UpdateTheme(Settings.DefaultValue.DefaultStyle);
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.ColorPalette.BorderNormal;
                _border.HoverColor = theme.ColorPalette.BorderHover;

                ForeColor          = theme.ColorPalette.TextEnabled;
                TextStyle.Enabled  = theme.ColorPalette.TextEnabled;
                TextStyle.Disabled = theme.ColorPalette.TextDisabled;

                _buttonColorState = new ControlColorState {
                    Disabled = theme.ColorPalette.Disabled, Enabled = theme.ColorPalette.Enabled, Hover = theme.ColorPalette.Hover, Pressed = theme.ColorPalette.Pressed
                };

                _backColorState = new ColorState {
                    Enabled = theme.ColorPalette.ControlEnabled, Disabled = theme.ColorPalette.ControlDisabled
                };

                _borderButton.BackColor = theme.ColorPalette.BorderNormal;
                _borderImage.BackColor  = theme.ColorPalette.BorderNormal;
            }
            catch (Exception e)
            {
                ConsoleEx.WriteDebug(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        public void UpdateTheme(Theme theme)
        {
            try
            {
                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font             = theme.TextSetting.Font; // TODO: 16F - Bold
                _subscriptFont   = theme.TextSetting.Font; // TODO: - Bold
                _superscriptFont = theme.TextSetting.Font; // TODO: - Bold

                _superscriptColor = theme.TextSetting.SuperscriptColor;
                _subscriptColor   = theme.TextSetting.SubscriptColor;

                _colorState = new ControlColorState
                {
                    Enabled  = theme.BackgroundSettings.Type1,
                    Disabled = theme.BackgroundSettings.Type1
                };

                _backCircleColor = theme.OtherSettings.BackCircle;
                _foreCircleColor = theme.OtherSettings.ForeCircle;
                _progressColor   = theme.OtherSettings.Progress;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Esempio n. 8
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.ColorPalette.BorderNormal;
                _border.HoverColor = theme.ColorPalette.BorderHover;

                _buttonBorder.Color      = theme.ColorPalette.BorderNormal;
                _buttonBorder.HoverColor = theme.ColorPalette.BorderHover;

                ForeColor          = theme.ColorPalette.TextEnabled;
                TextStyle.Enabled  = theme.ColorPalette.TextEnabled;
                TextStyle.Disabled = theme.ColorPalette.TextDisabled;

                // Font = theme.ColorPalette.Font;
                _controlColorState = new ColorState {
                    Enabled = theme.ColorPalette.ControlEnabled, Disabled = theme.ColorPalette.ControlDisabled
                };

                _buttonColorState = new ControlColorState {
                    Enabled = theme.ColorPalette.Enabled, Disabled = theme.ColorPalette.Disabled, Hover = theme.ColorPalette.Hover, Pressed = theme.ColorPalette.Pressed
                };
            }
            catch (Exception e)
            {
                Logger.WriteDebug(e);
            }

            Invalidate();
            OnThemeChanged(this, new ThemeEventArgs(theme));
        }
 /// <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);
 }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
 /// <summary>Initializes a new instance of the <see cref="ToggleCheckmarkBase" /> class.</summary>
 protected ToggleCheckmarkBase()
 {
     _boxSpacing = 2;
     _box        = new Rectangle(0, 0, 14, 14);
     _animation  = Settings.DefaultValue.Animation;
     _checkStyle = new CheckStyle(ClientRectangle);
     _border     = new Border();
     _colorState = new ControlColorState();
     ConfigureAnimation(new[] { 0.05, 0.10, 0.08 }, new[] { EffectType.EaseInOut, EffectType.Linear });
 }
Esempio n. 12
0
        /// <summary>Initializes a new instance of the <see cref="VisualButton" /> class.</summary>
        public VisualButton()
        {
            Size               = new Size(140, 45);
            _border            = new Border();
            _backColorState    = new ControlColorState();
            _animation         = Settings.DefaultValue.Animation;
            _textImageRelation = TextImageRelation.Overlay;
            ConfigureAnimation(new[] { 0.03, 0.07 }, new[] { EffectType.EaseOut, EffectType.EaseInOut });

            UpdateTheme(ThemeManager.Theme);
        }
Esempio n. 13
0
        /// <summary>Initializes a new instance of the <see cref="VisualButton" /> class.</summary>
        public VisualButton()
        {
            Size               = new Size(140, 45);
            _animation         = DefaultConstants.Animation;
            _border            = new Border();
            _backColorState    = new ControlColorState();
            dialogResult       = DialogResult.None;
            _textImageRelation = TextImageRelation.Overlay;
            ConfigureAnimation(new[] { 0.03, 0.07 }, new[] { EffectType.EaseOut, EffectType.EaseInOut });

            UpdateTheme(ThemeManager.Theme);
        }
Esempio n. 14
0
        /// <summary>Initializes a new instance of the <see cref="VisualTile" /> class.</summary>
        public VisualTile()
        {
            Size = new Size(110, 80);

            backgroundLayout = BackgroundLayout.Stretch;
            backColorState   = new ControlColorState();
            type             = TileType.Text;
            image            = Resources.VisualPlus;
            MouseState       = MouseStates.Normal;
            offset           = new Point(0, 0);

            UpdateTheme(ThemeManager.Theme);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        /// <summary>Initializes a new instance of the <see cref="VisualStyleBase" /> class.</summary>
        private void InitializeComponent()
        {
            DoubleBuffered = true;
            ResizeRedraw   = true;

            _mouseState   = MouseStates.Normal;
            _themeManager = new StyleManager(DefaultConstants.DefaultStyle);

            Theme theme = new Theme(DefaultConstants.DefaultStyle);

            ControlColorState controlState = new ControlColorState {
                Disabled = theme.ColorPalette.TextDisabled, Enabled = theme.ColorPalette.TextEnabled, Hover = theme.ColorPalette.TextHover, Pressed = theme.ColorPalette.TextPressed
            };

            _textStyle = new TextStyle(controlState);
        }
Esempio n. 17
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:VisualPlus.Toolkit.Controls.Interactivity.VisualButton" />
        ///     class.
        /// </summary>
        public VisualButton()
        {
            Size               = new Size(140, 45);
            _animation         = Settings.DefaultValue.Animation;
            _border            = new Border();
            _textImageRelation = TextImageRelation.Overlay;
            _backColorState    = new ControlColorState();
            _visualBitmap      = new VisualBitmap(Resources.VisualPlus, new Size(24, 24))
            {
                Visible = false,
                Image   = Resources.VisualPlus
            };
            _visualBitmap.Point = new Point(0, (Height / 2) - (_visualBitmap.Size.Height / 2));

            ConfigureAnimation(new[] { 0.03, 0.07 }, new[] { EffectType.EaseOut, EffectType.EaseInOut });
            UpdateTheme(Settings.DefaultValue.DefaultStyle);
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        /// <inheritdoc />
        /// <summary>Initializes a new instance of the <see cref="VisualRadialProgress" /> class.</summary>
        public VisualRadialProgress()
        {
            _backCircleVisible = true;
            _foreCircleVisible = true;
            _colorState        = new ControlColorState();
            _imageSize         = new Size(16, 16);
            _lineCap           = LineCap.Round;
            _progressSize      = 5F;

            _superscriptLocation = new Point(70, 35);
            _subscriptLocation   = new Point(70, 50);
            _superscriptText     = "°C";
            _subscriptText       = ".25";

            Size        = new Size(100, 100);
            MinimumSize = Size;
            Maximum     = 100;

            UpdateTheme(Settings.DefaultValue.DefaultStyle);
        }
Esempio n. 21
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();
        }
Esempio n. 22
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                _buttonBorder.Color      = theme.BorderSettings.Normal;
                _buttonBorder.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _controlColorState = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type2,
                    Disabled = theme.BackgroundSettings.Type1
                };

                _buttonColorState = new ControlColorState
                {
                    Enabled  = theme.ColorStateSettings.Enabled,
                    Disabled = theme.ColorStateSettings.Disabled,
                    Hover    = theme.ColorStateSettings.Hover,
                    Pressed  = theme.ColorStateSettings.Pressed
                };
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Esempio n. 23
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);
            }
        }
Esempio n. 24
0
        /// <summary>Initializes a new instance of the <see cref="VisualTextBox" /> class.</summary>
        public VisualTextBox()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);

            // Contains another control
            SetStyle(ControlStyles.ContainerControl, true);

            // Cannot select this control, only the child and does not generate a click event
            SetStyle(ControlStyles.Selectable | ControlStyles.StandardClick, false);

            _borderButton = new BorderEdge {
                Visible = false
            };

            _borderImage = new BorderEdge {
                Visible = false
            };

            _backColorState   = new ColorState();
            _buttonColorState = new ControlColorState();

            _textWidth = 125;
            _border    = new Border();
            _textBox   = new TextBox
            {
                Size        = new Size(_textWidth, 25),
                Location    = new Point(VisualBorderRenderer.CalculateBorderCurve(_border), VisualBorderRenderer.CalculateBorderCurve(_border)),
                Text        = string.Empty,
                BorderStyle = BorderStyle.None,
                TextAlign   = HorizontalAlignment.Left,
                Font        = Font,
                ForeColor   = ForeColor,
                BackColor   = _backColorState.Enabled,
                Multiline   = false
            };

            _imageWidth   = 35;
            _buttonFont   = Font;
            _buttonIndent = 3;
            _buttontext   = "visualButton";

            _image = null;

            _watermark    = new Watermark();
            _buttonBorder = new Border();

            AutoSize = true;
            Size     = new Size(135, 25);

            _textBox.KeyDown     += TextBox_KeyDown;
            _textBox.Leave       += OnLeave;
            _textBox.Enter       += OnEnter;
            _textBox.GotFocus    += OnEnter;
            _textBox.LostFocus   += OnLeave;
            _textBox.MouseLeave  += OnLeave;
            _textBox.TextChanged += TextBox_TextChanged;
            _textBox.SizeChanged += TextBox_SizeChanged;

            Controls.Add(_textBox);
            Controls.Add(_borderButton);
            Controls.Add(_borderImage);

            _waterMarkContainer = null;

            if (_watermark.Visible)
            {
                DrawWaterMark();
            }

            UpdateTheme(Settings.DefaultValue.DefaultStyle);
        }