當前位置: 首頁>>代碼示例>>C#>>正文


C# PathGradientBrush.Dispose方法代碼示例

本文整理匯總了C#中System.Drawing.Drawing2D.PathGradientBrush.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# PathGradientBrush.Dispose方法的具體用法?C# PathGradientBrush.Dispose怎麽用?C# PathGradientBrush.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Drawing2D.PathGradientBrush的用法示例。


在下文中一共展示了PathGradientBrush.Dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush(//創建線性漸變畫刷
            new Point(0, 0),new Point(20, 20),                  //漸變起始點和終止點
            Color.Yellow,Color.Blue);                           //漸變起始顏色和終止顏色
            G.FillRectangle(linearGradientBrush1, new Rectangle(0, 0, 150, 150));//繪製矩形
            LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(//創建線性漸變畫刷
            new Rectangle(0, 0, 20, 20),                      //漸變所在矩形
            Color.Yellow, Color.Blue, 60f);                     //漸變起始顏色、終止顏色以及漸變方向
            linearGradientBrush2.WrapMode = WrapMode.TileFlipXY;
            G.FillRectangle(linearGradientBrush2, new Rectangle(150, 0, 150, 150));//繪製矩形

            GraphicsPath graphicsPath1 = new GraphicsPath();        //創建繪製路徑
            graphicsPath1.AddArc(new Rectangle(0, 150, 100, 100), 90, 180);//向路徑中添加半左圓弧
            graphicsPath1.AddArc(new Rectangle(150, 150, 100, 100), 270, 180);//向路徑中添加半右圓弧
            graphicsPath1.CloseFigure();                            //閉合路徑
            PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath1);//創建路徑漸變畫刷
            pathGradientBrush.CenterColor = Color.Yellow;           //指定畫刷中心顏色
            pathGradientBrush.SurroundColors = new Color[] { Color.Blue };//指定畫刷周邊顏色
            pathGradientBrush.CenterPoint = new PointF(125, 200);   //指定畫刷中心點坐標
            G.SmoothingMode = SmoothingMode.AntiAlias;              //消鋸齒
            G.FillPath(pathGradientBrush, graphicsPath1);           //利用畫刷填充路徑
            G.DrawPath(new Pen(Color.Lime, 3f), graphicsPath1);     //繪製閉合路徑曲線

            linearGradientBrush1.Dispose();
            linearGradientBrush2.Dispose();
            graphicsPath1.Dispose();
            pathGradientBrush.Dispose();
        }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:32,代碼來源:FormGradientBrush.cs

示例2: OnPaint

        /// <summary>
        /// Draws a radial gradient in the label
        /// </summary>
        /// <param name="e">paint arguments</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddEllipse(this.ClientRectangle);

            PathGradientBrush brush = new PathGradientBrush(path);

            brush.CenterPoint = new PointF(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2);
            brush.CenterColor = this.StartColor;
            brush.SurroundColors = new Color[] { this.EndColor };

            e.Graphics.FillPath(brush, path);

            brush.Dispose();
            path.Dispose();
        }
開發者ID:bluewormlabs,項目名稱:colorclock,代碼行數:20,代碼來源:GradientLabel.cs

示例3: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            G.SmoothingMode = SmoothingMode.AntiAlias;              //消除鋸齒
            LinearGradientBrush brushOut = new LinearGradientBrush( //創建線性漸變畫刷
            new Point(0, 0), new Point(20, 20), Color.Gray, Color.White);
            brushOut.WrapMode = WrapMode.TileFlipXY;
            G.FillPath(brushOut, pathOut);                          //填充外框路徑
            PathGradientBrush brushIn = new PathGradientBrush(pathIn);//創建路徑畫刷
            brushIn.CenterColor = Color.White;
            brushIn.CenterPoint = new PointF(ClientRectangle.Width / 2, ClientRectangle.Height / 2);
            brushIn.SurroundColors = new Color[] { Color.Orange };
            G.FillPath(brushIn, pathIn);                            //填充內框路徑
            G.DrawString(buttonText, Font, Brushes.Black, ClientRectangle, format);//繪製字符串
            brushOut.Dispose();
            brushIn.Dispose();
        }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:19,代碼來源:CrystalButton.cs

