Пример #1
0
    // </snippet12>

// The following code example demonstrates how use the Data from
    // one region to set the Data for another region. This example is designed
    // to be used with Windows Forms. To run this example paste
    // it into a form and handle the form's Paint event
    // by calling the DemonstrateRegionData2 method, passing e as PaintEventArgs.
    // <snippet13>
    private void DemonstrateRegionData2(PaintEventArgs e)
    {
        //Create a simple region.
        Region region1 = new Region(new Rectangle(10, 10, 100, 100));

        // Extract the region data.
        System.Drawing.Drawing2D.RegionData region1Data = region1.GetRegionData();
        byte[] data1;
        data1 = region1Data.Data;

        // Create a second region.
        Region region2 = new Region();

        // Get the region data for the second region.
        System.Drawing.Drawing2D.RegionData region2Data = region2.GetRegionData();

        // Set the Data property for the second region to the Data from the first region.
        region2Data.Data = data1;

        // Construct a third region using the modified RegionData of the second region.
        Region region3 = new Region(region2Data);

        // Dispose of the first and second regions.
        region1.Dispose();
        region2.Dispose();

        // Call ExcludeClip passing in the third region.
        e.Graphics.ExcludeClip(region3);

        // Fill in the client rectangle.
        e.Graphics.FillRectangle(Brushes.Red, this.ClientRectangle);

        region3.Dispose();
    }
Пример #2
0
	public RegionData Clone() 
	{
		RegionData rd = new RegionData();
		if ( data != null )
		{
			rd.data = (byte[]) data.Clone();
		}
		return rd ;
	}
Пример #3
0
		public Region (RegionData rgnData)
		{
			if (rgnData == null)
				throw new ArgumentNullException ("rgnData");
			// a NullReferenceException can be throw for rgnData.Data.Length (if rgnData.Data is null) just like MS
			if (rgnData.Data.Length == 0)
				throw new ArgumentException ("rgnData");
			Status status = GDIPlus.GdipCreateRegionRgnData (rgnData.Data, rgnData.Data.Length, out nativeRegion);
			GDIPlus.CheckStatus (status);
		}
 public Region(RegionData rgnData)
 {
     if (rgnData == null)
     {
         throw new ArgumentNullException("rgnData");
     }
     IntPtr zero = IntPtr.Zero;
     int status = SafeNativeMethods.Gdip.GdipCreateRegionRgnData(rgnData.Data, rgnData.Data.Length, out zero);
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
     this.SetNativeRegion(zero);
 }
Пример #5
0
    //</snippet11>


// The following code example demonstrates how to construct a Region
    // using the RegionData class. This example is designed to be used with Windows
    // Forms. To run this example paste it into a form and handle the form's Paint event
    // by calling the DemonstrateRegionData method, passing e as PaintEventArgs.
    // <snippet12>
    private void DemonstrateRegionData(PaintEventArgs e)
    {
        //Create a simple region.
        Region region1 = new Region(new Rectangle(10, 10, 100, 100));

        // Extract the region data.
        System.Drawing.Drawing2D.RegionData region1Data =
            region1.GetRegionData();

        // Create a new region using the region data.
        Region region2 = new Region(region1Data);

        // Dispose of the first region.
        region1.Dispose();

        // Call ExcludeClip passing in the second region.
        e.Graphics.ExcludeClip(region2);

        // Fill in the client rectangle.
        e.Graphics.FillRectangle(Brushes.Red, this.ClientRectangle);

        region2.Dispose();
    }
Пример #6
0
		public RegionData GetRegionData()
		{
			int size, filled;			
			
			Status status = GDIPlus.GdipGetRegionDataSize (nativeRegion, out size);                  
                        GDIPlus.CheckStatus (status);                      
                        
                        byte[] buff = new byte [size];			
                        
			status = GDIPlus.GdipGetRegionData (nativeRegion, buff, size, out filled);
			GDIPlus.CheckStatus (status);                      
			
			RegionData rgndata = new RegionData();
			rgndata.Data = buff;
			
			return rgndata;
		}
Пример #7
0
		public Region (RegionData region_data) : this((geom.Area)null)
		{
			throw new NotImplementedException ();
		}
Пример #8
0
 public PdnRegion(RegionData regionData)
 {
     this.gdiRegion = new Region(regionData);
 }
Пример #9
0
	/*
	   Region Constructor from given RegionData:
	    The region data is parsed 
	    and operations are evaluated
	    on the returned region .
	 */
	internal Region ConstructRegion ( RegionData other ) 
	{
		return Evaluate( other.data ); // other.Data );
	}
Пример #10
0
        public Region(RegionData rgnData) {
            if (rgnData == null)
                throw new ArgumentNullException("rgnData");
            IntPtr region = IntPtr.Zero;

            int status = SafeNativeMethods.Gdip.GdipCreateRegionRgnData(rgnData.Data,
                                                         rgnData.Data.Length, 
                                                         out region);

            if (status != SafeNativeMethods.Gdip.Ok)
                throw SafeNativeMethods.Gdip.StatusException(status);

            SetNativeRegion(region);
        }
Пример #11
0
	public Region(RegionData otherRgnData)
	{
		if(otherRgnData == null)
		{
			throw new ArgumentNullException("rgnData", "Argument cannot be null");
		}
		Region r = otherRgnData.ConstructRegion ( otherRgnData ) ;
		this.rects = r.rects ;
		this.extent = r.extent ;
		this.rgnData = r.GetRegionData() ;
	}
Пример #12
0
	public Region(RectangleF rect)
	{
		rgnData = new RegionData( rect );
		if (rect.Width < 0)
			rect = new RectangleF(rect.Right, rect.Top, -rect.Width, rect.Height);
		if (rect.Height < 0)
			rect = new RectangleF(rect.Left, rect.Bottom, rect.Width, -rect.Height);

		if(rect.Width != 0 || rect.Height != 0)
		{
			extent = rect;
			rects = new RectangleF[1];
			rects[0] = rect;
		}
		else
		{
			// extent is already empty(0,0,0,0)
			rects = new RectangleF[0];
		}
	}
Пример #13
0
	public Region(GraphicsPath path)
	{
		if(path == null)
		{
			throw new ArgumentNullException("path", "Argument cannot be null");
		}
		rgnData = new RegionData( path );
	}
Пример #14
0
	// Constructors.
	public Region()
	{
		rgnData = new RegionData() ;
		MakeInfinite();
	}