System.Drawing.IDeviceContext.ReleaseHdc()

Here are the examples of the csharp api class System.Drawing.IDeviceContext.ReleaseHdc() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

1. Example

Project: TaskScheduler
Source File: SafeHandles.cs
protected override bool ReleaseHandle()
		{
			if (idc != null)
				idc.ReleaseHdc();
			return true;
		}

2. Example

Project: audio-switcher
Source File: ToolStripNativeRenderer.cs
private Padding GetThemeMargins(IDeviceContext dc, MarginTypes marginType)
        {
            
            try
            {
                IntPtr hDC = dc.GetHdc();

                MARGINS margins;
                if (DllImports.GetThemeMargins(_renderer.Handle, hDC, _renderer.Part, _renderer.State, (int)marginType, IntPtr.Zero, out margins) == 0)
                    return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);

                return new Padding(0);
            }
            finally
            {
                dc.ReleaseHdc();
            }
        }

3. Example

Project: TraceLab
Source File: Glass.cs
public static Size MeasureCompositedText(IDeviceContext dc, string text, Font font, TextFormatFlags /n ..... /n //View Source file for more details /n }

4. Example

Project: LiteDevelop
Source File: NativeToolStripRenderer.cs
Padding GetThemeMargins(IDeviceContext dc, MarginTypes marginType)
        {
            NativeMethods.MARGINS margins;
            try
            {
                IntPtr hDC = dc.GetHdc();
                if (0 == NativeMethods.GetThemeMargins(renderer.Handle, hDC, renderer.Part, renderer.State, (int)marginType, IntPtr.Zero, out margins))
                    return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
                return new Padding(0);
            }
            finally
            {
                dc.ReleaseHdc();
            }
        }

5. Example

Project: simpleDLNA
Source File: ToolStripRealSystemRenderer.cs
private Padding GetThemeMargins(IDeviceContext dc,
                                    MarginProperty marginType)
    {
      NativeMethods.MARGINS margins;
      try {
        var hDC = dc.GetHdc();
        var rv = NativeMethods.GetThemeMargins(
          renderer.Handle,
          hDC,
          renderer.Part,
          renderer.State,
          (int)marginType,
          IntPtr.Zero,
          out margins);
        if (rv == 0) {
          return new Padding(
            margins.cxLeftWidth,
            margins.cyTopHeight,
            margins.cxRightWidth,
            margins.cyBottomHeight);
        }
        return new Padding(0);
      }
      catch (Exception) {
        return renderer.GetMargins(dc, marginType);
      }
      finally {
        dc.ReleaseHdc();
      }
    }

6. Example

Project: TraceLab
Source File: Glass.cs
public static void DrawCompositedText(IDeviceContext dc, string text, Font font, Rectangle bounds, P/n ..... /n //View Source file for more details /n }