示例4: PaintView3

        private void PaintView3(Graphics g)
        {
            GraphicsPath gp = new GraphicsPath();
            gp.AddEllipse(ClientRectangle);

            PathGradientBrush pgb = new PathGradientBrush(gp);

            pgb.CenterPoint = new PointF(ClientRectangle.Width / 2,
                                         ClientRectangle.Height / 2);
            pgb.CenterPoint = new PointF(ClientRectangle.Width / 4,
                ClientRectangle.Height / 4);
            pgb.CenterColor = Color.White;
            pgb.SurroundColors = new Color[] { Color.Red };

            g.FillRectangle(pgb, this.ClientRectangle);
            pgb.Dispose();
            gp.Dispose();

            title = "Big Red Circle";
        }
開發者ID:mono,項目名稱:sysdrawing-coregraphics,代碼行數:20,代碼來源:DrawingView.cs

示例5: GlassSphere

        private void GlassSphere(Graphics g)
        {
            Color c = Color.Blue;
            int reduct = 200;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;

            // Base ellipse
            Rectangle r1 = new Rectangle(new Point(0, 0), new Size(this.Width-reduct, this.Height-reduct));
            Rectangle r2 = new Rectangle(r1.Location, new Size(r1.Size.Width - reduct - 2, r1.Size.Height - reduct - 2));

            GraphicsPath path = new GraphicsPath (FillMode.Winding);
            path.AddEllipse(r2);
            PathGradientBrush br1 = new PathGradientBrush(path);
            br1.CenterColor = c;
            br1.SurroundColors = new Color[] { Color.FromArgb(255, Color.Black) };
            //br1.CenterPoint = new PointF((float)(r1.Width / 1.5), r1.Top - Convert.ToInt16(r1.Height * 2));

            Blend bl1 = new Blend(5);
            bl1.Factors = new float[] { 0.5f, 1.0f, 1.0f, 1.0f, 1.0f };
            bl1.Positions = new float[] { 0.0f, 0.05f, 0.5f, 0.75f, 1.0f };
            br1.Blend = bl1;

            g.FillPath(br1, path);

            br1.Dispose();
            path.Dispose();

            // 1st hilite ellipse
            int r3w = Convert.ToInt16(r2.Width * 0.8);
            int r3h = Convert.ToInt16(r2.Height * 0.6);

            int r3posX = (r2.Width / 2) - (r3w / 2);
            int r3posY = r2.Top + 1;

            Rectangle r3 = new Rectangle(
                new Point(r3posX, r3posY),
                new Size(r3w, r3h));

            Color br3c1 = Color.White;
            Color br3c2 = Color.Transparent;

            LinearGradientBrush br2 = new LinearGradientBrush(r3, br3c1, br3c2, 90);
            br2.WrapMode = WrapMode.TileFlipX;
            g.FillEllipse(br2, r3);

            br2.Dispose();

            // 2nd hilite ellipse
            int r4w = Convert.ToInt16(r2.Width * 0.3);
            int r4h = Convert.ToInt16(r2.Height * 0.2);

            int r4posX = (r2.Width / 2) + (r4w / 2);
            int r4posY = r2.Top + Convert.ToInt16(r2.Height * 0.2);

            Rectangle r4 = new Rectangle(
                new Point(-(int)(r4w / 2), -(int)(r4h / 2)),
                new Size(r4w, r4h));

            LinearGradientBrush br3 = new LinearGradientBrush(r4, br3c1, br3c2, 90, true);
            g.TranslateTransform(r4posX, r4posY);
            g.RotateTransform(30);
            g.FillEllipse(br3, r4);

            br3.Dispose();
            title = "GlassSphere";
        }
開發者ID:mono,項目名稱:sysdrawing-coregraphics,代碼行數:67,代碼來源:DrawingView.cs

