Пример #1
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            GraphicsPath path;
            Graphics     graphics = pevent.Graphics;

            graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.Clear(base.Parent.BackColor);
            int    x        = this.boxOffset + 9;
            double progress = this.animationManager.GetProgress();
            int    alpha    = base.Enabled ? ((int)(progress * 255.0)) : this.SkinManager.GetCheckBoxOffDisabledColor().A;
            int    num4     = base.Enabled ? ((int)(this.SkinManager.GetCheckboxOffColor().A *(1.0 - progress))) : this.SkinManager.GetCheckBoxOffDisabledColor().A;
            float  width    = (float)(progress * 8.0);
            float  num6     = width / 2f;

            width = (float)(progress * 9.0);
            SolidBrush brush = new SolidBrush(Color.FromArgb(alpha, base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor()));
            Pen        pen   = new Pen(brush.Color);

            if (this.Ripple && this.rippleAnimationManager.IsAnimating())
            {
                for (int i = 0; i < this.rippleAnimationManager.GetAnimationCount(); i++)
                {
                    double     num8   = this.rippleAnimationManager.GetProgress(i);
                    Point      point  = new Point(x, x);
                    SolidBrush brush2 = new SolidBrush(Color.FromArgb((int)(num8 * 40.0), ((bool)this.rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color));
                    int        num9   = ((base.Height % 2) == 0) ? (base.Height - 3) : (base.Height - 2);
                    int        num10  = (this.rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? ((int)(num9 * (0.8 + (0.2 * num8)))) : num9;
                    using (path = DrawHelper.CreateRoundRect((float)(point.X - (num10 / 2)), (float)(point.Y - (num10 / 2)), (float)num10, (float)num10, (float)(num10 / 2)))
                    {
                        graphics.FillPath(brush2, path);
                    }
                    brush2.Dispose();
                }
            }
            Color color = DrawHelper.BlendColor(base.Parent.BackColor, base.Enabled ? this.SkinManager.GetCheckboxOffColor() : this.SkinManager.GetCheckBoxOffDisabledColor(), (double)num4);

            using (path = DrawHelper.CreateRoundRect((float)this.boxOffset, (float)this.boxOffset, 19f, 19f, 9f))
            {
                graphics.FillPath(new SolidBrush(color), path);
                if (base.Enabled)
                {
                    graphics.FillPath(brush, path);
                }
            }
            graphics.FillEllipse(new SolidBrush(base.Parent.BackColor), 2 + this.boxOffset, 2 + this.boxOffset, 15, 15);
            if (base.Checked)
            {
                using (path = DrawHelper.CreateRoundRect(x - num6, x - num6, width, width, 4f))
                {
                    graphics.FillPath(brush, path);
                }
            }
            SizeF ef = graphics.MeasureString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10);

            graphics.DrawString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10, base.Enabled ? this.SkinManager.GetMainTextBrush() : this.SkinManager.GetDisabledOrHintBrush(), (float)(this.boxOffset + 0x16), (base.Height / 2) - (ef.Height / 2f));
            brush.Dispose();
            pen.Dispose();
        }
Пример #2
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;

            g.Clear(Parent.BackColor);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Paint shadow on element to blend with the parent shadow
            DrawHelper.DrawRoundShadow(g, fabBounds);

            // draw fab
            g.FillEllipse(Enabled ? _mouseHover ?
                          new SolidBrush(SkinManager.ColorScheme.AccentColor.Lighten(0.25f)) :
                          SkinManager.ColorScheme.AccentBrush :
                          new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)),
                          fabBounds);

            if (_animationManager.IsAnimating())
            {
                GraphicsPath regionPath = new GraphicsPath();
                regionPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 2));
                Region fabRegion = new Region(regionPath);

                GraphicsContainer gcont = g.BeginContainer();
                g.SetClip(fabRegion, CombineMode.Replace);

                for (int i = 0; i < _animationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = _animationManager.GetProgress(i);
                    var animationSource = _animationManager.GetSource(i);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White));
                    var rippleSize      = (int)(animationValue * Width * 2);
                    g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                }

                g.EndContainer(gcont);
            }

            if (Icon != null)
            {
                g.DrawImage(Icon, new Rectangle(fabBounds.Width / 2 - 11, fabBounds.Height / 2 - 11, 24, 24));
            }

            if (_showAnimationManager.IsAnimating())
            {
                int target = Convert.ToInt32((_mini ? FAB_MINI_SIZE : FAB_SIZE) * _showAnimationManager.GetProgress());
                fabBounds.Width  = target == 0 ? 1 : target;
                fabBounds.Height = target == 0 ? 1 : target;
                fabBounds.X      = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress()));
                fabBounds.Y      = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress()));
            }

            // Clip to a round shape with a 1px padding
            GraphicsPath clipPath = new GraphicsPath();

            clipPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 3));
            Region = new Region(clipPath);
        }
Пример #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var doneProgress = (int)(Width * ((double)Value / Maximum));

            e.Graphics.FillRectangle(Enabled ?
                                     SkinManager.ColorScheme.PrimaryBrush :
                                     new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.PrimaryColor, SkinManager.SwitchOffDisabledThumbColor, 197)),
                                     0, 0, doneProgress, Height);
            e.Graphics.FillRectangle(SkinManager.BackgroundFocusBrush, doneProgress, 0, Width - doneProgress, Height);
        }
Пример #4
0
 protected override void OnCreateControl()
 {
     base.OnCreateControl();
     if (DesignMode)
     {
         BackColorChanged += (sender, args) => BackColor = Parent.BackColor;
         BackColor         = Parent.BackColor;
     }
     else
     {
         BackColorChanged += (sender, args) => BackColor = DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A);
         BackColor         = DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A);
     }
 }
