Ejemplo n.º 1
0
 public static Standard.SafeDC CreateCompatibleDC(Standard.SafeDC hdc)
 {
     Standard.SafeDC edc = null;
     try
     {
         IntPtr zero = IntPtr.Zero;
         if (hdc != null)
         {
             zero = hdc.handle;
         }
         edc = NativeMethods.CreateCompatibleDC(zero);
         if (edc == null)
         {
             Standard.HRESULT.ThrowLastError();
         }
     }
     finally
     {
         if (edc != null)
         {
             edc._created = true;
         }
     }
     if (edc.IsInvalid)
     {
         edc.Dispose();
         throw new SystemException("Unable to create a device context from the specified device information.");
     }
     return(edc);
 }
Ejemplo n.º 2
0
 public static void UpdateLayeredWindow(IntPtr hwnd, Standard.SafeDC hdcDst, ref Standard.POINT pptDst, ref Standard.SIZE psize, Standard.SafeDC hdcSrc, ref Standard.POINT pptSrc, int crKey, ref Standard.BLENDFUNCTION pblend, Standard.ULW dwFlags)
 {
     if (!_UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags))
     {
         Standard.HRESULT.ThrowLastError();
     }
 }
Ejemplo n.º 3
0
        public static IntPtr SelectObject(Standard.SafeDC hdc, IntPtr hgdiobj)
        {
            IntPtr ptr = _SelectObject(hdc, hgdiobj);

            if (ptr == IntPtr.Zero)
            {
                Standard.HRESULT.ThrowLastError();
            }
            return(ptr);
        }
Ejemplo n.º 4
0
 private static int _GetBitDepth()
 {
     if (s_bitDepth == 0)
     {
         using (Standard.SafeDC edc = Standard.SafeDC.GetDesktop())
         {
             s_bitDepth = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.BITSPIXEL) * Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.PLANES);
         }
     }
     return(s_bitDepth);
 }
Ejemplo n.º 5
0
 static DpiHelper()
 {
     using (Standard.SafeDC edc = Standard.SafeDC.GetDesktop())
     {
         int deviceCaps = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.LOGPIXELSX);
         int num2       = Standard.NativeMethods.GetDeviceCaps(edc, Standard.DeviceCap.LOGPIXELSY);
         _transformToDip = Matrix.Identity;
         _transformToDip.Scale(96.0 / ((double)deviceCaps), 96.0 / ((double)num2));
         _transformToDevice = Matrix.Identity;
         _transformToDevice.Scale(((double)deviceCaps) / 96.0, ((double)num2) / 96.0);
     }
 }
Ejemplo n.º 6
0
 public static Standard.SafeHBITMAP CreateDIBSection(Standard.SafeDC hdc, ref Standard.BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset)
 {
     Standard.SafeHBITMAP ehbitmap = null;
     if (hdc == null)
     {
         ehbitmap = _CreateDIBSectionIntPtr(IntPtr.Zero, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset);
     }
     else
     {
         ehbitmap = _CreateDIBSection(hdc, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset);
     }
     if (ehbitmap.IsInvalid)
     {
         Standard.HRESULT.ThrowLastError();
     }
     return(ehbitmap);
 }
Ejemplo n.º 7
0
 public static Standard.SafeDC GetDC(IntPtr hwnd)
 {
     Standard.SafeDC dC = null;
     try
     {
         dC = NativeMethods.GetDC(hwnd);
     }
     finally
     {
         if (dC != null)
         {
             dC.Hwnd = hwnd;
         }
     }
     if (dC.IsInvalid)
     {
         Standard.HRESULT.E_FAIL.ThrowIfFailed();
     }
     return(dC);
 }
Ejemplo n.º 8
0
 public static Standard.SafeDC CreateDC(string deviceName)
 {
     Standard.SafeDC edc = null;
     try
     {
         edc = NativeMethods.CreateDC(deviceName, null, IntPtr.Zero, IntPtr.Zero);
     }
     finally
     {
         if (edc != null)
         {
             edc._created = true;
         }
     }
     if (edc.IsInvalid)
     {
         edc.Dispose();
         throw new SystemException("Unable to create a device context from the specified device information.");
     }
     return(edc);
 }
Ejemplo n.º 9
0
 public static extern int GetDeviceCaps(Standard.SafeDC hdc, Standard.DeviceCap nIndex);
Ejemplo n.º 10
0
 private static extern Standard.SafeHBITMAP _CreateDIBSection(Standard.SafeDC hdc, [In] ref Standard.BITMAPINFO bitmapInfo, int iUsage, out IntPtr ppvBits, IntPtr hSection, int dwOffset);
Ejemplo n.º 11
0
 private static extern bool _UpdateLayeredWindow(IntPtr hwnd, Standard.SafeDC hdcDst, [In] ref Standard.POINT pptDst, [In] ref Standard.SIZE psize, Standard.SafeDC hdcSrc, [In] ref Standard.POINT pptSrc, int crKey, ref Standard.BLENDFUNCTION pblend, Standard.ULW dwFlags);
Ejemplo n.º 12
0
 private static extern IntPtr _SelectObjectSafeHBITMAP(Standard.SafeDC hdc, Standard.SafeHBITMAP hgdiobj);
Ejemplo n.º 13
0
 private static extern IntPtr _SelectObject(Standard.SafeDC hdc, IntPtr hgdiobj);