Beispiel #1
0
        public static Size GetSize(System.Windows.Forms.Screen screen)
        {
            //uint xDpi, yDpi;
            ScreenExtensions.Dpi dpi = screen.GetDpi(DpiType.Effective);
            var size = new Size();

            size.Width  = screen.Bounds.Width / (dpi.x / 96.0);
            size.Height = screen.Bounds.Height / (dpi.y / 96.0);
            size.XDPI   = dpi.x;
            size.YDPI   = dpi.y;
            return(size);
        }
Beispiel #2
0
        public static double ToDips(System.Windows.Forms.Screen screen, double value, DpiDirection dpiDirection = DpiDirection.X)
        {
            ScreenExtensions.Dpi dpi = screen.GetDpi(DpiType.Effective);

            return(value / (dpiDirection == DpiDirection.X ? dpi.x : dpi.y / 96.0));
        }