Пример #5
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var G = pevent.Graphics;

            G.SmoothingMode = SmoothingMode.AntiAlias;
            G.Clear(Parent.BackColor);

            var brush  = new SolidBrush(Color.FromArgb(75, Enabled ? Checked ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor() : SkinManager.GetCheckBoxOffDisabledColor()));
            var brush2 = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, Enabled ? Checked ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckboxOffColor() : SkinManager.GetCheckBoxOffDisabledColor()));
            var pen    = new Pen(brush.Color);

            G.FillPath(brush, RoundedRectangle);
            G.DrawPath(pen, RoundedRectangle);

            G.FillEllipse(brush2, PointAnimationNum, 0, 18, 18);
            G.DrawEllipse(pen, PointAnimationNum, 0, 18, 18);
        }
        private void DrawCheckbox(DrawTreeNodeEventArgs e)
        {
            if (CheckBoxes == true)
            {
                Rectangle CheckBoxRect = new Rectangle(e.Node.Bounds.X - e.Node.Bounds.Height, e.Node.Bounds.Y + 2, e.Node.Bounds.Height - 4, e.Node.Bounds.Height - 4);

                var g = e.Graphics;
                g.SmoothingMode = SmoothingMode.AntiAlias;


                using (var checkmarkPath = DrawHelper.CreateRoundRect(CheckBoxRect.X, CheckBoxRect.Y, CheckBoxRect.Width, CheckBoxRect.Height, 1f))
                {
                    SolidBrush brush2 = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.GetCheckboxOffColor() : SkinManager.GetCheckBoxOffDisabledColor(), 255));
                    Pen        pen2   = new Pen(brush2.Color);
                    g.FillPath(brush2, checkmarkPath);
                    g.DrawPath(pen2, checkmarkPath);

                    g.FillRectangle(new SolidBrush(BackColor), CheckBoxRect);
                    g.DrawRectangle(new Pen(BackColor), CheckBoxRect.X + 2, CheckBoxRect.Y + 2, CheckBoxRect.Width - 1, CheckBoxRect.Height - 1);

                    var brush = new SolidBrush(Color.FromArgb((e.Node.Checked) ? 255 : 0, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor()));
                    var pen   = new Pen(brush.Color);

                    brush2.Dispose();
                    pen2.Dispose();

                    if (Enabled)
                    {
                        g.FillPath(brush, checkmarkPath);
                        g.DrawPath(pen, checkmarkPath);
                    }
                    else if (e.Node.Checked)
                    {
                        g.SmoothingMode = SmoothingMode.None;
                        g.FillRectangle(brush, CheckBoxRect.X + 2, CheckBoxRect.Y + 2, CheckBoxRect.Width - 1, CheckBoxRect.Height - 1);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                    }
                    if (e.Node.Checked)
                    {
                        g.DrawImageUnscaledAndClipped(DrawCheckMarkBitmap(CheckBoxRect), CheckBoxRect);
                    }
                }
            }
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            // clear the control
            g.Clear(Parent.BackColor);

            var RADIOBUTTON_CENTER = _boxOffset + RADIOBUTTON_SIZE_HALF;

            var animationProgress = _animationManager.GetProgress();

            int   colorAlpha        = Enabled ? (int)(animationProgress * 255.0) : SkinManager.GetCheckBoxOffDisabledColor().A;
            int   backgroundAlpha   = Enabled ? (int)(SkinManager.GetCheckboxOffColor().A *(1.0 - animationProgress)) : SkinManager.GetCheckBoxOffDisabledColor().A;
            float animationSize     = (float)(animationProgress * 8f);
            float animationSizeHalf = animationSize / 2;

            animationSize = (float)(animationProgress * 9f);

            var brush = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor()));
            var pen   = new Pen(brush.Color);

            // draw ripple animation
            if (Ripple && _rippleAnimationManager.IsAnimating())
            {
                for (var i = 0; i < _rippleAnimationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = _rippleAnimationManager.GetProgress(i);
                    var animationSource = new Point(RADIOBUTTON_CENTER, RADIOBUTTON_CENTER);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), ((bool)_rippleAnimationManager.GetData(i) [0]) ? Color.Black : brush.Color));
                    var rippleHeight    = (Height % 2 == 0) ? Height - 3 : Height - 2;
                    var rippleSize      = (_rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.8d + (0.2d * animationValue))) : rippleHeight;
                    using (var path = DrawHelper.CreateRoundRect(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize, rippleSize / 2)) {
                        g.FillPath(rippleBrush, path);
                    }

                    rippleBrush.Dispose();
                }
            }

            // draw radiobutton circle
            Color uncheckedColor = DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.GetCheckboxOffColor() : SkinManager.GetCheckBoxOffDisabledColor(), backgroundAlpha);

            using (var path = DrawHelper.CreateRoundRect(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE, 9f)) {
                g.FillPath(new SolidBrush(uncheckedColor), path);

                if (Enabled)
                {
                    g.FillPath(brush, path);
                }
            }

            g.FillEllipse(
                new SolidBrush(Parent.BackColor),
                RADIOBUTTON_OUTER_CIRCLE_WIDTH + _boxOffset,
                RADIOBUTTON_OUTER_CIRCLE_WIDTH + _boxOffset,
                RADIOBUTTON_INNER_CIRCLE_SIZE,
                RADIOBUTTON_INNER_CIRCLE_SIZE);

            if (Checked)
            {
                using (var path = DrawHelper.CreateRoundRect(RADIOBUTTON_CENTER - animationSizeHalf, RADIOBUTTON_CENTER - animationSizeHalf, animationSize, animationSize, 4f)) {
                    g.FillPath(brush, path);
                }
            }
            SizeF stringSize = g.MeasureString(Text, SkinManager.ROBOTO_MEDIUM_10);

            g.DrawString(Text, SkinManager.ROBOTO_MEDIUM_10, Enabled ? SkinManager.GetPrimaryTextBrush() : SkinManager.GetDisabledOrHintBrush(), _boxOffset + 22, Height / 2 - stringSize.Height / 2);

            brush.Dispose();
            pen.Dispose();
        }