示例6: DrawPanelSelected

        /// <summary>
        /// Draws a panel in selected state
        /// </summary>
        /// <param name="e"></param>
        public void DrawPanelSelected(RibbonPanelRenderEventArgs e)
        {

            #region Office_2007

            if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007)
            {
                Rectangle darkBorder = Rectangle.FromLTRB(
                      e.Panel.Bounds.Left,
                      e.Panel.Bounds.Top,
                      e.Panel.Bounds.Right,
                      e.Panel.Bounds.Bottom);

                Rectangle lightBorder = Rectangle.FromLTRB(
                     e.Panel.Bounds.Left + 1,
                     e.Panel.Bounds.Top + 1,
                     e.Panel.Bounds.Right - 1,
                     e.Panel.Bounds.Bottom - 1);

                Rectangle textArea =
                     Rectangle.FromLTRB(
                     e.Panel.Bounds.Left + 1,
                     e.Panel.ContentBounds.Bottom,
                     e.Panel.Bounds.Right - 1,
                     e.Panel.Bounds.Bottom - 1);

                GraphicsPath dark = RoundRectangle(darkBorder, 3);
                GraphicsPath light = RoundRectangle(lightBorder, 3);
                GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest);

                using (Pen p = new Pen(ColorTable.PanelLightBorder))
                {
                    e.Graphics.DrawPath(p, light);
                }

                using (Pen p = new Pen(ColorTable.PanelDarkBorder))
                {
                    e.Graphics.DrawPath(p, dark);
                }

                using (SolidBrush b = new SolidBrush(ColorTable.PanelBackgroundSelected))
                {
                    e.Graphics.FillPath(b, light);
                }

                using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackgroundSelected))
                {
                    e.Graphics.FillPath(b, txt);
                }

                if (e.Panel.ButtonMoreVisible)
                {
                    if (e.Panel.ButtonMorePressed)
                    {
                        DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }
                    else if (e.Panel.ButtonMoreSelected)
                    {
                        DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }

                    DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled);
                }

                txt.Dispose();
                dark.Dispose();
                light.Dispose();
            }

            #endregion

            #region Office_2010

            if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010)
            {
                Rectangle innerLightBorder = Rectangle.FromLTRB(
                     e.Panel.Bounds.Left,
                     e.Panel.Bounds.Top,
                     e.Panel.Bounds.Right - 2,
                     e.Panel.Bounds.Bottom);

                Rectangle darkBorder = Rectangle.FromLTRB(
                      e.Panel.Bounds.Left,
                      e.Panel.Bounds.Top,
                      e.Panel.Bounds.Right - 1,
                      e.Panel.Bounds.Bottom);

                Rectangle outerLightBorder = Rectangle.FromLTRB(
                    e.Panel.Bounds.Left,
                    e.Panel.Bounds.Top,
                    e.Panel.Bounds.Right,
                    e.Panel.Bounds.Bottom);

                //Glow appears as a tall elipse, rather than circle
                Rectangle glowR = new Rectangle(
                     e.Panel.Bounds.Left + (int)(0.1 * e.Panel.Bounds.Width),
//.........這裏部分代碼省略.........
開發者ID:shintadono,項目名稱:System.Windows.Forms.Ribbon,代碼行數:101,代碼來源:RibbonProfessionalRenderer.cs

示例7: GenerateCircle

     private void GenerateCircle(Graphics g, float x, float y, float width, float height, int heading)
     {
         var outerRect = new RectangleF(x, y, width, height);

         // Fill the background of the whole control
         using (var bg = new SolidBrush(BackColor))
             g.FillRectangle(bg, outerRect);

         // Fill the background of the circle
         var circleRect = outerRect;
         circleRect.Inflate((_borderWidth/-2), (_borderWidth/-2));
         
         using (var white = new LinearGradientBrush(outerRect, _barBgLightColour, _barBgDarkColor, 0F))
                {
                  g.FillEllipse(white, circleRect);
                }
     
         var gp = new GraphicsPath();
         gp.AddEllipse(circleRect);

         var pgb = new PathGradientBrush(gp);

         pgb.CenterPoint = new PointF(circleRect.Width/2, circleRect.Height/2);
         pgb.CenterColor = _sweepDarkColour;
         pgb.SurroundColors = new[] {_sweepLightColour};

         heading = (heading + 270  -5)   %360;

         g.FillPie(pgb, circleRect.Left, circleRect.Top, circleRect.Width, circleRect.Height, heading, 10);

         pgb.Dispose();

         using (var borderPen = new Pen(_borderColor, _borderWidth))
         {
             g.DrawEllipse(borderPen, circleRect);
         }
     }
開發者ID:RodrigoVarasLopez,項目名稱:ardupilot-mega,代碼行數:37,代碼來源:CompassControl.cs

示例8: DrawGlassOverlay

        /// <summary>
        /// Renders the clock's glass overlay.
        /// </summary>
        /// <param name="gfx">Graphics object used for rendering.</param>
        /// <param name="rect">Bounding rectangle.</param>
        protected virtual void DrawGlassOverlay(Graphics gfx, RectangleF rect)
        {
            GraphicsState gState;
            PathGradientBrush brush;
            GraphicsPath path, brushPath;
            PointF[] curvePoints;
            float radius;

            gState = gfx.Save();
            rect.Width *= 0.95f;
            rect.Height *= 0.95f;
            rect.X = -rect.Width / 2.0f;
            rect.Y = -rect.Height / 2.0f;
            radius = Math.Min(rect.Width, rect.Height) / 2.0f;

            brushPath = new GraphicsPath();
            brushPath.AddEllipse(rect);
            brush = new PathGradientBrush(brushPath);
            brush.CenterPoint = new PointF(0.0f, 0.0f);
            brush.CenterColor = Color.FromArgb(192, Color.White);
            brush.SurroundColors = new Color[] { Color.FromArgb(64, Color.White) };

            path = new GraphicsPath();
            path.AddArc(rect, 180, 180);
            curvePoints = new PointF[5];
            curvePoints[0].X = -radius;
            curvePoints[0].Y = 0.0f;

            curvePoints[1].X = -radius * 0.5f;
            curvePoints[1].Y = -radius * 0.175f;

            curvePoints[2].X = 0.0f;
            curvePoints[2].Y = -radius * 0.25f;

            curvePoints[3].X = radius * 0.5f;
            curvePoints[3].Y = -radius * 0.175f;

            curvePoints[4].X = radius;
            curvePoints[4].Y = 0.0f;

            path.AddCurve(curvePoints);
            path.CloseAllFigures();

            gfx.RotateTransform(_ClockStyleData.GlassAngle);
            gfx.FillPath(brush, path);

            gfx.Restore(gState);
            brush.Dispose();
            brushPath.Dispose();
            path.Dispose();

        }
開發者ID:huamanhtuyen,項目名稱:VNACCS,代碼行數:57,代碼來源:AnalogClockControl.cs

示例9: GraphicsPath

    FillCircle3D
    (
        Graphics oGraphics,
        Color oColor,
        Single fXCenter,
        Single fYCenter,
        Single fRadius
    )
    {
        Debug.Assert(oGraphics != null);
        Debug.Assert(fRadius > 0);

        // The following code is based on the BouncingGradientBrushBall.cs
        // example in "Programming Windows with C#," by Petzold.

        GraphicsPath oGraphicsPath = new GraphicsPath();

        // Add the circle to the path.

        RectangleF oRectangleF =
            SquareFromCenterAndHalfWidth(fXCenter, fYCenter, fRadius);

        oGraphicsPath.AddEllipse(oRectangleF);

        PathGradientBrush oPathGradientBrush =
            new PathGradientBrush(oGraphicsPath);

        // Specify white for the point 1/3 to the left and top of the circle's
        // bounding rectangle.

        oPathGradientBrush.CenterPoint = new PointF(
            oRectangleF.Left + oRectangleF.Width / 3F,
            oRectangleF.Top + oRectangleF.Height / 3F);

        oPathGradientBrush.CenterColor = Color.White;

        // Use the specified color for the single surround color.

        oPathGradientBrush.SurroundColors = new Color [] {oColor};

        // Fill the circle with the gradient brush.

        oGraphics.FillRectangle(oPathGradientBrush, oRectangleF);

        oPathGradientBrush.Dispose();
        oGraphicsPath.Dispose();
    }
開發者ID:2014-sed-team3,項目名稱:term-project,代碼行數:47,代碼來源:GraphicsUtil.cs

示例10: OnPaint


//.........這裏部分代碼省略.........
                case 270:
                    {
                        int h = Height - 1;
                        int w = Width - 1;
                        int ha = arrowHeadWidth + 1;
                        int w1 = (int)(w * (1 - arrowBaseHeight) / 2.0f);
                        PointF[] la =
             {
                 new PointF(w1,h),
                 new PointF(w1,ha),
                 new PointF(1,ha),
                 new PointF(w/2,1),
                 new PointF(w,ha),
                 new PointF(w-w1,ha),
                 new PointF(w-w1,h),
                 new PointF(w1,h)
             };
                        path.AddLines(la);
                        PointF[] la2 =
             {
                 new PointF(w1-1,h+1),
                 new PointF(w1-1,ha+1),
                 new PointF(0,ha-1),
                 new PointF(w/2,0),
                 new PointF(w+1,ha+1),
                 new PointF(w-w1+1,ha+1),
                 new PointF(w-w1+1,h+1),
                 new PointF(w1-1,h+1)
             };
                        innerPath.AddLines(la2);

                        cliphover = new Region(new Rectangle(0, Height-hoverWidth, Width, hoverWidth));
                    }
                    break;
            }
            //this.Region = new Region(innerPath); // Set shape for hit detection
            Brush fontBrush = Brushes.Black;
            PathGradientBrush pgbrush = new PathGradientBrush(innerPath);
            pgbrush.CenterPoint = new Point(75, 75);
            pgbrush.CenterColor = Color.White;
            pgbrush.SurroundColors = new Color[] { this.ForeColor };
            Pen p = new Pen(borderColor, 1);
            g.FillPath(linearBrush, path);
            Region clip = g.Clip;
            g.Clip = cliphover;
            g.FillPath(highlightBrush, path);
            // Draw seperations
            string[] va = possibleValues.Split(';');
            g.Clip = new Region(path);
            switch (_rotation)
            {
                case 0: {
                    for (int i = 0; i < va.Length-1; i++)
                    {
                        int pos = (i + 1) * Width / va.Length;
                        g.DrawLine(Pens.DarkGray,pos,0,pos,Height);
                    }
                }
                    break;
                case 180:
                    {
                        for (int i = 0; i < va.Length - 1; i++)
                        {
                            int pos = Width-(i + 1) * Width / va.Length;
                            g.DrawLine(Pens.DarkGray, pos, 0, pos, Height);
                        }
                    }
                    break;
                case 90:
                    {
                        for (int i = 0; i < va.Length - 1; i++)
                        {
                            int pos = (i + 1) * Height / va.Length;
                            g.DrawLine(Pens.DarkGray,0, pos, Width, pos);
                        }
                    }
                    break;
                case 270:
                    {
                        for (int i = 0; i < va.Length - 1; i++)
                        {
                            int pos = Height - (i + 1) * Height / va.Length;
                            g.DrawLine(Pens.DarkGray,0, pos, Width, pos);
                        }
                    }
                    break;
            }
            g.Clip = clip;
            g.DrawPath(p, path);
            SizeF fsize = g.MeasureString(title, drawFont);
            textX -= fsize.Width / 2;
            textY -= fsize.Height / 2;
            g.DrawString(title, drawFont, fontBrush, textX, textY);
            // Dispose of painting objects
            b.Dispose();
            p.Dispose();
            pgbrush.Dispose();
            linearBrush.Dispose();
            highlightBrush.Dispose();
        }
