示例#1
0
        /// <summary>
        /// SidePanel on paint method
        /// </summary>
        private void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.Clear(tintColor);

            // Variables
            Point mouse             = PointToClient(Cursor.Position);
            int   distanceToCenterX = (sidePanel.Width / 2) - mouse.X;
            int   distanceToCenterY = (sidePanel.Height / 2) - mouse.Y;
            int   incX    = (distanceToCenterX / 50);
            int   incY    = (distanceToCenterY / 30);
            int   bWidth  = 350;
            int   bHeight = 300;
            int   bX      = (sidePanel.Width / 2) - (bWidth / 2);
            int   bY      = (sidePanel.Height / 2) - (bHeight / 2);

            // Draw ears
            DrawCircle(g, Brushes.White, new Point(bX + 30 + incX, bY + 65 + incY), 50 - (distanceToCenterX / 120));
            DrawCircle(g, Brushes.White, new Point(bX + bWidth - 30 + incX, bY + 65 + incY), 50 + (distanceToCenterX / 120));

            // Draw head
            g.FillEllipse(Brushes.White, new Rectangle(bX, bY, bWidth, bHeight));
            g.FillRectangle(Brushes.White, new Rectangle(bX, bY + (bHeight / 2), bWidth, (this.Height / 2)));

            // Draw eyes
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 - 25 - incX, bY + 60 - incY), 8 - (distanceToCenterX / 650));
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 + 25 - incX, bY + 60 - incY), 8 + (distanceToCenterX / 650));

            // Draw muzzle
            SolidBrush brush = new SolidBrush(MColor.Lighten(210, tintColor, Color.White));

            DrawCircle(g, brush, new Point(bX + bWidth / 2 - (distanceToCenterX / 20), bY + 150 - incY), 65);
            g.FillRectangle(brush, new Rectangle(bX + bWidth / 2 - 65 - (distanceToCenterX / 20), bY + 150 - incY, 130, 50));
            DrawCircle(g, brush, new Point(bX + bWidth / 2 - (distanceToCenterX / 20), bY + 50 + 150 - incY), 65);

            // Draw mouth
            Pen pen = new Pen(new Hex("#383838").ToColor(), 4);

            g.DrawLine(pen, new Point(bX + bWidth / 2 - 10 - (distanceToCenterX / 15), bY + 225 - (distanceToCenterY / 15)), new Point(bX + bWidth / 2 + 10 - (distanceToCenterX / 15), bY + 225 - (distanceToCenterY / 15)));

            // Draw nose
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 - (distanceToCenterX / 15), bY + 150 - (distanceToCenterY / 15)), 45);
            DrawCircle(g, Brushes.White, new Point(bX + bWidth / 2 - (distanceToCenterX / 15) - 20, bY + 150 - (distanceToCenterY / 15) - 20), 10);

            // Draw slogan
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.DrawString("Bear strong protection!", new Font("Segoe UI Light", 48, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new Point(bX - 80, 50));
        }
示例#2
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

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

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

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    if (Enabled)
                    {
                        fill = MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint);
                    }
                    else
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }
                else
                {
                    // Regular raised button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());

                    // Disabled
                    if (!Enabled)
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }

                // Click effect
                DrawClick(e);

                // Focus rectangle
                if (Focused || _tintAlpha > 0)
                {
                    Rectangle rc             = new Rectangle(Location.X, Location.Y, Width, Height);
                    Color     frameColor     = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : fill), fill);
                    Pen       framePen       = new Pen(frameColor);
                    Rectangle frameRectangle = new Rectangle(0, 0, rc.Width - 1, rc.Height - 1);
                    g.DrawRectangle(framePen, frameRectangle);
                }

                // Text
                DrawText(e);
            }

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

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }
                else
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _sourceTheme.CONTROL_FILL.Normal.ToColor() : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }

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

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }
                else
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(160, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }
        }
示例#3
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);
            Graphics g = e.Graphics;

            DIP.GetGraphics(g);

            // Handles control's source theme
            // Check if control has set own theme
            if (Owner.UsedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = Owner.UsedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Draw item background
            Color fill = (Owner.MenuItem == this) ? _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor() : MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(230, _tint, _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor())), _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor());

            g.FillRectangle(new SolidBrush(fill), new Rectangle(0, 0, Width, Height));

            if (FullColored)
            {
                g.FillRectangle(new SolidBrush(MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint)), _tint)), new Rectangle(0, 0, Owner.MenuItem.Height, Owner.MenuItem.Height));
            }

            // Click effect
            DrawClick(e);

            // Icon mode
            if (_icon != null && !_fullColored)
            {
                if (_sourceTheme.DARK_BASED)
                {
                    _icon.DarkBased = true;
                }
                else
                {
                    _icon.DarkBased = false;
                }
            }

            // Draw Icon
            if (_icon != null)
            {
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                if (Owner.SelectedItem == this)
                {
                    Image img = MColor.SetImageColor(_icon.Icon, _tint);
                    g.DrawImage(MColor.SetImageOpacity(img, 1f), 16, 16, 32, 32);
                }
                else
                {
                    g.DrawImage(MColor.SetImageOpacity(_icon.Icon, 1f), 16, 16, 32, 32);
                }
            }
            else
            {
                // Icon rect
                g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(20, 20, 20, 20));
            }

            // Draw text
            SolidBrush brush = (Owner.SelectedItem == this) ? new SolidBrush(_tint) : (_fullColored) ? new SolidBrush(ForeColor) : new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(Text, Font, brush, new Rectangle(65, (Height / 2) - (Font.Height / 2), Width, Height));
        }