Пример #8
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            g.Clear(Parent.BackColor);

            var animationProgress = _checkAM.GetProgress();

            // Draw Track
            Color thumbColor = DrawHelper.BlendColor(
                (Enabled ? SkinManager.SwitchOffThumbColor : SkinManager.SwitchOffDisabledThumbColor),                                                                      // Off color
                (Enabled ? SkinManager.ColorScheme.AccentColor : DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)), // On color
                animationProgress * 255);                                                                                                                                   // Blend amount

            using (var path = DrawHelper.CreateRoundRect(new Rectangle(TRACK_CENTER_X_BEGIN - TRACK_RADIUS, TRACK_CENTER_Y - TRACK_SIZE_HEIGHT / 2, TRACK_SIZE_WIDTH, TRACK_SIZE_HEIGHT), TRACK_RADIUS))
            {
                using (SolidBrush trackBrush = new SolidBrush(
                           Color.FromArgb(Enabled ? SkinManager.SwitchOffTrackColor.A : SkinManager.BackgroundDisabledColor.A,   // Track alpha
                                          DrawHelper.BlendColor(                                                                 // animate color
                                              (Enabled ? SkinManager.SwitchOffTrackColor : SkinManager.BackgroundDisabledColor), // Off color
                                              SkinManager.ColorScheme.AccentColor,                                               // On color
                                              animationProgress * 255)                                                           // Blend amount
                                          .RemoveAlpha())))
                {
                    g.FillPath(trackBrush, path);
                }
            }

            // Calculate animation movement X position
            int OffsetX = (int)(TRACK_CENTER_X_DELTA * animationProgress);

            // Ripple
            int rippleSize = (Height % 2 == 0) ? Height - 2 : Height - 3;

            Color rippleColor = Color.FromArgb(40,                                                                                   // color alpha
                                               Checked ? SkinManager.ColorScheme.AccentColor :                                       // On color
                                               (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White)); // Off color

            if (Ripple && _rippleAM.IsAnimating())
            {
                for (int i = 0; i < _rippleAM.GetAnimationCount(); i++)
                {
                    double rippleAnimProgress     = _rippleAM.GetProgress(i);
                    int    rippleAnimatedDiameter = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress))) : rippleSize;

                    using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha())))
                    {
                        g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter));
                    }
                }
            }

            // Hover
            if (Ripple)
            {
                double rippleAnimProgress     = _hoverAM.GetProgress();
                int    rippleAnimatedDiameter = (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress)));

                using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha())))
                {
                    g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter));
                }
            }

            // draw Thumb Shadow
            RectangleF thumbBounds = new RectangleF(TRACK_CENTER_X_BEGIN + OffsetX - THUMB_SIZE_HALF, TRACK_CENTER_Y - THUMB_SIZE_HALF, THUMB_SIZE, THUMB_SIZE);

            using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0)))
            {
                g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 2, thumbBounds.Y - 1, thumbBounds.Width + 4, thumbBounds.Height + 6));
                g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 1, thumbBounds.Y - 1, thumbBounds.Width + 2, thumbBounds.Height + 4));
                g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y - 0, thumbBounds.Width + 0, thumbBounds.Height + 2));
                g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 2, thumbBounds.Width + 0, thumbBounds.Height + 0));
                g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 1, thumbBounds.Width + 0, thumbBounds.Height + 0));
            }

            // draw Thumb
            using (SolidBrush thumbBrush = new SolidBrush(thumbColor))
            {
                g.FillEllipse(thumbBrush, thumbBounds);
            }

            // draw text
            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                Rectangle textLocation = (RightToLeft == RightToLeft.Yes) ? new Rectangle(0, 0, Width - (TEXT_OFFSET + TRACK_SIZE_WIDTH), Height) : new Rectangle(TEXT_OFFSET + TRACK_SIZE_WIDTH, 0, Width - (TEXT_OFFSET + TRACK_SIZE_WIDTH), Height);
                NativeText.DrawTransparentText(
                    Text,
                    SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft),
                    Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                    textLocation.Location,
                    textLocation.Size,
                    NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
            }
        }