開發者ID:JackTing,項目名稱:Repetier-Host,代碼行數:101,代碼來源:ArrowButton.cs

示例11: DrawDropShadow

		private void DrawDropShadow(Graphics graphics, Rectangle rect, Color shadowColor, int shadowDepth, byte maxAlpha)
		{
			// Determine the shadow colors
			Color darkShadow = Color.FromArgb(maxAlpha, shadowColor);
			Color lightShadow = Color.FromArgb(0, shadowColor);

			// Create a brush that will create a softshadow circle
			GraphicsPath graphicsPath = new GraphicsPath();
			graphicsPath.AddEllipse(0, 0, 2 * shadowDepth, 2 * shadowDepth);

			PathGradientBrush brush = new PathGradientBrush(graphicsPath);
			brush.CenterColor = darkShadow;
			brush.SurroundColors = new Color[] { lightShadow };

			// Generate a softshadow pattern that can be used to paint the shadow
			Bitmap pattern = new Bitmap(2 * shadowDepth, 2 * shadowDepth);

			Graphics patternGraphics = Graphics.FromImage(pattern);
			patternGraphics.FillEllipse(brush, 0, 0, 2 * shadowDepth, 2 * shadowDepth);

			patternGraphics.Dispose();
			brush.Dispose();

			// Top right corner
			graphics.DrawImage(pattern, new Rectangle(rect.Right - shadowDepth, rect.Top + shadowDepth, shadowDepth, shadowDepth), shadowDepth, 0, shadowDepth, shadowDepth, GraphicsUnit.Pixel);

			// Right side
			graphics.DrawImage(pattern, new Rectangle(rect.Right - shadowDepth, rect.Top + 2 * shadowDepth, shadowDepth, rect.Height - 3 * shadowDepth), shadowDepth, shadowDepth, shadowDepth, 1, GraphicsUnit.Pixel);

			// Bottom right corner
			graphics.DrawImage(pattern, new Rectangle(rect.Right - shadowDepth, rect.Bottom - shadowDepth, shadowDepth, shadowDepth), shadowDepth, shadowDepth, shadowDepth, shadowDepth, GraphicsUnit.Pixel);

			// Bottom side
			graphics.DrawImage(pattern, new Rectangle(rect.Left + 2 * shadowDepth, rect.Bottom - shadowDepth, rect.Width - 3 * shadowDepth, shadowDepth), shadowDepth, shadowDepth, 1, shadowDepth, GraphicsUnit.Pixel);

			// Bottom left corner
			graphics.DrawImage(pattern, new Rectangle(rect.Left + shadowDepth, rect.Bottom - shadowDepth, shadowDepth, shadowDepth), 0, shadowDepth, shadowDepth, shadowDepth, GraphicsUnit.Pixel);

			pattern.Dispose();
		}
