Exemplo n.º 1
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            var g = e.Graphics;

            g.Clear(MaterialSkinManager.GetApplicationBackgroundColor());

            //Draw background
            var itemRect = GetItemRect(e.Item);

            g.FillRectangle(e.Item.Selected && e.Item.Enabled ? MaterialSkinManager.GetCmsSelectedItemBrush() : new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), itemRect);

            //Ripple animation
            var toolStrip = e.ToolStrip as MaterialContextMenuStrip;

            if (toolStrip != null)
            {
                var animationManager = toolStrip.animationManager;
                var animationSource  = toolStrip.animationSource;
                if (toolStrip.animationManager.IsAnimating() && e.Item.Bounds.Contains(animationSource))
                {
                    for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                    {
                        var animationValue = animationManager.GetProgress(i);
                        var rippleBrush    = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.Black));
                        var rippleSize     = (int)(animationValue * itemRect.Width * 2.5);
                        g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, itemRect.Y - itemRect.Height, rippleSize, itemRect.Height * 3));
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
        {
            var g = e.Graphics;

            g.FillRectangle(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), e.Item.Bounds);
            g.DrawLine(new Pen(MaterialSkinManager.GetDividersColor()), new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), new Point(e.Item.Bounds.Right, e.Item.Bounds.Height / 2));
        }
Exemplo n.º 3
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     e.Graphics.FillRectangle(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height));
     e.Graphics.DrawString(e.Header.Text,
                           MaterialSkinManager.ROBOTO_MEDIUM_10,
                           MaterialSkinManager.GetSecondaryTextBrush(),
                           new Rectangle(e.Bounds.X + ITEM_PADDING, e.Bounds.Y + ITEM_PADDING, e.Bounds.Width - ITEM_PADDING * 2, e.Bounds.Height - ITEM_PADDING * 2),
                           getStringFormat());
 }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.SmoothingMode     = SmoothingMode.HighQuality;
            G.TextRenderingHint = TextRenderingHint.AntiAlias;

            Color NonColor = MaterialSkinManager.GetDisabledOrHintColor();

            var PicBG        = DrawHelper.CreateRoundRect(1, 1, 292, 164, 1);
            var UpRoundedRec = DrawHelper.CreateRoundRect(1, 1, 291, 164, 1);
            var BG           = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1);
            var ShadowBG     = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2);

            G.FillPath(new SolidBrush(NonColor), ShadowBG);
            G.DrawPath(new Pen(NonColor), ShadowBG);

            //if (MouseState == MouseState.HOVER)
            //{
            //    Color c = MaterialSkinManager.GetApplicationBackgroundColor();
            //    G.FillPath(new SolidBrush(Color.FromArgb((int)(0.7*c.A), c.RemoveAlpha())), BG);
            //}
            //else
            //{
            G.FillPath(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), BG);
            //}
            G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG);


            G.DrawString(Text, MaterialSkinManager.ROBOTO_MEDIUM_15, Primary ? MaterialSkinManager.ColorScheme.PrimaryBrush : MaterialSkinManager.GetPrimaryTextBrush(), 12, 176);

            G.SmoothingMode = SmoothingMode.None;
            G.FillRectangle(MaterialSkinManager.GetDividersBrush(), 16, InfoLabel.Bottom + 14, 261, 1);

            if (_image != null)
            {
                G.SetClip(PicBG);
                G.DrawImage(_image, 0, 0, 293, 166);
            }
            else
            {
                G.FillPath(new SolidBrush(NonColor), UpRoundedRec);
                G.DrawPath(new Pen(NonColor), UpRoundedRec);
            }
            G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG);
            if (!DesignMode && Controls.Count > 0)
            {
                this.DrawChildShadow(G);
            }
        }
Exemplo n.º 5
0
        public PopupForm()
        {
            materialSkinManager             = MaterialSkinManager.Instance;
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);

            FormBorderStyle = FormBorderStyle.None;
            DoubleBuffered  = true;
            ShowInTaskbar   = false;
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);

            //TopLevel = false;
            BackColor = materialSkinManager.GetApplicationBackgroundColor();
        }