Пример #9
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics graphics = pevent.Graphics;

            graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.Clear(base.Parent.BackColor);
            int    num      = this._boxOffset + 9;
            double progress = this._animationManager.GetProgress();
            Color  color;
            int    num2;

            if (!base.Enabled)
            {
                color = this.SkinManager.GetCheckBoxOffDisabledColor();
                num2  = color.A;
            }
            else
            {
                num2 = (int)(progress * 255.0);
            }
            int alpha = num2;
            int num3;

            if (!base.Enabled)
            {
                color = this.SkinManager.GetCheckBoxOffDisabledColor();
                num3  = color.A;
            }
            else
            {
                color = this.SkinManager.GetCheckboxOffColor();
                num3  = (int)((double)(int)color.A * (1.0 - progress));
            }
            int   num4 = num3;
            float num5 = (float)(progress * 8.0);
            float num6 = num5 / 2f;

            num5 = (float)(progress * 9.0);
            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(alpha, base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor()));
            Pen        pen        = new Pen(solidBrush.Color);

            if (this.Ripple && this._rippleAnimationManager.IsAnimating())
            {
                for (int i = 0; i < this._rippleAnimationManager.GetAnimationCount(); i++)
                {
                    double     progress2   = this._rippleAnimationManager.GetProgress(i);
                    Point      point       = new Point(num, num);
                    SolidBrush solidBrush2 = new SolidBrush(Color.FromArgb((int)(progress2 * 40.0), ((bool)this._rippleAnimationManager.GetData(i)[0]) ? Color.Black : solidBrush.Color));
                    int        num7        = (base.Height % 2 == 0) ? (base.Height - 3) : (base.Height - 2);
                    int        num8        = (this._rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? ((int)((double)num7 * (0.8 + 0.2 * progress2))) : num7;
                    using (GraphicsPath path = DrawHelper.CreateRoundRect((float)(point.X - num8 / 2), (float)(point.Y - num8 / 2), (float)num8, (float)num8, (float)(num8 / 2)))
                    {
                        graphics.FillPath(solidBrush2, path);
                    }
                    solidBrush2.Dispose();
                }
            }
            Color color2 = DrawHelper.BlendColor(base.Parent.BackColor, base.Enabled ? this.SkinManager.GetCheckboxOffColor() : this.SkinManager.GetCheckBoxOffDisabledColor(), (double)num4);

            using (GraphicsPath path2 = DrawHelper.CreateRoundRect((float)this._boxOffset, (float)this._boxOffset, 19f, 19f, 9f))
            {
                graphics.FillPath(new SolidBrush(color2), path2);
                if (base.Enabled)
                {
                    graphics.FillPath(solidBrush, path2);
                }
            }
            graphics.FillEllipse(new SolidBrush(base.Parent.BackColor), 2 + this._boxOffset, 2 + this._boxOffset, 15, 15);
            if (base.Checked)
            {
                using (GraphicsPath path3 = DrawHelper.CreateRoundRect((float)num - num6, (float)num - num6, num5, num5, 4f))
                {
                    graphics.FillPath(solidBrush, path3);
                }
            }
            SizeF sizeF = graphics.MeasureString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10);

            graphics.DrawString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10, base.Enabled ? this.SkinManager.GetPrimaryTextBrush() : this.SkinManager.GetDisabledOrHintBrush(), (float)(this._boxOffset + 22), (float)(base.Height / 2) - sizeF.Height / 2f);
            solidBrush.Dispose();
            pen.Dispose();
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);

            var g = pevent.Graphics;

            g.Clear(Parent.BackColor);

            SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A));

            g.FillRectangle(
                !Enabled ? SkinManager.BackgroundDisabledBrush :                    // Disabled
                Focused ? SkinManager.BackgroundFocusBrush :                        // Focused
                MouseState == MouseState.HOVER ? SkinManager.BackgroundHoverBrush : // Hover
                backBrush,                                                          // Normal
                ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y);


            // HintText
            bool  userTextPresent = !String.IsNullOrEmpty(Text);
            Color textColor       = Enabled ? Focused ?
                                    UseAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor : // Focused
                                    SkinManager.TextHighEmphasisColor :                                                      // Inactive
                                    SkinManager.TextDisabledOrHintColor;                                                     // Disabled
            Rectangle hintRect     = new Rectangle(SkinManager.FORM_PADDING, ClientRectangle.Y, Width, LINE_Y);
            int       hintTextSize = 16;

            // bottom line base
            g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1);

            if (!_animationManager.IsAnimating())
            {
                // No animation
                if (hasHint && UseTallSize && (Focused || userTextPresent))
                {
                    // hint text
                    hintRect     = new Rectangle(SkinManager.FORM_PADDING, HINT_TEXT_SMALL_Y, Width, HINT_TEXT_SMALL_SIZE);
                    hintTextSize = 12;
                }

                // bottom line
                if (Focused)
                {
                    g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, 0, LINE_Y, Width, 2);
                }
            }
            else
            {
                // Animate - Focus got/lost
                double animationProgress = _animationManager.GetProgress();

                // hint Animation
                if (hasHint && UseTallSize)
                {
                    hintRect = new Rectangle(
                        SkinManager.FORM_PADDING,
                        userTextPresent ? (HINT_TEXT_SMALL_Y) : ClientRectangle.Y + (int)((HINT_TEXT_SMALL_Y - ClientRectangle.Y) * animationProgress),
                        Width,
                        userTextPresent ? (HINT_TEXT_SMALL_SIZE) : (int)(LINE_Y + (HINT_TEXT_SMALL_SIZE - LINE_Y) * animationProgress));
                    hintTextSize = userTextPresent ? 12 : (int)(16 + (12 - 16) * animationProgress);
                }

                // Line Animation
                int LineAnimationWidth = (int)(Width * animationProgress);
                int LineAnimationX     = (Width / 2) - (LineAnimationWidth / 2);
                g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2);
            }

            // Text stuff:
            string    textToDisplay = Password ? Text.ToSecureString() : Text;
            string    textSelected;
            Rectangle textSelectRect;

            // Calc text Rect
            Rectangle textRect = new Rectangle(
                SkinManager.FORM_PADDING,
                hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y,
                ClientRectangle.Width - SkinManager.FORM_PADDING * 2 + scrollPos.X,
                hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y);

            g.Clip      = new Region(textRect);
            textRect.X -= scrollPos.X;

            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                // Selection rects calc
                string textBeforeSelection = textToDisplay.Substring(0, SelectionStart);
                textSelected = textToDisplay.Substring(SelectionStart, SelectionLength);

                int selectX     = NativeText.MeasureLogString(textBeforeSelection, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width;
                int selectWidth = NativeText.MeasureLogString(textSelected, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width;

                textSelectRect = new Rectangle(
                    textRect.X + selectX, UseTallSize ? hasHint ?
                    textRect.Y + BOTTOM_PADDING : // tall and hint
                    LINE_Y / 3 - BOTTOM_PADDING : // tall and no hint
                    BOTTOM_PADDING,               // not tall
                    selectWidth,
                    UseTallSize ? hasHint ?
                    textRect.Height - BOTTOM_PADDING * 2 : // tall and hint
                    (int)(LINE_Y / 2) :                    // tall and no hint
                    LINE_Y - BOTTOM_PADDING * 2);          // not tall

                // Draw user text
                NativeText.DrawTransparentText(
                    textToDisplay,
                    SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1),
                    Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                    textRect.Location,
                    textRect.Size,
                    NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
            }

            if (Focused)
            {
                // Draw Selection Rectangle
                g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.DarkPrimaryBrush, textSelectRect);

                // Draw Selected Text
                using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
                {
                    NativeText.DrawTransparentText(
                        textSelected,
                        SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1),
                        SkinManager.ColorScheme.TextColor,
                        textSelectRect.Location,
                        textSelectRect.Size,
                        NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
                }
            }

            g.Clip = new Region(ClientRectangle);

            // Draw hint text
            if (hasHint && (UseTallSize || String.IsNullOrEmpty(Text)))
            {
                using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
                {
                    NativeText.DrawTransparentText(
                        Hint,
                        SkinManager.getTextBoxFontBySize(hintTextSize),
                        Enabled ? Focused ? UseAccent ?
                        SkinManager.ColorScheme.AccentColor :  // Focus Accent
                        SkinManager.ColorScheme.PrimaryColor : // Focus Primary
                        SkinManager.TextMediumEmphasisColor :  // not focused
                        SkinManager.TextDisabledOrHintColor,   // Disabled
                        hintRect.Location,
                        hintRect.Size,
                        NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
                }
            }
        }
Пример #11
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            // clear the control
            g.Clear(Parent.BackColor);

            int    CHECKBOX_CENTER   = _boxOffset + CHECKBOX_SIZE_HALF - 1;
            Point  animationSource   = new Point(CHECKBOX_CENTER, CHECKBOX_CENTER);
            double animationProgress = _checkAM.GetProgress();

            int colorAlpha      = Enabled ? (int)(animationProgress * 255.0) : SkinManager.CheckBoxOffDisabledColor.A;
            int backgroundAlpha = Enabled ? (int)(SkinManager.CheckboxOffColor.A * (1.0 - animationProgress)) : SkinManager.CheckBoxOffDisabledColor.A;
            int rippleHeight    = (HEIGHT_RIPPLE % 2 == 0) ? HEIGHT_RIPPLE - 3 : HEIGHT_RIPPLE - 2;

            SolidBrush brush = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.CheckBoxOffDisabledColor));
            Pen        pen   = new Pen(brush.Color, 2);

            // draw hover animation
            if (Ripple)
            {
                double animationValue = _hoverAM.IsAnimating() ? _hoverAM.GetProgress() : hovered ? 1 : 0;
                int    rippleSize     = (int)(rippleHeight * (0.7 + (0.3 * animationValue)));

                using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue),
                                                                              !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : brush.Color))) // no animation
                {
                    g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                }
            }

            // draw ripple animation
            if (Ripple && _rippleAM.IsAnimating())
            {
                for (int i = 0; i < _rippleAM.GetAnimationCount(); i++)
                {
                    double animationValue = _rippleAM.GetProgress(i);
                    int    rippleSize     = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight;

                    using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : brush.Color)))
                    {
                        g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                    }
                }
            }

            Rectangle checkMarkLineFill = new Rectangle(_boxOffset, _boxOffset, (int)(CHECKBOX_SIZE * animationProgress), CHECKBOX_SIZE);

            using (GraphicsPath checkmarkPath = DrawHelper.CreateRoundRect(_boxOffset - 0.5f, _boxOffset - 0.5f, CHECKBOX_SIZE, CHECKBOX_SIZE, 1))
            {
                if (Enabled)
                {
                    using (Pen pen2 = new Pen(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.CheckboxOffColor : SkinManager.CheckBoxOffDisabledColor, backgroundAlpha), 2))
                    {
                        g.DrawPath(pen2, checkmarkPath);
                    }

                    g.DrawPath(pen, checkmarkPath);
                    g.FillPath(brush, checkmarkPath);
                }
                else
                {
                    if (Checked)
                    {
                        g.FillPath(brush, checkmarkPath);
                    }
                    else
                    {
                        g.DrawPath(pen, checkmarkPath);
                    }
                }

                g.DrawImageUnscaledAndClipped(DrawCheckMarkBitmap(), checkMarkLineFill);
            }

            // draw checkbox text
            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                Rectangle textLocation = new Rectangle(_boxOffset + TEXT_OFFSET, 0, Width - (_boxOffset + TEXT_OFFSET), HEIGHT_RIPPLE);
                NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1),
                                               Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                                               textLocation.Location,
                                               textLocation.Size,
                                               NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
            }

            // dispose used paint objects
            pen.Dispose();
            brush.Dispose();
        }
