Example #1
0
        //渲染背景 包括menustrip背景 toolstripDropDown背景
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            var toolStrip = e.ToolStrip;
            var g         = e.Graphics;

            //g.SmoothingMode = SmoothingMode.HighQuality;//抗锯齿
            Share.GraphicSetup(g);
            var bounds = e.AffectedBounds;

            //DrawHelper.RenderFormBorder(MenuBgImg, 20, g, e.);
            if (toolStrip is MenuStrip)
            {
                // g.FillRectangle(Brushes.Orange, bounds);
                //DrawHelper.RenderFormBorder(MenuBgImg, 20, g, bounds);
            }
            else if (toolStrip is ToolStripDropDown)
            {
                //  g.FillRectangle(Brushes.Orange, bounds);

                //背景圆角
                DrawHelper.SetWindowRegion(toolStrip, 1);
                using (var sb = new SolidBrush(Share.BackColor))
                {
                    g.FillRectangle(sb, bounds);
                    //画边线
                    sb.Color = Share.BorderColor;

                    var pen = new Pen(sb);
                    var gp  = DrawHelper.CreateRoundPath2(bounds, 2);
                    e.Graphics.DrawPath(pen, gp);
                    pen.Dispose();
                    gp.Dispose();
                }


                //int Rgn = NativeMethods.CreateRoundRectRgn(0, 0, bounds.Width + 1, bounds.Height + 1, 3, 3);
                //NativeMethods.SetWindowRgn(e.ToolStrip.Handle, Rgn, true);
                //toolStrip.BackColor = Color.White;
                //DrawHelper.RenderFormBorder(MenuBgImg, 27, g, bounds);
            }
            else
            {
                //  g.FillRectangle(Brushes.Orange, bounds);

                // g.FillRectangle(Brushes.Orange, bounds);
                //e.Graphics.Clear(Color.Transparent);
                base.OnRenderToolStripBackground(e);
            }
        }