開發者ID:nhannd,項目名稱:Xian,代碼行數:40,代碼來源:SplashScreen.cs

示例12: FillPath

 /// <summary>
 /// Handles the drawing code for linear gradient paths.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="gp"></param>
 public override void FillPath(Graphics g, GraphicsPath gp)
 {
     RectangleF bounds = Bounds;
     if (bounds.IsEmpty) bounds = gp.GetBounds();
     if (bounds.Width == 0 || bounds.Height == 0) return;
     //also don't draw gradient for very small polygons
     if (bounds.Width < 0.01 || bounds.Height < 0.01) return;
     if (_gradientType == GradientType.Linear)
     {
         LinearGradientBrush b = new LinearGradientBrush(bounds, _colors[0], _colors[_colors.Length - 1], (float)-_angle);
         ColorBlend cb = new ColorBlend();
         cb.Positions = _positions;
         cb.Colors = _colors;
         b.InterpolationColors = cb;
         g.FillPath(b, gp);
         b.Dispose();
     }
     else if (_gradientType == GradientType.Circular)
     {
         GraphicsPath round = new GraphicsPath();
         PointF center = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
         float x = (float)(center.X - Math.Sqrt(2) * bounds.Width / 2);
         float y = (float)(center.Y - Math.Sqrt(2) * bounds.Height / 2);
         float w = (float)(bounds.Width * Math.Sqrt(2));
         float h = (float)(bounds.Height * Math.Sqrt(2));
         RectangleF circum = new RectangleF(x, y, w, h);
         round.AddEllipse(circum);
         PathGradientBrush pgb = new PathGradientBrush(round);
         ColorBlend cb = new ColorBlend();
         cb.Colors = _colors;
         cb.Positions = _positions;
         pgb.InterpolationColors = cb;
         g.FillPath(pgb, gp);
         pgb.Dispose();
     }
     else if (_gradientType == GradientType.Rectangular)
     {
         GraphicsPath rect = new GraphicsPath();
         PointF[] points = new PointF[5];
         PointF center = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
         double a = bounds.Width / 2;
         double b = bounds.Height / 2;
         double angle = _angle;
         if (angle < 0) angle = 360 + angle;
         angle = angle % 90;
         angle = 2 * (Math.PI * angle / 180);
         double x = a * Math.Cos(angle);
         double y = -b - a * Math.Sin(angle);
         points[0] = new PointF((float)x + center.X, (float)y + center.Y);
         x = a + b * Math.Sin(angle);
         y = b * Math.Cos(angle);
         points[1] = new PointF((float)x + center.X, (float)y + center.Y);
         x = -a * Math.Cos(angle);
         y = b + a * Math.Sin(angle);
         points[2] = new PointF((float)x + center.X, (float)y + center.Y);
         x = -a - b * Math.Sin(angle);
         y = -b * Math.Cos(angle);
         points[3] = new PointF((float)x + center.X, (float)y + center.Y);
         points[4] = points[0];
         rect.AddPolygon(points);
         PathGradientBrush pgb = new PathGradientBrush(rect);
         ColorBlend cb = new ColorBlend();
         cb.Colors = _colors;
         cb.Positions = _positions;
         pgb.InterpolationColors = cb;
         g.FillPath(pgb, gp);
         pgb.Dispose();
     }
 }
開發者ID:DIVEROVIEDO,項目名稱:DotSpatial,代碼行數:74,代碼來源:GradientPattern.cs

示例13: UpdateBorder

        /// <summary>
        /// Updates Border panel image
        /// </summary>
        /// <param name="pg">Border Panel Graphics device</param>
        private void UpdateBorder(ref Graphics pg, ref Graphics pgc2)
        {
            //gnarly code goes here
            GraphicsPath gpath = new GraphicsPath();
            foreach (GridBase gb in BorderBases)
            {
                gpath.Reset();
                gpath.AddEllipse(gb.mx/20 - 6, gb.my/20 - 6, 12, 12);

                PathGradientBrush pgBrush = new PathGradientBrush(gpath);
                pgBrush.CenterPoint = new Point(gb.mx/20, gb.my/20);
                pgBrush.CenterColor = Color.FromArgb(254, 255, 255, 255);

                Color[] bcolor = { Color.FromArgb(1, 0, 0, 0) };
                pgBrush.SurroundColors = bcolor;
                if (gb.cityflag == 0)
                {
                    pg.FillEllipse(pgBrush, gb.mx / 20 - 6, gb.my / 20 - 6, 12, 12);
                }
                else
                {
                    pgc2.FillEllipse(pgBrush, gb.mx / 20 - 6, gb.my / 20 - 6, 12, 12);
                }
                pgBrush.Dispose();
            }
            gpath.Dispose();
            // update grid array with new values from image
        }