Пример #12
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            // clear the control
            g.Clear(Parent.BackColor);

            int   RADIOBUTTON_CENTER = _boxOffset + RADIOBUTTON_SIZE_HALF;
            Point animationSource    = new Point(RADIOBUTTON_CENTER, RADIOBUTTON_CENTER);

            double animationProgress = _checkAM.GetProgress();

            int   colorAlpha        = Enabled ? (int)(animationProgress * 255.0) : SkinManager.CheckBoxOffDisabledColor.A;
            int   backgroundAlpha   = Enabled ? (int)(SkinManager.CheckboxOffColor.A * (1.0 - animationProgress)) : SkinManager.CheckBoxOffDisabledColor.A;
            float animationSize     = (float)(animationProgress * 9f);
            float animationSizeHalf = animationSize / 2;
            int   rippleHeight      = (HEIGHT_RIPPLE % 2 == 0) ? HEIGHT_RIPPLE - 3 : HEIGHT_RIPPLE - 2;

            Color RadioColor = Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.CheckBoxOffDisabledColor);

            // draw hover animation
            if (Ripple)
            {
                double animationValue = _hoverAM.GetProgress();
                int    rippleSize     = (int)(rippleHeight * (0.7 + (0.3 * animationValue)));

                using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue),
                                                                              !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor)))
                {
                    g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1));
                }
            }

            // draw ripple animation
            if (Ripple && _rippleAM.IsAnimating())
            {
                for (int i = 0; i < _rippleAM.GetAnimationCount(); i++)
                {
                    double animationValue = _rippleAM.GetProgress(i);
                    int    rippleSize     = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight;

                    using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor)))
                    {
                        g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1));
                    }
                }
            }

            // draw radiobutton circle
            using (Pen pen = new Pen(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.CheckboxOffColor : SkinManager.CheckBoxOffDisabledColor, backgroundAlpha), 2))
            {
                g.DrawEllipse(pen, new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE));
            }

            if (Enabled)
            {
                using (Pen pen = new Pen(RadioColor, 2))
                {
                    g.DrawEllipse(pen, new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE));
                }
            }

            if (Checked)
            {
                using (SolidBrush brush = new SolidBrush(RadioColor))
                {
                    g.FillEllipse(brush, new RectangleF(RADIOBUTTON_CENTER - animationSizeHalf, RADIOBUTTON_CENTER - animationSizeHalf, animationSize, animationSize));
                }
            }

            // Text
            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                Rectangle textLocation = new Rectangle(_boxOffset + TEXT_OFFSET, 0, Width, Height);
                NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1),
                                               Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                                               textLocation.Location,
                                               textLocation.Size,
                                               NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(Parent.BackColor);

            // card rectangle path
            RectangleF expansionPanelRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size);

            expansionPanelRectF.X -= 0.5f;
            expansionPanelRectF.Y -= 0.5f;
            GraphicsPath expansionPanelPath = DrawHelper.CreateRoundRect(expansionPanelRectF, 2);

            // button shadow (blend with form shadow)
            DrawHelper.DrawSquareShadow(g, ClientRectangle);

            // Draw expansion panel
            // Disabled
            if (!Enabled)
            {
                using (SolidBrush disabledBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundDisabledColor, SkinManager.BackgroundDisabledColor.A)))
                {
                    g.FillPath(disabledBrush, expansionPanelPath);
                }
            }
            // Mormal
            else
            {
                if ((_buttonState == ButtonState.HeaderOver | _buttonState == ButtonState.ColapseExpandOver) && _collapse)
                {
                    RectangleF expansionPanelBorderRectF = new RectangleF(ClientRectangle.X + 1, ClientRectangle.Y + 1, ClientRectangle.Width - 2, ClientRectangle.Height - 2);
                    expansionPanelBorderRectF.X -= 0.5f;
                    expansionPanelBorderRectF.Y -= 0.5f;
                    GraphicsPath expansionPanelBoarderPath = DrawHelper.CreateRoundRect(expansionPanelBorderRectF, 2);

                    g.FillPath(SkinManager.ExpansionPanelFocusBrush, expansionPanelBoarderPath);
                }
                else
                {
                    using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor))
                    {
                        g.FillPath(normalBrush, expansionPanelPath);
                    }
                }
            }

            // Calc text Rect
            var       RectangleX = (RightToLeft == RightToLeft.Yes) ? Width - (TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding + _leftrightPadding) : _leftrightPadding;
            Rectangle headerRect = new Rectangle(
                RectangleX,
                (_headerHeight - _textHeaderHeight) / 2,
                TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding,
                _textHeaderHeight);

            //Draw  headers
            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                // Draw header text
                var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left;
                NativeText.DrawTransparentText(
                    _titleHeader,
                    SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft),
                    Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                    headerRect.Location,
                    headerRect.Size,
                    textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle);
            }

            if (!String.IsNullOrEmpty(_descriptionHeader))
            {
                //Draw description header text
                RectangleX = (RightToLeft == RightToLeft.Yes) ? _leftrightPadding + _expansionPanelDefaultPadding : headerRect.Right + _expansionPanelDefaultPadding;
                var       RectangleW            = (RightToLeft == RightToLeft.Yes) ? headerRect.Left - _expansionPanelDefaultPadding - _expansionPanelDefaultPadding : _expandcollapseBounds.Left - (headerRect.Right + _expansionPanelDefaultPadding) - _expansionPanelDefaultPadding;
                Rectangle headerDescriptionRect = new Rectangle(
                    RectangleX,
                    (_headerHeight - _textHeaderHeight) / 2,
                    RectangleW,
                    _textHeaderHeight);

                using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
                {
                    // Draw description header text
                    var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left;
                    NativeText.DrawTransparentText(
                        _descriptionHeader,
                        SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft),
                        SkinManager.TextDisabledOrHintColor,
                        headerDescriptionRect.Location,
                        headerDescriptionRect.Size,
                        textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle);
                }
            }

            if (_showCollapseExpand == true)
            {
                using (var formButtonsPen = new Pen(_useAccentColor && Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.TextDisabledOrHintColor, 2))
                {
                    if (_collapse)
                    {
                        //Draw Expand button
                        System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
                        PointF TopLeft   = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 9);
                        PointF MidBottom = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 15);
                        PointF TopRight  = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 9);
                        pth.AddLine(TopLeft, MidBottom);
                        pth.AddLine(TopRight, MidBottom);
                        g.DrawPath(formButtonsPen, pth);
                    }
                    else
                    {
                        // Draw Collapse button
                        System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
                        PointF BottomLeft  = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 15);
                        PointF MidTop      = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 9);
                        PointF BottomRight = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 15);
                        pth.AddLine(BottomLeft, MidTop);
                        pth.AddLine(BottomRight, MidTop);
                        g.DrawPath(formButtonsPen, pth);
                    }
                }
            }

            if (!_collapse && _showValidationButtons)
            {
                //Draw divider
                g.DrawLine(new Pen(SkinManager.DividersColor, 1), new Point(0, Height - _footerHeight), new Point(Width, Height - _footerHeight));
            }
        }
Пример #14
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics graphics = pevent.Graphics;

            graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.Clear(base.Parent.BackColor);
            int        x        = (this.boxOffset + 9) - 1;
            double     progress = this.animationManager.GetProgress();
            int        alpha    = base.Enabled ? ((int)(progress * 255.0)) : this.SkinManager.GetCheckBoxOffDisabledColor().A;
            int        num4     = base.Enabled ? ((int)(this.SkinManager.GetCheckboxOffColor().A *(1.0 - progress))) : this.SkinManager.GetCheckBoxOffDisabledColor().A;
            SolidBrush brush    = new SolidBrush(Color.FromArgb(alpha, base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor()));
            SolidBrush brush2   = new SolidBrush(base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor());
            Pen        pen      = new Pen(brush.Color);

            if (this.Ripple && this.rippleAnimationManager.IsAnimating())
            {
                for (int i = 0; i < this.rippleAnimationManager.GetAnimationCount(); i++)
                {
                    double     num6   = this.rippleAnimationManager.GetProgress(i);
                    Point      point  = new Point(x, x);
                    SolidBrush brush3 = new SolidBrush(Color.FromArgb((int)(num6 * 40.0), ((bool)this.rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color));
                    int        num7   = ((base.Height % 2) == 0) ? (base.Height - 3) : (base.Height - 2);
                    int        num8   = (this.rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? ((int)(num7 * (0.8 + (0.2 * num6)))) : num7;
                    using (GraphicsPath path = DrawHelper.CreateRoundRect((float)(point.X - (num8 / 2)), (float)(point.Y - (num8 / 2)), (float)num8, (float)num8, (float)(num8 / 2)))
                    {
                        graphics.FillPath(brush3, path);
                    }
                    brush3.Dispose();
                }
            }
            brush2.Dispose();
            Rectangle rect = new Rectangle(this.boxOffset, this.boxOffset, (int)(17.0 * progress), 0x11);

            using (GraphicsPath path2 = DrawHelper.CreateRoundRect((float)this.boxOffset, (float)this.boxOffset, 17f, 17f, 1f))
            {
                SolidBrush brush4 = new SolidBrush(DrawHelper.BlendColor(base.Parent.BackColor, base.Enabled ? this.SkinManager.GetCheckboxOffColor() : this.SkinManager.GetCheckBoxOffDisabledColor(), (double)num4));
                Pen        pen2   = new Pen(brush4.Color);
                graphics.FillPath(brush4, path2);
                graphics.DrawPath(pen2, path2);
                graphics.FillRectangle(new SolidBrush(base.Parent.BackColor), this.boxOffset + 2, this.boxOffset + 2, 13, 13);
                graphics.DrawRectangle(new Pen(base.Parent.BackColor), this.boxOffset + 2, this.boxOffset + 2, 13, 13);
                brush4.Dispose();
                pen2.Dispose();
                if (base.Enabled)
                {
                    graphics.FillPath(brush, path2);
                    graphics.DrawPath(pen, path2);
                }
                else if (base.Checked)
                {
                    graphics.SmoothingMode = SmoothingMode.None;
                    graphics.FillRectangle(brush, this.boxOffset + 2, this.boxOffset + 2, 14, 14);
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
                graphics.DrawImageUnscaledAndClipped(this.DrawCheckMarkBitmap(), rect);
            }
            SizeF ef = graphics.MeasureString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10);

            graphics.DrawString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10, base.Enabled ? this.SkinManager.GetMainTextBrush() : this.SkinManager.GetDisabledOrHintBrush(), (float)(this.boxOffset + 0x16), (base.Height / 2) - (ef.Height / 2f));
            pen.Dispose();
            brush.Dispose();
        }
