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


C# Region.Exclude方法代码示例

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


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

示例1: Main

	public static void Main () 
	{
		Bitmap bmp = new Bitmap (600, 800);
		Graphics dc = Graphics.FromImage (bmp);        		
		Font fnt = new Font ("Arial", 8);
		Font fnttitle = new Font("Arial", 8, FontStyle.Underline);
		Matrix matrix = new Matrix ();		
		int x = 0;
		Rectangle rect1, rect2, rect3, rect4;		
		Region rgn1, rgn2, rgn3, rgn4;
				
		bool complement = true, exclude = true, union = true, xor = true, intersect = true;
		
		SolidBrush whiteBrush = new SolidBrush (Color.White);				
		
		dc.DrawString ("Region samples using two Rectangle classes", fnttitle, whiteBrush, 5, 5);
				
		/* First */				
		if (complement) {	
			rect1 = new Rectangle (20, 30, 60, 80);		
			rect2 = new Rectangle (50, 40, 60, 80);		
			rgn1 = new Region (rect1);
			rgn2 = new Region (rect2);						
			dc.DrawRectangle (Pens.Green, rect1);				
			dc.DrawRectangle (Pens.Red, rect2);
			rgn1.Complement (rgn2);
			dc.FillRegion (Brushes.Blue, rgn1);		
			dc.DrawString ("Complement ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 130);						
			dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));		
			DumpRegion (rgn1);
		}
		
		/* Second */		
		if (exclude) {
			rect3 = new Rectangle (130, 30, 60, 80);		
			rect4 = new Rectangle (170, 40, 60, 80);		
			rgn3 = new Region (rect3);
			rgn4 = new Region (rect4);			
			dc.DrawRectangle (Pens.Green, rect3);		
			dc.DrawRectangle (Pens.Red, rect4);
			rgn3.Exclude (rgn4);
			dc.FillRegion (Brushes.Blue, rgn3);		
			dc.DrawString ("Exclude ("  + rgn3.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 130, 130);
			dc.DrawRectangles (Pens.Yellow, rgn3.GetRegionScans (matrix));
			DumpRegion (rgn3);
		}
		
		/* Third */
		if (intersect) {		
			
			Rectangle rect5 = new Rectangle (260, 30, 60, 80);		
			Rectangle rect6 = new Rectangle (290, 40, 60, 80);		
			Region rgn5 = new Region (rect5);
			Region rgn6 = new Region (rect6);			
			dc.DrawRectangle (Pens.Green, rect5);		
			dc.DrawRectangle (Pens.Red, rect6);
			rgn5.Intersect (rgn6);
			dc.FillRegion (Brushes.Blue, rgn5);		
			dc.DrawString ("Intersect ("  + rgn5.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 130);
			dc.DrawRectangles (Pens.Yellow, rgn5.GetRegionScans (matrix));
			DumpRegion (rgn5);
		}
		
		/* Four */		
		if (xor) {
			Rectangle rect7 = new Rectangle (380, 30, 60, 80);		
			Rectangle rect8 = new Rectangle (410, 40, 60, 80);		
			Region rgn7 = new Region (rect7);
			Region rgn8 = new Region (rect8);			
			dc.DrawRectangle (Pens.Green, rect7);		
			dc.DrawRectangle (Pens.Red, rect8);
			rgn7.Xor (rgn8);
			dc.FillRegion (Brushes.Blue, rgn7);		
			dc.DrawString ("Xor ("  + rgn7.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 400, 130);
			dc.DrawRectangles (Pens.Yellow, rgn7.GetRegionScans (matrix));
			DumpRegion (rgn7);
		}
		
		/* Fifht */		
		if (union) {
			Rectangle rect9 = new Rectangle (500, 30, 60, 80);		
			Rectangle rect10 = new Rectangle (520, 40, 60, 80);		
			Region rgn9 = new Region(rect9);
			Region rgn10 = new Region(rect10);			
			dc.DrawRectangle (Pens.Green, rect9);		
			dc.DrawRectangle (Pens.Red, rect10);
			rgn9.Union(rgn10);
			dc.FillRegion (Brushes.Blue, rgn9);		
			dc.DrawString ("Union (" + rgn9.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 530, 130);		
			dc.DrawRectangles (Pens.Yellow, rgn9.GetRegionScans (matrix));		
			DumpRegion (rgn9);
		}
		
		dc.DrawString ("Region samples using three Rectangle class", fnttitle, whiteBrush, 5, 155);
		
		/* First */		
		x = 0;		
		
		if (complement) {	
			rect1 = new Rectangle (20+x, 180, 40, 50);		
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:RegionsRectangle.cs

示例2: 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

示例3: DrawColorSlider

    /// <summary>
    /// Draws the colorslider control using passed colors.
    /// </summary>
    /// <param name="e">The <see cref="T:System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
    /// <param name="thumbOuterColorPaint">The thumb outer color paint.</param>
    /// <param name="thumbInnerColorPaint">The thumb inner color paint.</param>
    /// <param name="thumbPenColorPaint">The thumb pen color paint.</param>
    /// <param name="barOuterColorPaint">The bar outer color paint.</param>
    /// <param name="barInnerColorPaint">The bar inner color paint.</param>
    /// <param name="barPenColorPaint">The bar pen color paint.</param>
    /// <param name="elapsedOuterColorPaint">The elapsed outer color paint.</param>
    /// <param name="elapsedInnerColorPaint">The elapsed inner color paint.</param>
    private void DrawColorSlider(PaintEventArgs e, Color thumbOuterColorPaint, Color thumbInnerColorPaint,
        Color thumbPenColorPaint, Color barOuterColorPaint, Color barInnerColorPaint,
        Color barPenColorPaint, Color elapsedOuterColorPaint, Color elapsedInnerColorPaint)
    {
        //set up thumbRect aproprietly
        if (barOrientation == Orientation.Horizontal)
        {
            int TrackX = (((trackerValue - barMinimum) * (this.ContentRectangle.Width - thumbSize)) / (barMaximum - barMinimum)) + 2;
            thumbRect = new Rectangle(TrackX, 3, thumbSize - 1, this.ContentRectangle.Height - 3);
        }
        else
        {
            int TrackY = (((trackerValue - barMinimum) * (this.ContentRectangle.Height - thumbSize)) / (barMaximum - barMinimum));
            thumbRect = new Rectangle(3, TrackY, this.ContentRectangle.Width - 3, thumbSize - 1);
        }

        //adjust drawing rects
        barRect = this.ContentRectangle;
        thumbHalfRect = thumbRect;
        LinearGradientMode gradientOrientation;
        if (barOrientation == Orientation.Horizontal)
        {
            barRect.Inflate(-1, -barRect.Height / 3);
            barHalfRect = barRect;
            barHalfRect.Height /= 2;
            gradientOrientation = LinearGradientMode.Vertical;
            thumbHalfRect.Height /= 2;
            elapsedRect = barRect;
            elapsedRect.Width = thumbRect.Left + thumbSize / 2;
        }
        else
        {
            barRect.Inflate(-barRect.Width / 3, -1);
            barHalfRect = barRect;
            barHalfRect.Width /= 2;
            gradientOrientation = LinearGradientMode.Horizontal;
            thumbHalfRect.Width /= 2;
            elapsedRect = barRect;
            elapsedRect.Height = thumbRect.Top + thumbSize / 2;
        }
        //get thumb shape path
        GraphicsPath thumbPath;
        if (thumbCustomShape == null)
            thumbPath = CreateRoundRectPath(thumbRect, thumbRoundRectSize);
        else
        {
            thumbPath = thumbCustomShape;
            Matrix m = new Matrix();
            m.Translate(thumbRect.Left - thumbPath.GetBounds().Left, thumbRect.Top - thumbPath.GetBounds().Top);
            thumbPath.Transform(m);
        }

        //draw bar
        using (
            LinearGradientBrush lgbBar =
                new LinearGradientBrush(barHalfRect, barOuterColorPaint, barInnerColorPaint, gradientOrientation)
            )
        {
            lgbBar.WrapMode = WrapMode.TileFlipXY;
            e.Graphics.FillRectangle(lgbBar, barRect);
            //draw elapsed bar
            using (
                LinearGradientBrush lgbElapsed =
                    new LinearGradientBrush(barHalfRect, elapsedOuterColorPaint, elapsedInnerColorPaint,
                                            gradientOrientation))
            {
                lgbElapsed.WrapMode = WrapMode.TileFlipXY;
                if (Selected && drawSemitransparentThumb)
                {
                    Region elapsedReg = new Region(elapsedRect);
                    elapsedReg.Exclude(thumbPath);
                    e.Graphics.FillRegion(lgbElapsed, elapsedReg);
                }
                else
                    e.Graphics.FillRectangle(lgbElapsed, elapsedRect);
            }
            //draw bar band
            using (Pen barPen = new Pen(barPenColorPaint, 0.5f))
            {
                e.Graphics.DrawRectangle(barPen, barRect);
            }
        }

        //draw thumb
        Color newthumbOuterColorPaint = thumbOuterColorPaint, newthumbInnerColorPaint = thumbInnerColorPaint;
        if (Selected && drawSemitransparentThumb)
        {
            newthumbOuterColorPaint = Color.FromArgb(175, thumbOuterColorPaint);
//.........这里部分代码省略.........
开发者ID:philwo,项目名称:crossfade,代码行数:101,代码来源:ToolStripSlider.cs


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