当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsPath.Reset方法代码示例

本文整理汇总了C#中GraphicsPath.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.Reset方法的具体用法?C# GraphicsPath.Reset怎么用?C# GraphicsPath.Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsPath的用法示例。


在下文中一共展示了GraphicsPath.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

	public static void Main () 
	{

		Bitmap bmp = new Bitmap (600, 300);
		Graphics dc = Graphics.FromImage (bmp);        		
		Font fnt = new Font ("Arial", 8);
		Font fnttitle = new Font ("Arial", 8, FontStyle.Underline);
		Matrix matrix = new Matrix ();		
		GraphicsPath patha = new GraphicsPath ();
		GraphicsPath pathb = new GraphicsPath ();
		Pen redPen = new Pen (Color.Red, 2);		
		Region rgn1;
		Region rgn2;		
		int x = 0;		
		
		SolidBrush whiteBrush = new SolidBrush (Color.White);				
		
		dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5);				
		
		/* First*/		
		patha.AddLine (60, 40, 90, 90);
		patha.AddLine (90, 90, 10, 90);
		patha.AddLine (10, 90, 60, 40);			
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse(30, 55, 60, 60);
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Complement (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);			
		dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Second*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);					
		
		dc.DrawPath (redPen, patha);						
				
		pathb.AddEllipse (30+x, 55, 60, 60);						
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Exclude (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);				
		dc.DrawString ("Exclude ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Third*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Intersect (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);		
		dc.DrawString ("Intersect ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;
		
		/* Four*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Xor (rgn2);
		dc.FillRegion(Brushes.Blue, rgn1);		
		dc.DrawString ("Xor ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;	
		
		/* Fifth */		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:RegionsGraphicsPath.cs

示例2: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        int intRate = 0;
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        Color UseFillColor = new Color();
        Color UseBorderColor = new Color();
        GraphicsPath ShapePath = new GraphicsPath();
        float ptx;
        float pty;
        StringFormat sf = new StringFormat();
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;

        pty = (this.Height - (RadiusOuter * 2)) / 2;
        intRate = 0;
        while (!(intRate == MaxRating))
        {
          ptx = intRate * (RadiusOuter * 2 + ShapeGap) + Padding.Left + (ShapeGap / 2);
          if (PaintRating > intRate)
          {
        if (!IsPainting & HighlightRateFill & (PaintRating != intRate + 1))
        {
          UseFillColor = ShapeColorHover;
          UseBorderColor = ShapeBorderHoverColor;
        }
        else if (IsPainting & HighlightRateHover & (PaintRating == intRate + 1))
        {
          UseFillColor = ShapeColorFill;
          UseBorderColor = ShapeBorderFilledColor;
        }
        else
        {
          UseFillColor = PaintColor;
          UseBorderColor = PaintBorderColor;
        }
          }
          else
          {
        UseFillColor = ShapeColorEmpty;
        UseBorderColor = ShapeBorderEmptyColor;
          }

          ShapePath.Reset();
          Point[] pts;
          switch (Shape)
          {
        case eShape.Star:
          ShapePath = DrawStar(ptx, pty);
          break;
        case eShape.Heart:
          ShapePath = DrawHeart(ptx, pty);
          break;
        case eShape.Square:
          ShapePath.AddRectangle(new Rectangle((int)ptx, (int)pty, (int)(RadiusOuter * 2), (int)(RadiusOuter * 2)));
          break;
        case eShape.Circle:
          ShapePath.AddEllipse(ptx, pty, RadiusOuter * 2, RadiusOuter * 2);
          break;
        case eShape.Diamond:
          pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter)), new Point((int)(ptx + RadiusOuter), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter)) };
          ShapePath.AddPolygon(pts);
          break;
        case eShape.Triangle:
          pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter * 2)) };
          ShapePath.AddPolygon(pts);
          break;

          }

          e.Graphics.FillPath(new SolidBrush(UseFillColor), ShapePath);
          e.Graphics.DrawPath(new Pen(UseBorderColor, ShapeBorderWidth), ShapePath);

          if (ShapeNumberShow != eShapeNumberShow.None)
          {
        if (ShapeNumberShow == eShapeNumberShow.All | (ShapeNumberShow == eShapeNumberShow.RateOnly & PaintRating == intRate + 1))
        {
          e.Graphics.DrawString((intRate + 1).ToString(), ShapeNumberFont, new SolidBrush(ShapeNumberColor), new RectangleF(ShapeNumberIndent.X + ptx, ShapeNumberIndent.Y + pty, RadiusOuter * 2, RadiusOuter * 2), sf);
        }
          }

          intRate += 1;
        }

        if (LabelShow)
        {
          int R_x = (int)(((RadiusOuter * 2) * (MaxRating)) + LabelIndent + ((ShapeGap) * MaxRating) + Padding.Left);
          if (IsPainting)
          {
        RateLabel.Text = GetLabelText(LabelTypeHover);
          }
          else
          {
        RateLabel.Text = GetLabelText(LabelTypeText);
          }
          RateLabel.Width = (this.Width - R_x);
          RateLabel.Height = (this.Height);
          RateLabel.Location = new Point(R_x, 0);
        }
    }
开发者ID:jcbarton,项目名称:MUMS,代码行数:99,代码来源:ShapeRater.cs


注:本文中的GraphicsPath.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。