Пример #15
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            var G = pevent.Graphics;

            G.SmoothingMode = SmoothingMode.AntiAlias;

            Color bColor;

            if (Enabled)
            {
                if (animationManager.IsAnimating())
                {
                    if (Checked)
                    {
                        bColor = DrawHelper.BlendColor(SkinManager.GetCheckboxOffColor(), SkinManager.ColorScheme.AccentColor, animationManager.GetProgress() * 255);
                    }
                    else
                    {
                        bColor = DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.GetCheckboxOffColor(), 255 - animationManager.GetProgress() * 255);
                    }
                }
                else
                {
                    if (Checked)
                    {
                        bColor = SkinManager.ColorScheme.AccentColor;
                    }
                    else
                    {
                        bColor = SkinManager.GetCheckboxOffColor();
                    }
                }
            }
            else
            {
                bColor = SkinManager.GetCheckBoxOffDisabledColor();
            }
            Color aColor;

            if (Enabled)
            {
                if (animationManager.IsAnimating())
                {
                    if (Checked)
                    {
                        aColor = DrawHelper.BlendColor(SkinManager.ColorScheme.LightPrimaryColor, SkinManager.ColorScheme.PrimaryColor, animationManager.GetProgress() * 255);
                    }
                    else
                    {
                        aColor = DrawHelper.BlendColor(SkinManager.ColorScheme.PrimaryColor, SkinManager.ColorScheme.LightPrimaryColor, 255 - animationManager.GetProgress() * 255);
                    }
                }
                else
                {
                    if (Checked)
                    {
                        aColor = SkinManager.ColorScheme.PrimaryColor;
                    }
                    else
                    {
                        aColor = SkinManager.ColorScheme.LightPrimaryColor;
                    }
                }
            }
            else
            {
                aColor = SkinManager.GetCheckBoxOffDisabledColor();
            }

            G.FillPath(new SolidBrush(Color.FromArgb(115, bColor)), RoundedRectangle);
            G.DrawPath(new Pen(Color.FromArgb(50, bColor)), RoundedRectangle);


            // draw ripple animation
            if (Ripple && rippleAnimationManager.IsAnimating())
            {
                for (int i = 0; i < rippleAnimationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = rippleAnimationManager.GetProgress(i);
                    int colorAlpha      = Enabled ? (int)(animationValue * 255.0) : SkinManager.GetCheckBoxOffDisabledColor().A;
                    var brush           = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor()));
                    var animationSource = new Point((int)(23f + 20f * (float)animationManager.GetProgress()), Height / 2);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), ((bool)rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color));
                    var rippleHeight    = (Height % 2 == 0) ? Height - 3 : Height - 2;
                    var rippleSize      = (rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.8d + (0.2d * animationValue))) : rippleHeight;
                    using (var path = DrawHelper.CreateRoundRect(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize, rippleSize / 2))
                    {
                        G.FillPath(rippleBrush, path);
                    }

                    rippleBrush.Dispose();
                }
            }

            G.FillEllipse(new SolidBrush(aColor), 14f + 20f * (float)animationManager.GetProgress(), Height / 2 - 9, 18, 18);
            G.DrawEllipse(new Pen(aColor), 14f + 20f * (float)animationManager.GetProgress(), Height / 2 - 9, 18, 18);
            this.DrawChildShadow(G);
        }
