Example #1
0
        /// <summary>
        /// Draw label
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base call
            base.OnPaint(e);

            // Get graphics variable
            Graphics g = e.Graphics;

            // Normal and alternate color
            Color standardTextColor  = Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor();
            Color alternateTextColor = (Component.SourceTheme.DARK_BASED) ? ColorExtensions.AddRGB(-120, Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor()) : ColorExtensions.AddRGB(100, Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor());
            Color accentTextColor    = Component.Accent;

            // Set foreground color
            switch (_type)
            {
            case LabelType.Standard:
                ForeColor = standardTextColor;
                break;

            case LabelType.Alternate:
                ForeColor = alternateTextColor;
                break;

            case LabelType.Accent:
                ForeColor = accentTextColor;
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Draw item
        /// </summary>
        protected override void OnDrawItem(Graphics g, Rectangle bounds)
        {
            // Base call
            base.OnDrawItem(g, bounds);

            // Default height
            Height = DIP.Set(70);

            // String format
            // Converts alignment types
            StringFormat format = new StringFormat();
            int          lNum   = (int)Math.Log((double)TextAlign, 2);

            format.LineAlignment = (StringAlignment)(lNum / 4);
            format.Alignment     = (StringAlignment)(lNum % 4);

            // Creates color of secondary text
            Color color = (Owner.Component.SourceTheme.DARK_BASED) ? ColorExtensions.AddRGB(-120, Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal) : ColorExtensions.AddRGB(100, Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal);

            // Draws secondary text
            using (SolidBrush brush = new SolidBrush(color))
                g.DrawString(SecondaryText, new Font("Segoe UI", 8), brush, new Rectangle(Bounds.X + 10, Bounds.Y + 12, Bounds.Width - 20, Bounds.Height), format);

            // Draws primary text
            using (SolidBrush brush = new SolidBrush(Selected ? Owner.Accent : Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor()))
                g.DrawString(PrimaryText, new Font("Segoe UI", 9), brush, new Rectangle(Bounds.X + 10, Bounds.Y - 12, Bounds.Width - 20, Bounds.Height), format);
        }
Example #3
0
        /// <summary>
        /// Draw click effect
        /// </summary>
        private void DrawClick(Graphics g)
        {
            // ClickEffect
            if (ClickEffect != ClickEffect.None)
            {
                // Color of click effect
                Color color;
                Color fill = Owner.Accent;

                if (Owner.Component.SourceTheme.DARK_BASED == true)
                {
                    // Dark based themes
                    color = Color.FromArgb(_clickAlpha, ColorExtensions.AddRGB(150, fill));
                }
                else
                {
                    // Light based themes
                    color = Color.FromArgb(_clickAlpha, ColorExtensions.AddRGB(-150, fill));
                }

                // Draws click effect
                // Set up anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Ripple
                if (ClickEffect == ClickEffect.Ripple)
                {
                    // Ink's brush and graphics path
                    GraphicsPath ink = Draw.GetEllipsePath(_mouseClickPoint, (int)_radius);

                    // Draws ripple click effect
                    using (SolidBrush brush = new SolidBrush(color))
                        g.FillPath(brush, ink);
                }

                // Square
                if (ClickEffect == ClickEffect.Square || ClickEffect == ClickEffect.SquareRotate)
                {
                    // Square's brush and graphics path
                    GraphicsPath square = Draw.GetSquarePath(_mouseClickPoint, (int)_radius);

                    // Rotates square
                    if (ClickEffect == ClickEffect.SquareRotate)
                    {
                        Matrix matrix = new Matrix();
                        matrix.RotateAt(_rotation, _mouseClickPoint);
                        square.Transform(matrix);
                    }

                    // Draws square click effect
                    using (SolidBrush brush = new SolidBrush(color))
                        g.FillPath(brush, square);
                }

                // Remove anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
Example #4
0
        /// <summary>
        /// Draw click effect
        /// </summary>
        /// <param name="e"></param>
        private void DrawClick(PaintEventArgs e)
        {
            // Control's graphics object
            Graphics g = e.Graphics;

            // ClickEffect
            if (_clickEffect != ClickEffect.None)
            {
                // Color of ClickEffect
                Color color;
                Color fill = Component.SourceTheme.COMPONENT_FILL.Normal.ToColor();

                if (Component.SourceTheme.DARK_BASED == true)
                {
                    // Dark based themes
                    color = Color.FromArgb(_alpha, ColorExtensions.AddRGB(150, fill));
                }
                else
                {
                    // Light based themes
                    color = Color.FromArgb(_alpha, ColorExtensions.AddRGB(-150, fill));
                }

                // Draws ClickEffect
                // Set up anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Ink
                if (_clickEffect == ClickEffect.Ripple)
                {
                    // Ink's brush and graphics path
                    GraphicsPath ink = Draw.GetEllipsePath(_mouse, (int)_radius);

                    // Draws ink ClickEffect
                    using (SolidBrush brush = new SolidBrush(color))
                        g.FillPath(brush, ink);
                }

                // Square
                if (_clickEffect == ClickEffect.Square || _clickEffect == ClickEffect.SquareRotate)
                {
                    // Square's brush and graphics path
                    GraphicsPath square = Draw.GetSquarePath(_mouse, (int)_radius);

                    // Rotates square
                    if (_clickEffect == ClickEffect.SquareRotate)
                    {
                        Matrix matrix = new Matrix();
                        matrix.RotateAt(_rotation, _mouse);
                        square.Transform(matrix);
                    }

                    // Draws square ClickEffect
                    using (SolidBrush brush = new SolidBrush(color))
                        g.FillPath(brush, square);
                }

                // Remove anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
Example #5
0
        /// <summary>
        /// Draws color-box
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Get graphics context
            Graphics g = e.Graphics;

            // Draw colored highlight border
            using (Pen pen = new Pen(ColorExtensions.AddRGB(Component.SourceTheme.DARK_BASED ? 70 : -70, Color)))
            {
                // Rectangular color-box
                if (Type == ColorBoxType.Circle)
                {
                    // Turn on anti-aliasing
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    // Clear control
                    using (SolidBrush brush = new SolidBrush(Color))
                        g.FillEllipse(brush, new Rectangle(new Point(0, 0), new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1)));

                    // Draw border
                    g.DrawEllipse(pen, new Rectangle(new Point(0, 0), new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1)));

                    // Turn off anti-aliasing
                    g.SmoothingMode = SmoothingMode.Default;
                }

                // Circular color-box
                if (Type == ColorBoxType.Rectangle)
                {
                    // Clear control
                    g.Clear(Color);

                    // Draw border
                    g.DrawRectangle(pen, new Rectangle(new Point(0, 0), new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1)));
                }
            }

            // Is border enabled?
            if (Selected)
            {
                // Calculate foreground color
                Color foreColor = (ColorExtensions.PerceivedBrightness(Color) > 130 ? Color.Black : Color.White);
            }

            // Check-box's height
            int height = 19;

            // Middle of check-box
            int b = Height / 2 - height / 2;

            // Check-mark points
            _checkmark = new Point[]
            {
                new Point(7, b + 8),
                new Point(8, b + 9),
                new Point(9, b + 10),
                new Point(10, b + 11),
                new Point(11, b + 12),
                new Point(12, b + 11),
                new Point(13, b + 10),
                new Point(14, b + 9),
                new Point(15, b + 8),
                new Point(16, b + 7),
                new Point(17, b + 6),
                new Point(18, b + 5),
            };

            // Draws check-mark in animation
            if (_a == 10 && Selected == true)
            {
                // Draws two check-marks with 1 width of pen. Setting pen's
                // width to 2 pixels causes one missing pixel at bottom of the
                // check-mark.
                DrawCheckmarkIn(g);
                DrawCheckmarkIn(g, 1, 1);
            }

            // Draws check-mark out animation
            if (_a == 10 && Selected == false)
            {
                // Draws two check-marks with 1 width of pen. Setting pen's
                // width to 2 pixels causes one missing pixel at bottom of the
                // check-mark.
                DrawCheckmarkOut(g);
                DrawCheckmarkOut(g, 1, 1);
            }
        }
Example #6
0
        /// <summary>
        /// Draw method
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Graphics
            Graphics g = e.Graphics;

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

            // Client rectangle
            Rectangle r = ClientRectangle;

            // Draw raised button
            if (_buttonType == ButtonType.Raised)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Accent color
                if (_customColor)
                {
                    // If control is enabled
                    if (Enabled)
                    {
                        // Control enabled
                        fill = ColorExtensions.AddRGB((Component.SourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), Component.Accent);
                    }
                    else
                    {
                        // Control disabled
                        fill = Component.SourceTheme.COMPONENT_FILL.Disabled;
                    }

                    // Fill client rectangle with correct color (background layer)
                    using (SolidBrush brush = new SolidBrush(fill))
                        g.FillRectangle(brush, ClientRectangle);

                    // Turn on anti-aliasing
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    // Mouse position relative to parent form
                    Point mouse = PointToClient(Cursor.Position);

                    // Draw reveal effect
                    // Reveal effect ellipse
                    GraphicsPath ellipse = Draw.GetEllipsePath(mouse, _revealDistance);

                    // Path gradient brush
                    PathGradientBrush pgb = new PathGradientBrush(ellipse);
                    pgb.CenterPoint    = mouse;
                    pgb.CenterColor    = ColorExtensions.AddRGB(Component.SourceTheme.DARK_BASED ? 70 : -70, Accent);
                    pgb.SurroundColors = new Color[] { ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, fill), fill) };

                    // Draw reveal effect if mouse is hovering over an item
                    if (!DesignMode)
                    {
                        g.FillPath(pgb, ellipse);
                    }

                    // Turn off anti-aliasing
                    g.SmoothingMode = SmoothingMode.Default;

                    // Shortcut variable for client rectangle
                    Rectangle cr = ClientRectangle;

                    // Fill client rectangle with correct color (foreground layer)
                    using (SolidBrush brush = new SolidBrush(fill))
                        g.FillRectangle(brush, new Rectangle(cr.X + 2, cr.Y + 2, cr.Width - 4, cr.Height - 4));
                }
                else
                {
                    // Regular raised button
                    fill = ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, Component.SourceTheme.COMPONENT_FILL.Hover), Component.SourceTheme.COMPONENT_FILL.Normal.ToColor());

                    // Control is disabled
                    if (!Enabled)
                    {
                        // Change fill color
                        fill = Component.SourceTheme.COMPONENT_FILL.Disabled;
                    }

                    // Fill client rectangle with correct color (background layer)
                    using (SolidBrush brush = new SolidBrush(fill))
                        g.FillRectangle(brush, ClientRectangle);

                    // Turn on anti-aliasing
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    // Mouse position relative to parent form
                    Point mouse = PointToClient(Cursor.Position);

                    // Draw reveal effect
                    // Reveal effect ellipse
                    GraphicsPath ellipse = Draw.GetEllipsePath(mouse, _revealDistance);

                    // Path gradient brush
                    PathGradientBrush pgb = new PathGradientBrush(ellipse);
                    pgb.CenterPoint    = mouse;
                    pgb.CenterColor    = Component.SourceTheme.COMPONENT_HIGHLIGHT.Normal.ToColor();
                    pgb.SurroundColors = new Color[] { ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, fill), fill) };

                    // Draw reveal effect if mouse is hovering over an item
                    if (!DesignMode)
                    {
                        g.FillPath(pgb, ellipse);
                    }

                    // Turn off anti-aliasing
                    g.SmoothingMode = SmoothingMode.Default;

                    // Shortcut variable for client rectangle
                    Rectangle cr = ClientRectangle;

                    // Fill client rectangle with correct color (foreground layer)
                    using (SolidBrush brush = new SolidBrush(fill))
                        g.FillRectangle(brush, new Rectangle(cr.X + 2, cr.Y + 2, cr.Width - 4, cr.Height - 4));
                }

                // Draw click-effect
                DrawClick(e);

                // Draws text
                DrawText(e);
            }

            // Draws outlined button
            if (_buttonType == ButtonType.Outline)
            {
                // Fill color
                Color fill = new Color();

                // Border color
                Color border = new Color();

                // Button is filled with his Accent color
                if (_customColor)
                {
                    // Full-colored outlined button
                    fill   = ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, ColorExtensions.Fade(220, Component.Accent, Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? Component.Accent : Component.SourceTheme.COMPONENT_FILL.Disabled.ToColor();

                    // Control is not enabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }
                }
                else
                {
                    // Full colored outlined button
                    fill   = ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, ColorExtensions.Fade(220, Component.SourceTheme.COMPONENT_BORDER.Normal, Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? Component.SourceTheme.COMPONENT_FILL.Normal.ToColor() : Component.SourceTheme.COMPONENT_FILL.Disabled.ToColor();

                    // Control is not enabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }
                }

                // Fills client rectangle
                using (SolidBrush brush = new SolidBrush(border))
                    g.FillRectangle(brush, r);

                // Turn on anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Mouse position relative to parent form
                Point mouse = PointToClient(Cursor.Position);

                // Draw reveal effect
                // Reveal effect ellipse
                GraphicsPath ellipse = Draw.GetEllipsePath(mouse, _revealDistance);

                // Path gradient brush
                PathGradientBrush pgb = new PathGradientBrush(ellipse);
                pgb.CenterPoint    = mouse;
                pgb.CenterColor    = (CustomColor) ? ColorExtensions.AddRGB(Component.SourceTheme.DARK_BASED ? 70 : -70, Accent) : Component.SourceTheme.COMPONENT_HIGHLIGHT.Normal.ToColor();
                pgb.SurroundColors = new Color[] { ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, border), border) };

                // Draw reveal effect if mouse is hovering over an item
                if (!DesignMode)
                {
                    g.FillPath(pgb, ellipse);
                }

                // Turn off anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;

                // Fills border (frame)
                using (SolidBrush pen = new SolidBrush(fill))
                    g.FillRectangle(pen, new Rectangle(r.X + 2, r.Y + 2, r.Width - 4, r.Height - 4));

                // Draws click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }

            // Flat button
            if (_buttonType == ButtonType.Flat)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Accent color
                if (_customColor)
                {
                    // Full colored outlined button
                    fill = ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, ColorExtensions.Fade(220, Component.Accent, Parent.BackColor)), Parent.BackColor);

                    // Control is not enabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }
                }
                else
                {
                    // Full colored outlined button
                    fill = ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, ColorExtensions.Fade(160, Component.SourceTheme.COMPONENT_BORDER.Normal, Parent.BackColor)), Parent.BackColor);

                    // Control is not enabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }
                }

                // Fills rectangle (background layer)
                using (SolidBrush brush = new SolidBrush(fill))
                    g.FillRectangle(brush, r);

                // Turn on anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Mouse position relative to parent form
                Point mouse = PointToClient(Cursor.Position);

                // Draw reveal effect
                // Reveal effect ellipse
                GraphicsPath ellipse = Draw.GetEllipsePath(mouse, _revealDistance);

                // Path gradient brush
                PathGradientBrush pgb = new PathGradientBrush(ellipse);
                pgb.CenterPoint    = mouse;
                pgb.CenterColor    = (CustomColor) ? Color.FromArgb(255, Accent) : Component.SourceTheme.COMPONENT_HIGHLIGHT.Normal.ToColor();
                pgb.SurroundColors = new Color[] { ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, fill), fill) };

                // Draw reveal effect if mouse is hovering over an item
                if (!DesignMode)
                {
                    g.FillPath(pgb, ellipse);
                }

                // Turn off anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;

                // Shortcut variable for client rectangle
                Rectangle cr = ClientRectangle;

                // Fills rectangle (foreground layer)
                using (SolidBrush brush = new SolidBrush(fill))
                    g.FillRectangle(brush, new Rectangle(cr.X + 2, cr.Y + 2, cr.Width - 4, cr.Height - 4));

                // Draws click-effect
                DrawClick(e);

                // Draws text
                DrawText(e);
            }
        }