示例#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);
 }
示例#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();
     }
 }
示例#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);
        }
示例#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);
 }
示例#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);
     }
 }
示例#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);
 }
示例#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);
 }
示例#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);
 }
示例#9
0
 public static extern int GetDeviceCaps(Standard.SafeDC hdc, Standard.DeviceCap nIndex);
示例#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);
示例#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);
示例#12
0
 private static extern IntPtr _SelectObjectSafeHBITMAP(Standard.SafeDC hdc, Standard.SafeHBITMAP hgdiobj);
示例#13
0
 private static extern IntPtr _SelectObject(Standard.SafeDC hdc, IntPtr hgdiobj);