static SystemScreen() { DPI = GetDPI(); LogicArea = GetLogicArea(); LogicWorkArea = GetLogicWorkArea(); PhysicalArea = GetPhysicalArea(); }
/// <summary> /// 获取系统当前设置的DPI信息 /// </summary> /// <returns></returns> private static ScreenDPI GetDPI() { ScreenDPI dpi = new ScreenDPI(); using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi.X = graphics.DpiX; dpi.Y = graphics.DpiY; } return(dpi); }