示例#1
0
        private void PaintVisual(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            base.Paint(g);

            var taskbarLocation = this.MainForm.TaskbarLocation;

            bool horizontal = taskbarLocation == Native.ABEdge.Top ||
                              taskbarLocation == Native.ABEdge.Bottom;

            int spaceAfterX = horizontal ? ButtonConstants.SpaceAfter : 1;
            int spaceAfterY = horizontal ? 0 : ButtonConstants.SpaceAfter;

            if (!MainForm.IsHidden)
            {
                // paint background
                Region originalClip = g.Clip;
                using (Region r = new System.Drawing.Region(g.ClipBounds))
                {
                    // exclude corners since they should be rounded
                    r.Exclude(new Rectangle(0, 0, 2, 2));
                    r.Exclude(new Rectangle(Width - spaceAfterX - 1, 0, 2, 2));
                    r.Exclude(new Rectangle(0, Height - 2, 2, 2));
                    r.Exclude(new Rectangle(Width - spaceAfterX - 1, Height - 2, 2, 2));
                    g.Clip = r;

                    ProgressBarDecorator.Paint(g, _buttonBounds, _progress);

                    if (_flashActive)
                    {
                        g.FillRectangle(new LinearGradientBrush(_buttonBounds, Theme.ButtonFlashBackgroundFrom, Theme.ButtonFlashBackgroundTo, 90f), _buttonBounds);
                    }
                    else if (Hover)
                    {
                        HotTrackDecorator.Paint(g, this.Tag as SecondDisplayProcess, this.Image as Bitmap, _buttonBounds, this.PointToClient(Cursor.Position));
                    }

                    HighlightDecorator.Paint(g, _buttonBounds);

                    if ((this.Focused || this._isClicked) && !_flashActive)
                    {
                        g.FillRectangle(Theme.ButtonBackgroundFocused, 2, 2, Width - spaceAfterX - 2, Height - spaceAfterY - 2);
                    }
                }
                g.Clip = originalClip;
            }

            #region Border
            // draw border over background
            GraphicsPath path = RoundedRectangle.Create(new Rectangle(0, 0, Width - spaceAfterX, Height - spaceAfterY - 1), 2, RoundedRectangle.RectangleCorners.All);
            g.DrawPath(Theme.ButtonOuterBorder, path);

            path = RoundedRectangle.Create(new Rectangle(1, 1, Width - spaceAfterX - 2, Height - spaceAfterY - 3), 2, RoundedRectangle.RectangleCorners.All);
            g.DrawPath(Theme.ButtonInnerBorder, path);

            #endregion

            if (MainForm.IsHidden)
            {
                return;
            }

            DrawImageAndText(g, horizontal, spaceAfterX, spaceAfterY);
        }
示例#2
0
        private void PaintClassic(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            base.Paint(g);

            var  taskbarLocation = this.MainForm.TaskbarLocation;
            bool horizontal      = taskbarLocation == Native.ABEdge.Top ||
                                   taskbarLocation == Native.ABEdge.Bottom;

            int spaceAfterX = horizontal ? ButtonConstants.SpaceAfter : 1;
            int spaceAfterY = horizontal ? 0 : ButtonConstants.SpaceAfter;

            if (!horizontal)
            {
                spaceAfterY = -1;
            }

            Pen darkPen    = new Pen(Color.FromKnownColor(KnownColor.ControlDark));
            Pen lighterPen = new Pen(Color.FromKnownColor(KnownColor.ControlLightLight));
            Pen darkerPen  = new Pen(Color.FromKnownColor(KnownColor.ControlDarkDark));
            Pen lightPen   = new Pen(Color.FromKnownColor(KnownColor.ControlLight));

            if (!MainForm.IsHidden)
            {
                // paint background
                ProgressBarDecorator.Paint(g, _buttonBounds, _progress);

                if (_flashActive)
                {
                    g.FillRectangle(new LinearGradientBrush(_buttonBounds, Theme.ButtonFlashBackgroundFrom, Theme.ButtonFlashBackgroundTo, 90f), _buttonBounds);
                }

                if (this.Focused || this._isClicked)
                {
                    if (!_flashActive)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.ButtonHighlight)), _buttonBounds);
                    }

                    #region Border
                    // draw border over background

                    if (this.MainForm.TaskbarLocation == Native.ABEdge.Top)
                    {
                        ButtonBorderDecorator.Draw(g, 0, 3, Width - spaceAfterX - 1, Height - spaceAfterY - 3, true);
                    }
                    else
                    {
                        ButtonBorderDecorator.Draw(g, 0, 4, Width - spaceAfterX - 1, Height - spaceAfterY - 3, true);
                    }
                    #endregion
                }
            }

            if (!this.Focused && !this._isClicked)
            {
                #region Border
                // draw border over background
                if (taskbarLocation == Native.ABEdge.Top)
                {
                    ButtonBorderDecorator.Draw(g, 0, 3, Width - spaceAfterX - 1, Height - spaceAfterY - 3, false);
                }
                else
                {
                    ButtonBorderDecorator.Draw(g, 0, 4, Width - spaceAfterX - 1, Height - spaceAfterY - 3, false);
                }

                #endregion
            }

            if (MainForm.IsHidden)
            {
                return;
            }

            DrawImageAndText(g, horizontal, spaceAfterX, spaceAfterY);
        }