Exemplo n.º 6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.SmoothingMode     = SmoothingMode.HighQuality;
            G.TextRenderingHint = TextRenderingHint.AntiAlias;

            Color NonColor = MaterialSkinManager.GetDisabledOrHintColor();

            var PicBG        = DrawHelper.CreateRoundRect(1, 1, 292, 164, 1);
            var UpRoundedRec = DrawHelper.CreateRoundRect(1, 1, 291, 164, 1);
            var BG           = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1);
            var ShadowBG     = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2);

            G.FillPath(new SolidBrush(NonColor), ShadowBG);
            G.DrawPath(new Pen(NonColor), ShadowBG);
            if (animationManager.IsAnimating())
            {
                G.FillPath(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), BG);
                G.SetClip(BG);
                G.SmoothingMode = SmoothingMode.AntiAlias;
                for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = animationManager.GetProgress(i);
                    var animationSource = animationManager.GetSource(i);

                    using (Brush rippleBrush = new SolidBrush(MaterialSkinManager.ColorScheme.PrimaryColor))
                    {
                        var rippleSize = (int)(animationValue * Math.Max(Width, Height) * 2.5);
                        G.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                    }
                }
                G.ResetClip();
                G.SmoothingMode = SmoothingMode.None;
            }
            else
            {
                G.FillPath(new SolidBrush(Primary ? MaterialSkinManager.ColorScheme.PrimaryColor : MaterialSkinManager.GetApplicationBackgroundColor()), BG);
            }
            G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG);
            if (!DesignMode && Controls.Count > 0)
            {
                this.DrawChildShadow(G);
            }
        }
Exemplo n.º 7
0
        public MaterialContextMenuStrip()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            Renderer = new MaterialToolStripRender();

            animationManager = new AnimationManager(false)
            {
                Increment     = 0.07,
                AnimationType = AnimationType.Linear
            };
            animationManager.OnAnimationProgress += sender => Invalidate();
            animationManager.OnAnimationFinished += sender => OnItemClicked(delayesArgs);

            BackColor = MaterialSkinManager.GetApplicationBackgroundColor();
        }
Exemplo n.º 8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;

            G.SmoothingMode = SmoothingMode.HighQuality;

            var BG          = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1);
            var ThumbnailBG = DrawHelper.CreateLeftRoundRect(1, 1, 50, 49, 1);

            G.FillPath(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), BG);
            //Hover
            Color c = MaterialSkinManager.GetFlatButtonHoverBackgroundColor();

            using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())))
                G.FillPath(b, BG);
            G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG);

            G.FillPath(MaterialSkinManager.ColorScheme.PrimaryBrush, ThumbnailBG);
            G.DrawPath(MaterialSkinManager.ColorScheme.PrimaryPen, ThumbnailBG);

            if (image != null)
            {
                G.DrawImage(image, 3, 3, 48, 47);
            }
            if (Enabled)
            {
                G.DrawString(Text, MaterialSkinManager.ROBOTO_MEDIUM_10, Primary ? MaterialSkinManager.ColorScheme.PrimaryBrush : MaterialSkinManager.GetPrimaryTextBrush(), new PointF(58.6f, 9f));
            }
            else
            {
                G.DrawString(Text, MaterialSkinManager.ROBOTO_MEDIUM_10, new SolidBrush(MaterialSkinManager.GetDisabledOrHintColor()), new PointF(58.6f, 9f));
            }

            G.TextRenderingHint = TextRenderingHint.AntiAlias;
            G.DrawString(info, MaterialSkinManager.ROBOTO_REGULAR_9, new SolidBrush(MaterialSkinManager.GetSecondaryTextColor()), new PointF(59.1f, 26f));
            if (!DesignMode && Controls.Count > 0)
            {
                this.DrawChildShadow(G);
            }
        }
