Author: spouliot
Date: 2007-05-30 21:15:22 -0400 (Wed, 30 May 2007)
New Revision: 78286
Modified:
trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing/Graphics.cs
Log:
2007-05-30 Sebastien Pouliot <[EMAIL PROTECTED]>
* Graphics.cs: Refactor [Get|Release]Hdc to get ReleaseHdcInternal
working (as long as the HDC comes from GetHdc).
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2007-05-31
01:14:35 UTC (rev 78285)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2007-05-31
01:15:22 UTC (rev 78286)
@@ -1,3 +1,8 @@
+2007-05-30 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * Graphics.cs: Refactor [Get|Release]Hdc to get ReleaseHdcInternal
+ working (as long as the HDC comes from GetHdc).
+
2007-05-21 Adar Wesley <[EMAIL PROTECTED]>
* Graphics.jvm.cs
Modified: trunk/mcs/class/System.Drawing/System.Drawing/Graphics.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Graphics.cs 2007-05-31
01:14:35 UTC (rev 78285)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Graphics.cs 2007-05-31
01:15:22 UTC (rev 78286)
@@ -52,9 +52,7 @@
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)]
@@ -1771,14 +1769,9 @@
#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)
{
@@ -2040,27 +2033,21 @@
}
[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
@@ -2069,9 +2056,13 @@
[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 ()
{
@@ -2482,6 +2473,7 @@
[EditorBrowsable (EditorBrowsableState.Never)]
public object GetContextInfo ()
{
+ // only known source of information @
http://blogs.wdevs.com/jdunlap/Default.aspx
throw new NotImplementedException ();
}
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches