private bool disposed = false;
private static float defDpiX = 0;
private static float defDpiY = 0;
-#if NET_2_0
private IntPtr deviceContextHdc;
-#endif
#if !NET_2_0
[ComVisible(false)]
#endif
public IntPtr GetHdc ()
{
- IntPtr hdc;
- GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
-#if NET_2_0
- deviceContextHdc = hdc;
-#endif
- return hdc;
+ GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out deviceContextHdc));
+ return deviceContextHdc;
}
-
public Color GetNearestColor (Color color)
{
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public void ReleaseHdc (IntPtr hdc)
{
- Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
- GDIPlus.CheckStatus (status);
-#if NET_2_0
- if (hdc == deviceContextHdc)
- deviceContextHdc = IntPtr.Zero;
-#endif
+ ReleaseHdcInternal (hdc);
}
#if NET_2_0
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
public void ReleaseHdc ()
{
- if (deviceContextHdc == IntPtr.Zero)
- throw new ArgumentException ("Invalid Handle");
-
- ReleaseHdc (deviceContextHdc);
+ ReleaseHdcInternal (deviceContextHdc);
}
#endif
- [MonoTODO ("Parameter hdc doesn't map well into libgdiplus")]
+ [MonoLimitation ("Can only be used when hdc was provided by Graphics.GetHdc() method")]
#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Never)]
#else
[SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
public void ReleaseHdcInternal (IntPtr hdc)
{
- throw new NotImplementedException ();
+ Status status = Status.InvalidParameter;
+ if (hdc == deviceContextHdc) {
+ status = GDIPlus.GdipReleaseDC (nativeObject, deviceContextHdc);
+ deviceContextHdc = IntPtr.Zero;
+ }
+ GDIPlus.CheckStatus (status);
}
-
public void ResetClip ()
{
[EditorBrowsable (EditorBrowsableState.Never)]
public object GetContextInfo ()
{
+ // only known source of information @ http://blogs.wdevs.com/jdunlap/Default.aspx
throw new NotImplementedException ();
}
#endif