開發者ID:NHundley,項目名稱:CityBorderTest,代碼行數:32,代碼來源:BorderTestForm.cs

示例14: DrawDropShadow

        /// <summary>
        /// Draw a drop shadow
        /// </summary>
        /// <param name="g">The graphics object to use</param>
        /// <param name="offx">Offset from the current position to draw the shadow</param>
        /// <param name="offy"></param>
        public void DrawDropShadow(Graphics g, float offx, float offy)
        {
            PathGradientBrush b = null;
            GraphicsPath path = GetPath();

            try
            {
                Matrix m = new Matrix();
                m.Translate(offx, offy);
                path.Transform(m);
                b = new PathGradientBrush(path);

                b.WrapMode = WrapMode.Clamp;
                ColorBlend colors = new ColorBlend(3);

                colors.Colors = new Color[] {Color.Transparent, Color.FromArgb(180, Color.DimGray),  Color.FromArgb(180, Color.DimGray)};
                colors.Positions = new float[] { 0.0f, 0.1f, 1.0f };
                b.InterpolationColors = colors;
                g.FillPath(b, path);
            }
            finally
            {
                if (path != null)
                {
                    path.Dispose();
                }

                if (b != null)
                {
                    b.Dispose();
                }
            }
        }
開發者ID:michyer,項目名稱:canape,代碼行數:39,代碼來源:GraphNode.cs

