星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Drawing;
  3. using System.Runtime.InteropServices;
  4. namespace ComeCapture.Helpers
  5. {
  6. public static class ScreenHelper
  7. {
  8. [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
  9. public static extern IntPtr ReleaseDC(
  10. IntPtr hWnd,
  11. IntPtr hDc
  12. );
  13. [DllImport("gdi32.dll")]
  14. public static extern int GetDeviceCaps(
  15. IntPtr hdc, // handle to DC
  16. int nIndex // index of capability
  17. );
  18. public static System.Drawing.Size GetPhysicalDisplaySize()
  19. {
  20. Graphics g = Graphics.FromHwnd(IntPtr.Zero);
  21. IntPtr desktop = g.GetHdc();
  22. int physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.Desktopvertres);
  23. int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
  24. ReleaseDC(IntPtr.Zero, desktop);
  25. g.Dispose();
  26. return new System.Drawing.Size(physicalScreenWidth, physicalScreenHeight);
  27. }
  28. public enum DeviceCap
  29. {
  30. Desktopvertres = 117,
  31. Desktophorzres = 118
  32. }
  33. public static void ResetScreenScale()
  34. {
  35. using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
  36. {
  37. IntPtr desktop = g.GetHdc();
  38. int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
  39. JieTuWindow.ScreenScale = physicalScreenWidth * 1.0000 / JieTuWindow.ScreenWidth;
  40. g.Dispose();
  41. }
  42. }
  43. }
  44. }