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


C# Region.Clone方法代码示例

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


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

示例1: BlockRegions

        static BlockRegions()
        {
            int n = Constants.PROJ_WIDTH / 4;

            WholeBlock = new Region();
            WholeBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                WholeBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i, i * 4 + 2, Constants.PROJ_HEIGHT - 2 * i));
            }
            WholeBlock.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH, Constants.PROJ_HEIGHT));
            InnerBlock = new Region();
            InnerBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                InnerBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i + 1, i * 4 + 2, Constants.PROJ_HEIGHT - 2 - 2 * i));
            }
            InnerBlock.Intersect(new Rectangle(1, 1, Constants.PROJ_WIDTH - 2, Constants.PROJ_HEIGHT - 2));

            OuterBorder = WholeBlock.Clone();
            OuterBorder.Exclude(InnerBlock);

            Top = InnerBlock.Clone();
            Top.Translate(0, -Constants.BLOCK_HEIGHT);
            Top.Intersect(InnerBlock);

            Left = InnerBlock.Clone();
            Left.Exclude(Top);
            Top.Translate(0, 1);
            Left.Exclude(Top);
            Top.Translate(0, -1);

            Right = Left.Clone();
            Left.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));
            Right.Intersect(new Rectangle(Constants.PROJ_WIDTH / 2 + 1, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));

            InnerBorder = InnerBlock.Clone();
            InnerBorder.Exclude(Top);
            InnerBorder.Exclude(Left);
            InnerBorder.Exclude(Right);
        }
开发者ID:ZetaTwo,项目名称:Project-Easter-Egg,代码行数:41,代码来源:BlockRegions.cs

示例2: Clipping

        /// <summary>
        /// Initialize a new instance of the Clipping class.
        /// </summary>
        /// <param name="graphics">Graphics context.</param>
        /// <param name="path">Path to clip.</param>
        /// <param name="exclude">Exclude path from clipping.</param>
        public Clipping(Graphics graphics, GraphicsPath path, bool exclude)
        {
            // Cache graphics instance
            _graphics = graphics;

            // Save the existing clipping region
            _previousRegion = _graphics.Clip;

            // Add clipping of path to existing clipping region
            _newRegion = _previousRegion.Clone();

            if (exclude)
                _newRegion.Exclude(path);
            else
                _newRegion.Intersect(path);

            _graphics.Clip = _newRegion;
        }
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:24,代码来源:Clipping.cs