示例15: DrawTabSelected

        /// <summary>
        /// Draws a selected tab
        /// </summary>
        /// <param name="e"></param>
        public void DrawTabSelected(RibbonTabRenderEventArgs e)
        {
            Rectangle outerR = Rectangle.FromLTRB(
                 e.Tab.TabBounds.Left,
                 e.Tab.TabBounds.Top,
                 e.Tab.TabBounds.Right - 1,
                 e.Tab.TabBounds.Bottom);
            Rectangle innerR = Rectangle.FromLTRB(
                 outerR.Left + 1,
                 outerR.Top + 1,
                 outerR.Right - 1,
                 outerR.Bottom);

            Rectangle glossyR = Rectangle.FromLTRB(
                 innerR.Left + 1,
                 innerR.Top + 1,
                 innerR.Right - 1,
                 innerR.Top + e.Tab.TabBounds.Height / 2);

            GraphicsPath outer = RoundRectangle(outerR, 3, Corners.NorthEast | Corners.NorthWest);
            GraphicsPath inner = RoundRectangle(innerR, 3, Corners.NorthEast | Corners.NorthWest);
            GraphicsPath glossy = RoundRectangle(glossyR, 3, Corners.NorthEast | Corners.NorthWest);

            using (Pen p = new Pen(ColorTable.TabBorder))
            {
                e.Graphics.DrawPath(p, outer);
            }

            using (Pen p = new Pen(Color.FromArgb(200, Color.White)))
            {
                e.Graphics.DrawPath(p, inner);
            }

            using (GraphicsPath radialPath = new GraphicsPath())
            {
                radialPath.AddRectangle(innerR);
                //radialPath.AddEllipse(innerR);
                radialPath.CloseFigure();

                PathGradientBrush gr = new PathGradientBrush(radialPath);
                gr.CenterPoint = new PointF(
                     Convert.ToSingle(innerR.Left + innerR.Width / 2),
                     Convert.ToSingle(innerR.Top - 5));
                gr.CenterColor = Color.Transparent;
                gr.SurroundColors = new Color[] { ColorTable.TabSelectedGlow };

                Blend blend = new Blend(3);
                blend.Factors = new float[] { 0.0f, 0.9f, 0.0f };
                blend.Positions = new float[] { 0.0f, 0.8f, 1.0f };

                gr.Blend = blend;

                e.Graphics.FillPath(gr, radialPath);

                gr.Dispose();
            }
            using (SolidBrush b = new SolidBrush(Color.FromArgb(100, Color.White)))
            {
                e.Graphics.FillPath(b, glossy);
            }

            outer.Dispose();
            inner.Dispose();
            glossy.Dispose();
        }
開發者ID:JoeyScarr,項目名稱:word-commandmap,代碼行數:69,代碼來源:RibbonProfessionalRenderer.cs


注:本文中的System.Drawing.Drawing2D.PathGradientBrush.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。