Exemplo n.º 9
0
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            //We draw the current line of items (= item with subitems) on a temp bitmap, then draw the bitmap at once. This is to reduce flickering.
            var b = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height);
            var g = Graphics.FromImage(b);

            //always draw default background
            g.FillRectangle(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));

            if (e.State.HasFlag(ListViewItemStates.Selected))
            {
                //selected background
                g.FillRectangle(MaterialSkinManager.GetFlatButtonPressedBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));
            }
            else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER)
            {
                //hover background
                g.FillRectangle(MaterialSkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));
            }


            //Draw separator
            g.DrawLine(new Pen(MaterialSkinManager.GetDividersColor()), e.Bounds.Left, 0, e.Bounds.Right, 0);

            foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems)
            {
                //Draw text
                g.DrawString(subItem.Text, MaterialSkinManager.ROBOTO_MEDIUM_10, MaterialSkinManager.GetPrimaryTextBrush(),
                             new Rectangle(subItem.Bounds.X + ITEM_PADDING, ITEM_PADDING, subItem.Bounds.Width - 2 * ITEM_PADDING, subItem.Bounds.Height - 2 * ITEM_PADDING),
                             getStringFormat());
            }

            e.Graphics.DrawImage((Image)b.Clone(), new Point(0, e.Item.Bounds.Location.Y));
            g.Dispose();
            b.Dispose();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(MaterialSkinManager.GetApplicationBackgroundColor());
            e.Graphics.FillRectangle(MaterialSkinManager.GetDisabledOrHintBrush(), 0, 0, Width, Height);
            int doneProgress = (int)(Width * ((double)Value / Maximum));

            if (OnRight)
            {
                e.Graphics.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, Width - doneProgress, 0, Width, Height);
            }
            else
            {
                e.Graphics.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, 0, 0, doneProgress, Height);
            }
            if (animationManager.IsAnimating())
            {
                for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                {
                    double animationValue     = animationManager.GetProgress(i);
                    bool   animationDirection = (bool)animationManager.GetData(i)[0];
                    int    animationData      = (int)animationManager.GetData(i)[1];
                    if (animationDirection)
                    {
                        int oldProgress = (int)(((float)(animationData - _value) / Maximum) * Width);
                        if (OnRight)
                        {
                            if (DecreaseHighlight)
                            {
                                e.Graphics.FillRectangle(MaterialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.ColorScheme.DarkPrimaryBrush : MaterialSkinManager.ColorScheme.LightPrimaryBrush, Width - doneProgress - oldProgress, 0, oldProgress, Height);
                            }
                            e.Graphics.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, (float)(Width - doneProgress - oldProgress + (oldProgress * animationValue)), 0, (float)(oldProgress - oldProgress * animationValue), Height);
                        }
                        else
                        {
                            if (DecreaseHighlight)
                            {
                                e.Graphics.FillRectangle(MaterialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.ColorScheme.DarkPrimaryBrush : MaterialSkinManager.ColorScheme.LightPrimaryBrush, doneProgress, 0, oldProgress, Height);
                            }
                            e.Graphics.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height);
                        }
                    }
                    else
                    {
                        int oldProgress = (int)(((float)(_value - animationData) / Maximum) * Width);
                        if (OnRight)
                        {
                            e.Graphics.FillRectangle(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), Width - doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height);
                            e.Graphics.FillRectangle(MaterialSkinManager.GetDisabledOrHintBrush(), Width - doneProgress, 0, (float)(oldProgress - oldProgress * animationValue), Height);
                        }
                        else
                        {
                            e.Graphics.FillRectangle(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), doneProgress - oldProgress + (float)(oldProgress * animationValue), 0, (float)(oldProgress - oldProgress * animationValue), Height);
                            e.Graphics.FillRectangle(MaterialSkinManager.GetDisabledOrHintBrush(), doneProgress - oldProgress + (float)(oldProgress * animationValue), 0, (float)(oldProgress - oldProgress * animationValue), Height);
                        }
                    }
                }
            }
            if (!DesignMode && Controls.Count > 0)
            {
                this.DrawChildShadow(e.Graphics);
            }
        }
Exemplo n.º 11
0
 protected override void OnCreateControl()
 {
     base.OnCreateControl();
     Font      = MaterialSkinManager.ROBOTO_MEDIUM_10;
     BackColor = MaterialSkinManager.GetApplicationBackgroundColor();
 }
