GetDesktop() 개인적인 메소드

private GetDesktop ( ) : SafeDC
리턴 SafeDC
예제 #1
0
 private static int s_bitDepth;         // = 0;
 private static int _GetBitDepth()
 {
     if (s_bitDepth != 0)
     {
         return(s_bitDepth);
     }
     using (var dc = SafeDC.GetDesktop())
         s_bitDepth = NativeMethods.GetDeviceCaps(dc, DeviceCap.BITSPIXEL) * NativeMethods.GetDeviceCaps(dc, DeviceCap.PLANES);
     return(s_bitDepth);
 }
예제 #2
0
 private static int _GetBitDepth()
 {
     if (Utility.s_bitDepth == 0)
     {
         using (SafeDC desktop = SafeDC.GetDesktop())
         {
             Utility.s_bitDepth = NativeMethods.GetDeviceCaps(desktop, DeviceCap.BITSPIXEL) * NativeMethods.GetDeviceCaps(desktop, DeviceCap.PLANES);
         }
     }
     return(Utility.s_bitDepth);
 }
예제 #3
0
 private static int _GetBitDepth()
 {
     if (s_bitDepth == 0)
     {
         using (SafeDC dc = SafeDC.GetDesktop())
         {
             s_bitDepth = NativeMethodsShell.GetDeviceCaps(dc, DeviceCap.BITSPIXEL) * NativeMethodsShell.GetDeviceCaps(dc, DeviceCap.PLANES);
         }
     }
     return(s_bitDepth);
 }
예제 #4
0
 static DpiHelper()
 {
     using (SafeDC desktop = SafeDC.GetDesktop())
     {
         int deviceCaps  = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX);
         int deviceCaps2 = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY);
         DpiHelper._transformToDip = Matrix.Identity;
         DpiHelper._transformToDip.Scale(96.0 / (double)deviceCaps, 96.0 / (double)deviceCaps2);
         DpiHelper._transformToDevice = Matrix.Identity;
         DpiHelper._transformToDevice.Scale((double)deviceCaps / 96.0, (double)deviceCaps2 / 96.0);
     }
 }
예제 #5
0
		static DpiHelper()
		{
			Class6.yDnXvgqzyB5jw();
			using (SafeDC desktop = SafeDC.GetDesktop())
			{
				int deviceCaps = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX);
				int num = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY);
				DpiHelper._transformToDip = Matrix.Identity;
				DpiHelper._transformToDip.Scale(96 / (double)deviceCaps, 96 / (double)num);
				DpiHelper._transformToDevice = Matrix.Identity;
				DpiHelper._transformToDevice.Scale((double)deviceCaps / 96, (double)num / 96);
			}
		}
예제 #6
0
 static DpiHelper()
 {
     using (var desktop = SafeDC.GetDesktop())
     {
         // Can get these in the static constructor.  They shouldn't vary window to window,
         // and changing the system DPI requires a restart.
         var pixelsPerInchX = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX);
         var pixelsPerInchY = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY);
         _transformToDip = Matrix.Identity;
         _transformToDip.Scale(96d / pixelsPerInchX, 96d / pixelsPerInchY);
         _transformToDevice = Matrix.Identity;
         _transformToDevice.Scale(pixelsPerInchX / 96d, pixelsPerInchY / 96d);
     }
 }
예제 #7
0
        public void Show()
        {
            _VerifyMutability();

            using (Stream imageStream = _GetImageStream())
            {
                Size bitmapSize;
                _hBitmap = _CreateHBITMAPFromImageStream(imageStream, out bitmapSize);

                Point location = new Point(
                    (NativeMethods.GetSystemMetrics(SM.CXSCREEN) - bitmapSize.Width) / 2,
                    (NativeMethods.GetSystemMetrics(SM.CYSCREEN) - bitmapSize.Height) / 2);

                // Pass a null WndProc.  Let the MessageWindow use DefWindowProc.
                _hwndWrapper = new MessageWindow(
                    CS.HREDRAW | CS.VREDRAW,
                    WS.POPUP | WS.VISIBLE,
                    WS_EX.WINDOWEDGE | WS_EX.TOOLWINDOW | WS_EX.LAYERED | (IsTopMost ? WS_EX.TOPMOST : 0),
                    new Rect(location, bitmapSize),
                    "Splash Screen",
                    null);

                byte opacity = (byte)(FadeInDuration > TimeSpan.Zero ? 0 : 255);

                using (SafeDC hScreenDC = SafeDC.GetDesktop())
                {
                    using (SafeDC memDC = SafeDC.CreateCompatibleDC(hScreenDC))
                    {
                        IntPtr hOldBitmap = NativeMethods.SelectObject(memDC, _hBitmap);

                        RECT hwndRect = NativeMethods.GetWindowRect(_hwndWrapper.Handle);

                        POINT         hwndPos  = hwndRect.Position;
                        SIZE          hwndSize = hwndRect.Size;
                        POINT         origin   = new POINT();
                        BLENDFUNCTION bf       = _BaseBlendFunction;
                        bf.SourceConstantAlpha = opacity;

                        NativeMethods.UpdateLayeredWindow(_hwndWrapper.Handle, hScreenDC, ref hwndPos, ref hwndSize, memDC, ref origin, 0, ref bf, ULW.ALPHA);
                        NativeMethods.SelectObject(memDC, hOldBitmap);
                    }
                }

                if (CloseOnMainWindowCreation)
                {
                    Dispatcher.CurrentDispatcher.BeginInvoke(
                        DispatcherPriority.Loaded,
                        (DispatcherOperationCallback) delegate(object splashObj)
                    {
                        var splashScreen = (SplashScreen)splashObj;
                        if (!splashScreen._isClosed)
                        {
                            splashScreen.Close();
                        }
                        return(null);
                    },
                        this);
                }

                _dispatcher = Dispatcher.CurrentDispatcher;
                if (FadeInDuration > TimeSpan.Zero)
                {
                    _fadeInEnd = DateTime.UtcNow + FadeInDuration;
                    _dt        = new DispatcherTimer(FadeInDuration, DispatcherPriority.Normal, _FadeInTick, _dispatcher);
                    _dt.Start();
                }
            }
        }