示例3: Paint

		/// <summary>
		/// Paints the shape on the canvas
		/// </summary>
		/// <param name="g"></param>
		/// 

		public override void Paint(System.Drawing.Graphics g)
		{
			g.SmoothingMode = SmoothingMode.AntiAlias;
			Rectangle toggleNode = Rectangle.Empty; //the [+] [-]
			Point[] pts = new Point[12]
				{
					new Point(rectangle.X,rectangle.Y), //0
					new Point(rectangle.X+bshift,rectangle.Y), //1
					new Point(rectangle.Right-bshift,rectangle.Y), //2
					new Point(rectangle.Right,rectangle.Y), //3
					new Point(rectangle.Right,rectangle.Y+bshift), //4
					new Point(rectangle.Right,rectangle.Bottom-bshift), //5
					new Point(rectangle.Right,rectangle.Bottom), //6
					new Point(rectangle.Right-bshift,rectangle.Bottom), //7
					new Point(rectangle.X+bshift,rectangle.Bottom), //8
					new Point(rectangle.X,rectangle.Bottom), //9
					new Point(rectangle.X,rectangle.Bottom - bshift), //10
					new Point(rectangle.X,rectangle.Y+bshift), //11				
			};
			path = new GraphicsPath();
			path.AddBezier(pts[11],pts[0],pts[0],pts[1]);
			path.AddLine(pts[1],pts[2]);
			path.AddBezier(pts[2],pts[3],pts[3],pts[4]);
			path.AddLine(pts[4],pts[5]);
			path.AddBezier(pts[5],pts[6],pts[6],pts[7]);
			path.AddLine(pts[7],pts[8]);
			path.AddBezier(pts[8],pts[9],pts[9],pts[10]);
			path.AddLine(pts[10],pts[11]);
			path.CloseFigure();
			region = new Region(path);

			shapeBrush = new LinearGradientBrush(rectangle,this.shapeColor,Color.WhiteSmoke,0f);
			
			// start Draw Shadow
			shadow = region.Clone();
			shadow.Translate(5, 5);
			

			//add the amount of children
			if (childNodes.Count > 0)
			{
				plus = " [" + childNodes.Count + "]";				
			}
			else
			{
				plus = "";
			}
			
			g.FillRegion(new SolidBrush(Color.Gainsboro), shadow);
			//g.DrawPath(new Pen(Color.Gainsboro,1), shadow);
			//End Draw Shadow

			g.FillRegion(shapeBrush, region);
			
			
            
			if (hovered || isSelected)			
				pen = thickPen;				
			else			
				pen = blackPen;				
			
			g.DrawPath(pen, path);
		
			if (text != string.Empty)
			{
				//g.DrawString(text + plus,font,Brushes.Black, rectangle.X+5,rectangle.Y+5);
				g.DrawString(text,font,Brushes.Black, rectangle.X+5,rectangle.Y+5);
			}

		

			//draw the [+] expansion shape
			if (childNodes.Count > 0)
			{
				switch(site.LayoutDirection)
				{
				
					case TreeDirection.Vertical:
						toggleNode = new Rectangle(Left + this.Width/2 - 5, Bottom, 10, 10);
						break;
					case TreeDirection.Horizontal:
						toggleNode = new Rectangle(Right , Top +Height/2-5 , 10, 10);
						break;
				}
				
                
				//Draw [ ]
				g.FillRectangle(new SolidBrush(Color.White), toggleNode);
				g.DrawRectangle(blackPen, toggleNode);
                
				//Draw -
				g.DrawLine(blackPen, (toggleNode.X + 2), (toggleNode.Y + (toggleNode.Height / 2)), (toggleNode.X + (toggleNode.Width - 2)), (toggleNode.Y + (toggleNode.Height / 2)) );
                
				if (!this.Expanded)
//.........这里部分代码省略.........
开发者ID:gblosser,项目名称:OpenNlp,代码行数:101,代码来源:SimpleRectangle.cs

示例4: CreateFromDesktopImageInClippedRegion

        public static BitmapPosData CreateFromDesktopImageInClippedRegion(Region rg, Point[] ptPath)
        {
            Console.WriteLine("CopyDesktopImageToClippedRegion");

            BitmapPosData data = null;
            int screenX;
            int screenY;
            IntPtr hBmp;
            IntPtr hdcScreen = GetDC(GetDesktopWindow());
            IntPtr hdcCompatible = CreateCompatibleDC(hdcScreen);

            screenX = GetSystemMetrics(0);
            screenY = GetSystemMetrics(1);
            hBmp = CreateCompatibleBitmap(hdcScreen, screenX, screenY);

            if (hBmp != IntPtr.Zero)
            {
                IntPtr hOldBmp = (IntPtr)SelectObject(hdcCompatible, hBmp);
                BitBlt(hdcCompatible, 0, 0, screenX, screenY, hdcScreen, 0, 0, 13369376);

                SelectObject(hdcCompatible, hOldBmp);
                DeleteDC(hdcCompatible);
                ReleaseDC(GetDesktopWindow(), hdcScreen);

                Bitmap bmpDt = System.Drawing.Image.FromHbitmap(hBmp);
                Graphics gd = Graphics.FromImage(bmpDt);
                RectangleF rc = rg.GetBounds(gd);
                Bitmap bmpClip = new Bitmap((int)rc.Width, (int)rc.Height);
                Graphics gt = Graphics.FromImage(bmpClip);
                Region rgnTempPict = rg.Clone();
                rgnTempPict.Translate(-rc.X, -rc.Y);
                gt.SetClip(rgnTempPict, System.Drawing.Drawing2D.CombineMode.Replace);
                RectangleF rc2 = rg.GetBounds(gt);
                gt.DrawImage(bmpDt, new Rectangle(0, 0, bmpClip.Width, bmpClip.Height), new Rectangle((int)rc.X, (int)rc.Y, (int)rc.Width, (int)rc.Height), GraphicsUnit.Pixel);
                for (int i = 0; i < ptPath.Length; i++)
                {
                    ptPath[i].Offset((int)-rc.X, (int)-rc.Y);
                }
                data = new BitmapPosData(bmpClip, rgnTempPict.Clone(), new Point(0, 0), ptPath);
                rgnTempPict.Dispose();

                gd.Dispose();
                gt.Dispose();

                DeleteObject(hBmp);
                GC.Collect();
            }
            return data;
        }
开发者ID:stndstn,项目名称:InkNote,代码行数:49,代码来源:BitmapPosData.cs

示例5: PdnRegion

 public PdnRegion(Region region, bool takeOwnership)
 {
     if (takeOwnership)
     {
         this.gdiRegion = region;
     }
     else
     {
         this.gdiRegion = region.Clone();
     }
 }
开发者ID:BackupTheBerlios,项目名称:molecule-svn,代码行数:11,代码来源:PdnRegion.cs

示例6: UseClipping

 /// <summary>
 /// Initialize a new instance of the UseClipping class.
 /// </summary>
 /// <param name="g">Graphics instance.</param>
 /// <param name="region">Clipping region.</param>
 public UseClipping(Graphics g, Region region)
 {
     _g = g;
     _old = g.Clip;
     Region clip = _old.Clone();
     clip.Intersect(region);
     _g.Clip = clip;
 }
开发者ID:routd1,项目名称:ProjectHurricane,代码行数:13,代码来源:Office2007Helpers.cs

示例7: CopyDesktopImageInClippedRegion

        public void CopyDesktopImageInClippedRegion(Region rg, Point[] ptPath)
        {
            Console.WriteLine("CopyDesktopImageToClippedRegion");

            int screenX;
            int screenY;
            IntPtr hBmp;
            IntPtr hdcScreen = GetDC(GetDesktopWindow());
            IntPtr hdcCompatible = CreateCompatibleDC(hdcScreen);

            screenX = GetSystemMetrics(0);
            screenY = GetSystemMetrics(1);
            hBmp = CreateCompatibleBitmap(hdcScreen, screenX, screenY);

            if (hBmp != IntPtr.Zero)
            {
                IntPtr hOldBmp = (IntPtr)SelectObject(hdcCompatible, hBmp);
                BitBlt(hdcCompatible, 0, 0, screenX, screenY, hdcScreen, 0, 0, 13369376);

                SelectObject(hdcCompatible, hOldBmp);
                DeleteDC(hdcCompatible);
                ReleaseDC(GetDesktopWindow(), hdcScreen);

                Bitmap bmpDt = System.Drawing.Image.FromHbitmap(hBmp);
                Graphics gd = Graphics.FromImage(bmpDt);
                RectangleF rc = rg.GetBounds(gd);
                Bitmap bmpClip = new Bitmap((int)rc.Width, (int)rc.Height);
                Graphics gt = Graphics.FromImage(bmpClip);
                Region rgnTempPict = rg.Clone();
                rgnTempPict.Translate(-rc.X, -rc.Y);
                gt.SetClip(rgnTempPict, System.Drawing.Drawing2D.CombineMode.Replace);
                RectangleF rc2 = rg.GetBounds(gt);
                gt.DrawImage(bmpDt, new Rectangle(0, 0, bmpClip.Width, bmpClip.Height), new Rectangle((int)rc.X, (int)rc.Y, (int)rc.Width, (int)rc.Height), GraphicsUnit.Pixel);
                for (int i = 0; i < ptPath.Length; i++)
                {
                    ptPath[i].Offset((int)-rc.X, (int)-rc.Y);
                }
                mCopiedBmpData = new FormNote.BitmapPosData(bmpClip, rgnTempPict.Clone(), new Point(0, 0), ptPath);
                /*
                //temp image for moving (transparent)
                if (mPickedBmpDataTmp != null)
                {
                    mPickedBmpDataTmp.Dispose();
                    mPickedBmpDataTmp = null;
                }
                mPickedBmpDataTmp = new BitmapPosData();
                mPickedBmpDataTmp.location = mPickedBmpData.location;
                mPickedBmpDataTmp.region = mPickedBmpData.region.Clone();
                mPickedBmpDataTmp.bmp = new Bitmap(mPickedBmpData.bmp);
                for (int y = 0; y < mPickedBmpDataTmp.bmp.Height; y++)
                {
                    for (int x = 0; x < mPickedBmpDataTmp.bmp.Width; x++)
                    {
                        Color c = mPickedBmpDataTmp.bmp.GetPixel(x, y);
                        Color cc = Color.FromArgb(127, c.R, c.G, c.B);
                        mPickedBmpDataTmp.bmp.SetPixel(x, y, cc);
                    }
                }
                */
                rgnTempPict.Dispose();

                gd.Dispose();
                gt.Dispose();

                DeleteObject(hBmp);
                GC.Collect();
            }
        }
开发者ID:stndstn,项目名称:InkNote,代码行数:68,代码来源:Palette.cs

示例8: InvalidateOverlays

 public void InvalidateOverlays(Region screenRegion)
 {
     for (int i = this.overlayList.Count - 1; i >= 0; i--)
     {
         Control control = this.overlayList[i] as Control;
         if (control != null)
         {
             Rectangle bounds = control.Bounds;
             bounds.Location = control.PointToScreen(control.Location);
             using (Region region = screenRegion.Clone())
             {
                 region.Intersect(bounds);
                 region.Translate(-bounds.X, -bounds.Y);
                 control.Invalidate(region);
             }
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:18,代码来源:DesignerFrame.cs

示例9: SetClip

        public void SetClip(Region region, CombineMode combineMode)
        {
            // We need to reset the clip that is active now so that the graphic
            // states are correct when we set them.
            ResetClip ();

            switch (combineMode)
            {
            case CombineMode.Replace:
                // Set our clip region by cloning the region that is passed for now
                clipRegion = region.Clone ();
                break;
            case CombineMode.Intersect:

                clipRegion.Intersect (region);

                break;
            case CombineMode.Union:

                clipRegion.Union (region);

                break;
            case CombineMode.Exclude:

                clipRegion.Exclude (region);

                break;
            case CombineMode.Xor:

                clipRegion.Xor (region);

                break;
            default:
                throw new NotImplementedException ("SetClip for CombineMode " + combineMode + " not implemented");
            }

            //Unlike the current path, the current clipping path is part of the graphics state.
            //Therefore, to re-enlarge the paintable area by restoring the clipping path to a
            //prior state, you must save the graphics state before you clip and restore the graphics
            //state after you’ve completed any clipped drawing.
            context.SaveState ();
            if (clipRegion.IsEmpty) {
                context.ClipToRect (CGRect.Empty);
            } else {
                //context.ClipToRect ((RectangleF)clipRegion.regionObject);
                context.AddPath (clipRegion.regionPath);
                context.ClosePath ();
                context.Clip ();
            }
            clipSet++;
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:51,代码来源:Graphics.cs

示例10: PushClip

		/// <summary>
		/// Pushes the current clip onto the clip stack and sets clip of the graphics context to
		/// the intersection of the current clip and the given clip.
		/// </summary>
		/// <remarks>
		/// The intersection of the current local clip and the new local clip is also pushed onto
		/// the local clip stack.
		/// </remarks>
		/// <param name="aClip">The clip to push.</param>
		public virtual void PushClip(Region aClip) {
			RectangleF newLocalClip = RectangleF.Intersect(LocalClip, aClip.GetBounds(graphics));
			localClipStack.Push(newLocalClip);

			Region currentClip = Graphics.Clip;
			clipStack.Push(currentClip);
			aClip = aClip.Clone();
			aClip.Intersect(currentClip);
			Graphics.Clip = aClip;
		}
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:19,代码来源:PPaintContext.cs

示例11: DrawRegions

		private void DrawRegions( Graphics g, int offset, string s, Region r1, Region r2, Region r3)
		{
			using (Pen p = new Pen(Color.Black))
			{
				using (Brush b1 = new SolidBrush(Color.Red), b2 = new SolidBrush(Color.Green), bl = new SolidBrush(Color.Blue))
				{
					Region region1 = r1.Clone();
					Region region2 = r2.Clone();
					Region region3 = r3.Clone();
					int x = (offset%4) * 110;
					int y = (int)offset / 4*80;
					g.DrawString(s,Font, bl, x, y);
					region1.Translate(x, y + 20);
					region2.Translate(x, y + 20);
					region3.Translate(x + 55, y + 20);
					g.FillRegion(b1,region1);
					g.DrawRectangle(p, Rectangle.Truncate(region1.GetBounds(g)));
					g.FillRegion(b2,region2);
					g.DrawRectangle(p, Rectangle.Truncate(region2.GetBounds(g)));
					g.FillRegion(b1,region3);
					g.DrawRectangle(p, Rectangle.Truncate(region3.GetBounds(g)));
				}
			}
		}
开发者ID:hitswa,项目名称:winforms,代码行数:24,代码来源:FormsTest.cs

示例12: MapChanged

        // Called whenever the map display changes.
        void MapChanged(Region regionChanged)
        {
            if (regionChanged == null) {
                // null region means everything.
                MarkAllInvalid();
            }

            if (allInvalid)
                return;     // nothing more to do.

            // Copy the region and transform to bitmap coords.
            Region copy = regionChanged.Clone();
            copy.Transform(matTransform);

            // Union with the invalid region.
            if (allValid) {
                allValid = false;
                invalidRegion = regionChanged;
            }
            else
                invalidRegion.Union(regionChanged);
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:23,代码来源:ViewCache.cs

示例13: MultiCombinedPathRegion

		public void MultiCombinedPathRegion ()
		{
			// note: seems identical to PathRegion but it test another code path inside libgdiplus
			Region r1 = new Region (sp1);
			r1.Xor (sp2);
			Region r2 = new Region (sp2);
			r2.Complement (sp1);

			Region r = r1.Clone ();
			r.Union (r2);
			RegionData data = r.GetRegionData ();
			Assert.IsNotNull (data.Data, "Data");
			Region region = new Region (data);
			Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:RegionDataTest.cs

示例14: SelectInternal

	// Uses the current selection positions to set what is selected in drawLayout
	// Sets the update to redraw only the characters that have changed
	internal override void SelectInternal(int start, int length)
	{
		if (start == selectionStartActual && length == selectionLengthActual)
		{
			return;
		}
		if (!IsHandleCreated)
		{
			return;
		}
		Region newRegion = new Region(RectangleF.Empty);
		selectionStartActual = start;
		selectionLengthActual = length;
		for (int i = 0; i < Text.Length; i++) 
		{
			bool selected = (i>=GetSelectionStart() && i < GetSelectionStart() + GetSelectionLength());
			layout.Items[i].selected = selected;
			Rectangle b = layout.Items[i].bounds;
			b = new Rectangle(b.Left, b.Top, b.Width, b.Height + 1);
			if (selected)
			{
				newRegion.Union(b);
			}
		}
		// Find the region we need to redraw by Xoring with old
		if (selectedRegion != null)
		{
			Region redrawRegion = newRegion.Clone();
			redrawRegion.Xor(selectedRegion);
			redrawRegion.Translate(-XViewOffset, -YViewOffset);
			// Only allow updates in the TextDrawArea
			redrawRegion.Intersect(new Region(TextDrawArea));
			AddUpdate(redrawRegion);
		}
		else
		{
			AddUpdate(newRegion);
		}
		selectedRegion = newRegion;

	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:43,代码来源:TextBox.cs

示例15: PushClip

        /// <summary>
        /// Pushes the current clip onto the clip stack and sets clip of the graphics context to
        /// the intersection of the current clip and the given clip.
        /// </summary>
        /// <remarks>
        /// The intersection of the current local clip and the new local clip is also pushed onto
        /// the local clip stack.
        /// </remarks>
        /// <param name="aClip">The clip to push.</param>
        public virtual void PushClip(Region aClip)
        {
            RectangleF aClipBounds = aClip.GetBounds(graphics.Graphics);
            RectangleF transformedClipBounds = Graphics.Matrix.Transform(aClipBounds);
            aClip = new Region(new Rectangle((int)Math.Floor(transformedClipBounds.X),
                (int)Math.Floor(transformedClipBounds.Y),
                (int)Math.Ceiling(transformedClipBounds.Width),
                (int)Math.Ceiling(transformedClipBounds.Height)));

            // Push the untransformed clip onto the local clip stack so that it will be transformed
            // when the matrix is pushed.
            RectangleF newLocalClip = PUtil.IntersectionOfRectangles(LocalClip, aClipBounds);
            localClipStack.Push(newLocalClip);

            // Push the transformed clip onto the clip stack since the graphics objec does not
            // contain a matrix and will not do the transforming itself.
            Region currentClip = Graphics.Clip;
            clipStack.Push(currentClip);
            aClip = aClip.Clone();
            aClip.Intersect(currentClip);
            Graphics.Clip = aClip;
        }
开发者ID:bearstampede,项目名称:piccolo2d,代码行数:31,代码来源:PPaintContext.cs


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