Exemplo n.º 12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(MaterialSkinManager.GetApplicationBackgroundColor());
            g.FillRectangle(MaterialSkinManager.ColorScheme.DarkPrimaryBrush, statusBarBounds);
            g.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, actionBarBounds);

            //Draw border
            using (var borderPen = new Pen(MaterialSkinManager.GetDividersColor(), 1))
            {
                g.DrawLine(borderPen, new Point(0, actionBarBounds.Bottom), new Point(0, Height - 2));
                g.DrawLine(borderPen, new Point(Width - 1, actionBarBounds.Bottom), new Point(Width - 1, Height - 2));
                g.DrawLine(borderPen, new Point(0, Height - 1), new Point(Width - 1, Height - 1));
            }

            // Determine whether or not we even should be drawing the buttons.
            bool showMin    = MinimizeBox && ControlBox;
            bool showMax    = MaximizeBox && ControlBox;
            var  hoverBrush = MaterialSkinManager.GetFlatButtonHoverBackgroundBrush();
            var  downBrush  = MaterialSkinManager.GetFlatButtonPressedBackgroundBrush();

            // When MaximizeButton == false, the minimize button will be painted in its place
            if (buttonState == ButtonState.MinOver && showMin)
            {
                g.FillRectangle(hoverBrush, showMax ? minButtonBounds : maxButtonBounds);
            }

            if (buttonState == ButtonState.MinDown && showMin)
            {
                g.FillRectangle(downBrush, showMax ? minButtonBounds : maxButtonBounds);
            }

            if (buttonState == ButtonState.MaxOver && showMax)
            {
                g.FillRectangle(hoverBrush, maxButtonBounds);
            }

            if (buttonState == ButtonState.MaxDown && showMax)
            {
                g.FillRectangle(downBrush, maxButtonBounds);
            }

            if (buttonState == ButtonState.XOver && ControlBox)
            {
                g.FillRectangle(hoverBrush, xButtonBounds);
            }

            if (buttonState == ButtonState.XDown && ControlBox)
            {
                g.FillRectangle(downBrush, xButtonBounds);
            }

            using (var formButtonsPen = new Pen(MaterialSkinManager.ACTION_BAR_TEXT_SECONDARY, 2))
            {
                // Minimize button.
                if (showMin)
                {
                    int x = showMax ? minButtonBounds.X : maxButtonBounds.X;
                    int y = showMax ? minButtonBounds.Y : maxButtonBounds.Y;

                    g.DrawLine(
                        formButtonsPen,
                        x + (int)(minButtonBounds.Width * 0.33),
                        y + (int)(minButtonBounds.Height * 0.66),
                        x + (int)(minButtonBounds.Width * 0.66),
                        y + (int)(minButtonBounds.Height * 0.66)
                        );
                }

                // Maximize button
                if (showMax)
                {
                    g.DrawRectangle(
                        formButtonsPen,
                        maxButtonBounds.X + (int)(maxButtonBounds.Width * 0.33),
                        maxButtonBounds.Y + (int)(maxButtonBounds.Height * 0.36),
                        (int)(maxButtonBounds.Width * 0.39),
                        (int)(maxButtonBounds.Height * 0.31)
                        );
                }

                // Close button
                if (ControlBox)
                {
                    g.DrawLine(
                        formButtonsPen,
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.33),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.33),
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.66),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.66)
                        );

                    g.DrawLine(
                        formButtonsPen,
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.66),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.33),
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.33),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.66));
                }
            }

            //Form title
            g.DrawString(Text, MaterialSkinManager.ROBOTO_MEDIUM_12, MaterialSkinManager.ColorScheme.TextBrush, new Rectangle(MaterialSkinManager.FORM_PADDING, STATUS_BAR_HEIGHT, Width, ACTION_BAR_HEIGHT), new StringFormat {
                LineAlignment = StringAlignment.Center
            });
            if (!DesignMode && Controls.Count > 0 && !resizing)
            {
                this.DrawChildShadow(g);
            }
        }