Пример #16
0
        /// <summary>
        /// The OnPaint
        /// </summary>
        /// <param name="pevent">The pevent<see cref="PaintEventArgs"/></param>
        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            // clear the control
            g.Clear(Parent.BackColor);

            var CHECKBOX_CENTER = _boxOffset + CHECKBOX_SIZE_HALF - 1;

            var animationProgress = _animationManager.GetProgress();

            var colorAlpha      = Enabled ? (int)(animationProgress * 255.0) : SkinManager.GetCheckBoxOffDisabledColor().A;
            var backgroundAlpha = Enabled ? (int)(SkinManager.GetCheckboxOffColor().A *(1.0 - animationProgress)) : SkinManager.GetCheckBoxOffDisabledColor().A;

            var brush  = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor()));
            var brush3 = new SolidBrush(Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor());
            var pen    = new Pen(brush.Color);

            // draw ripple animation
            if (Ripple && _rippleAnimationManager.IsAnimating())
            {
                for (var i = 0; i < _rippleAnimationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = _rippleAnimationManager.GetProgress(i);
                    var animationSource = new Point(CHECKBOX_CENTER, CHECKBOX_CENTER);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), ((bool)_rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color));
                    var rippleHeight    = (Height % 2 == 0) ? Height - 3 : Height - 2;
                    var rippleSize      = (_rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.8d + (0.2d * animationValue))) : rippleHeight;
                    using (var path = DrawHelper.CreateRoundRect(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize, rippleSize / 2))
                    {
                        g.FillPath(rippleBrush, path);
                    }

                    rippleBrush.Dispose();
                }
            }

            brush3.Dispose();

            var checkMarkLineFill = new Rectangle(_boxOffset, _boxOffset, (int)(17.0 * animationProgress), 17);

            using (var checkmarkPath = DrawHelper.CreateRoundRect(_boxOffset, _boxOffset, 17, 17, 1f))
            {
                var brush2 = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.GetCheckboxOffColor() : SkinManager.GetCheckBoxOffDisabledColor(), backgroundAlpha));
                var pen2   = new Pen(brush2.Color);
                g.FillPath(brush2, checkmarkPath);
                g.DrawPath(pen2, checkmarkPath);

                g.FillRectangle(new SolidBrush(Parent.BackColor), _boxOffset + 2, _boxOffset + 2, CHECKBOX_INNER_BOX_SIZE - 1, CHECKBOX_INNER_BOX_SIZE - 1);
                g.DrawRectangle(new Pen(Parent.BackColor), _boxOffset + 2, _boxOffset + 2, CHECKBOX_INNER_BOX_SIZE - 1, CHECKBOX_INNER_BOX_SIZE - 1);

                brush2.Dispose();
                pen2.Dispose();

                if (Enabled)
                {
                    g.FillPath(brush, checkmarkPath);
                    g.DrawPath(pen, checkmarkPath);
                }
                else if (Checked)
                {
                    g.SmoothingMode = SmoothingMode.None;
                    g.FillRectangle(brush, _boxOffset + 2, _boxOffset + 2, CHECKBOX_INNER_BOX_SIZE, CHECKBOX_INNER_BOX_SIZE);
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                }

                g.DrawImageUnscaledAndClipped(DrawCheckMarkBitmap(), checkMarkLineFill);
            }

            // draw checkbox text
            SizeF stringSize = g.MeasureString(Text, SkinManager.TEXT_FONT);

            g.DrawString(
                Text,
                SkinManager.TEXT_FONT,
                Enabled ? SkinManager.GetPrimaryTextBrush() : SkinManager.GetDisabledOrHintBrush(),
                _boxOffset + TEXT_OFFSET, Height / 2 - stringSize.Height / 2);

            // dispose used paint objects
            pen.Dispose();
            brush.Dispose();
        }
Пример #17
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics graphics = pevent.Graphics;

            graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.Clear(base.Parent.BackColor);
            int    num      = this._boxOffset + 9 - 1;
            double progress = this._animationManager.GetProgress();
            Color  color;
            int    num2;

            if (!base.Enabled)
            {
                color = this.SkinManager.GetCheckBoxOffDisabledColor();
                num2  = color.A;
            }
            else
            {
                num2 = (int)(progress * 255.0);
            }
            int alpha = num2;
            int num3;

            if (!base.Enabled)
            {
                color = this.SkinManager.GetCheckBoxOffDisabledColor();
                num3  = color.A;
            }
            else
            {
                color = this.SkinManager.GetCheckboxOffColor();
                num3  = (int)((double)(int)color.A * (1.0 - progress));
            }
            int        num4        = num3;
            SolidBrush solidBrush  = new SolidBrush(Color.FromArgb(alpha, base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor()));
            SolidBrush solidBrush2 = new SolidBrush(base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor());
            Pen        pen         = new Pen(solidBrush.Color);

            if (this.Ripple && this._rippleAnimationManager.IsAnimating())
            {
                for (int i = 0; i < this._rippleAnimationManager.GetAnimationCount(); i++)
                {
                    double     progress2   = this._rippleAnimationManager.GetProgress(i);
                    Point      point       = new Point(num, num);
                    SolidBrush solidBrush3 = new SolidBrush(Color.FromArgb((int)(progress2 * 40.0), ((bool)this._rippleAnimationManager.GetData(i)[0]) ? Color.Black : solidBrush.Color));
                    int        num5        = (base.Height % 2 == 0) ? (base.Height - 3) : (base.Height - 2);
                    int        num6        = (this._rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? ((int)((double)num5 * (0.8 + 0.2 * progress2))) : num5;
                    using (GraphicsPath path = DrawHelper.CreateRoundRect((float)(point.X - num6 / 2), (float)(point.Y - num6 / 2), (float)num6, (float)num6, (float)(num6 / 2)))
                    {
                        graphics.FillPath(solidBrush3, path);
                    }
                    solidBrush3.Dispose();
                }
            }
            solidBrush2.Dispose();
            Rectangle rect = new Rectangle(this._boxOffset, this._boxOffset, (int)(17.0 * progress), 17);

            using (GraphicsPath path2 = DrawHelper.CreateRoundRect((float)this._boxOffset, (float)this._boxOffset, 17f, 17f, 1f))
            {
                SolidBrush solidBrush4 = new SolidBrush(DrawHelper.BlendColor(base.Parent.BackColor, base.Enabled ? this.SkinManager.GetCheckboxOffColor() : this.SkinManager.GetCheckBoxOffDisabledColor(), (double)num4));
                Pen        pen2        = new Pen(solidBrush4.Color);
                graphics.FillPath(solidBrush4, path2);
                graphics.DrawPath(pen2, path2);
                graphics.FillRectangle(new SolidBrush(base.Parent.BackColor), this._boxOffset + 2, this._boxOffset + 2, 13, 13);
                graphics.DrawRectangle(new Pen(base.Parent.BackColor), this._boxOffset + 2, this._boxOffset + 2, 13, 13);
                solidBrush4.Dispose();
                pen2.Dispose();
                if (base.Enabled)
                {
                    graphics.FillPath(solidBrush, path2);
                    graphics.DrawPath(pen, path2);
                }
                else if (base.Checked)
                {
                    graphics.SmoothingMode = SmoothingMode.None;
                    graphics.FillRectangle(solidBrush, this._boxOffset + 2, this._boxOffset + 2, 14, 14);
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
                graphics.DrawImageUnscaledAndClipped(this.DrawCheckMarkBitmap(), rect);
            }
            SizeF sizeF = graphics.MeasureString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10);

            graphics.DrawString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10, base.Enabled ? this.SkinManager.GetPrimaryTextBrush() : this.SkinManager.GetDisabledOrHintBrush(), (float)(this._boxOffset + 22), (float)(base.Height / 2) - sizeF.Height / 2f);
            pen.Dispose();
            solidBrush.Dispose();
        }