コード例 #1
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            e.Graphics.Clear(e.BackColor);

            if (e.ToolStrip is ToolStripDropDownMenu)
            {
                //base.OnRenderToolStripBackground(e);
                Rectangle rect = e.AffectedBounds;
                //Image image = MenuBackImage.Image;
                //PT.ExpandImage(e.Graphics, image, 10, rect, new Rectangle(0, 0, image.Width, image.Height));
                //e.ToolStrip.Region = new Region(PT.GetRoundRectangle(new Rectangle(rect.Left, rect.Top, rect.Width + 1, rect.Height + 1), 2));

                e.Graphics.FillRectangle(new SolidBrush(UITheme.Default.Colors.MediumLight), rect);

                GraphicsPath path = PaintHelper.GetRoundRectangle(rect, 2);
                e.Graphics.DrawPath(Pens.Gray, path);

                e.Graphics.FillRectangle(Brushes.Silver, new Rectangle(rect.Right - 1, rect.Bottom - 1, 1, 1));
            }
            else
            {
                int def = 0;
                if (e.ToolStrip is ToolStripPro && ((ToolStripPro)e.ToolStrip).HalfRenderBackground)
                {
                    def = 2;
                }

                Image image = BarBackImage.Image;
                PaintHelper.ExpandImage(e.Graphics, image, 5, e.AffectedBounds, new Rectangle(0, def, image.Width, image.Height - def));
            }
            //base.OnRenderToolStripBackground(e);
        }
コード例 #2
0
        protected override void DrawItemBackground(TabItemPaintEventArgs e)
        {
            //base.DrawItemBackground(e);

            TaskBar taskBar   = e.GetBar <TaskBar>();
            Color   backColor = e.Bar.ItemBackColor;

            switch (e.Status)
            {
            case UIControlStatus.Selected:
            case UIControlStatus.Focused:
                if (taskBar.IsActive)
                {
                    backColor = taskBar.SelectedItemBackColor;
                }
                else
                {
                    backColor = taskBar.InactiveSelectedItemBackColor;
                }
                break;

            case UIControlStatus.Hover:
                backColor = taskBar.HoverItemBackColor;
                break;
            }

            if (!backColor.IsEmpty)
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(e.Bounds, taskBar.TabRounded, taskBar.TabRounded, 0, 0);
                //if (e.Status == UIControlStatus.Hover)
                //{
                //    LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, backColor, backColor, 90.0f);
                //    ColorBlend cb = new ColorBlend(3);
                //    cb.Colors = new Color[] { PaintHelper.GetLightColor(backColor), backColor, backColor };
                //    cb.Positions = new float[] { 0.0f, 0.5f, 1.0f };
                //    backBrush.InterpolationColors = cb;
                //    e.Graphics.FillPath(backBrush, path);
                //}
                //else
                //{
                SolidBrush backBrush = new SolidBrush(backColor);
                e.Graphics.FillPath(backBrush, path);
                //}

                //
                if ((e.Status == UIControlStatus.Normal || e.Status == UIControlStatus.Hover) &&
                    e.Bounds.Height > 10)
                {
                    Rectangle rectShadow = e.Bounds;
                    rectShadow.Y      = rectShadow.Bottom - 6;
                    rectShadow.Height = 5;
                    var brush = new LinearGradientBrush(rectShadow, Color.Transparent,
                                                        PaintHelper.AdjustColorSLess(PaintHelper.GetDarkColor(backColor), 20), 90.0f);
                    rectShadow.Y++;//规避一个Gdi+错误, 会导致第一行有一个很深的线
                    //e.Graphics.FillRectangle(Brushes.Red, rectShadow);
                    e.Graphics.FillRectangle(brush, rectShadow);
                }
            }
        }
コード例 #3
0
        public override void DrawBaseLine(PaintEventArgs e)
        {
            Rectangle    rect  = new Rectangle(0, Bar.Height - Bar.BaseLineSize, Bar.Width, Bar.BaseLineSize);
            GraphicsPath path  = PaintHelper.GetRoundRectangle(rect, Bar.BaseLineSize, Bar.BaseLineSize, 0, 0);
            Color        color = TaskBar.IsActive ? TaskBar.SelectedItemBackColor : TaskBar.InactiveSelectedItemBackColor;

            e.Graphics.FillPath(new SolidBrush(color), path);
        }
コード例 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            InvokePaintBackground(this, e);

            Rectangle rectTitle = ClientRectangle;

            rectTitle.Height = FoldingButtonRect.Height;

            Size sizeText = Size.Ceiling(e.Graphics.MeasureString(Text, Font));

            rectTitle.Height = Math.Max(rectTitle.Height, sizeText.Height);

            Image image = Folded ? Properties.Resources.folding_expand : Properties.Resources.folding_collapse;

            PaintHelper.DrawImageInRange(e.Graphics, image, FoldingButtonRect);
            rectTitle.X     += FoldingButtonRect.Width;
            rectTitle.Width -= FoldingButtonRect.Width;

            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rectTitle, PaintHelper.SFLeft);
            rectTitle.X     += sizeText.Width;
            rectTitle.Width -= sizeText.Width;

            PaintHelper.SetHighQualityRender(e.Graphics);
            e.Graphics.ExcludeClip(new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - rectTitle.Width, rectTitle.Height));
            Rectangle rectBorder = new Rectangle(0, rectTitle.Y + rectTitle.Height / 2, ClientSize.Width, ClientSize.Height - rectTitle.Height / 2);
            Pen       penLine    = new Pen(PaintHelper.GetDarkColor(BackColor));

            if (Folded)
            {
                e.Graphics.DrawLine(penLine, rectBorder.X, rectBorder.Y, rectBorder.Right, rectBorder.Y);
            }
            else
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(rectBorder, 6);
                e.Graphics.DrawPath(penLine, path);
                path.Dispose();
            }

            if (Focused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));
            }
        }
コード例 #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            e.Graphics.Clear(BackColor);

            Rectangle rect = ClientRectangle.Inflate(Padding);

            if (RoundSize == 0)
            {
                e.Graphics.DrawRectangle(new Pen(BorderColor),
                                         rect.X,
                                         rect.Y,
                                         rect.Width - 1,
                                         rect.Height - 1);
            }
            else
            {
                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                GraphicsPath path = PaintHelper.GetRoundRectangle(rect, RoundSize);
                e.Graphics.FillPath(new SolidBrush(ContentBackColor), path);
                e.Graphics.DrawPath(new Pen(BorderColor), path);
            }
        }