packages/MaterialDesignThemes.2.5.1/src/net45/Screen.cs

(开头部分) 15KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Windows;

namespace MaterialDesignThemes.Wpf
{
    ///<summary>
    /// Represents a display device or multiple display devices on a single system.
    /// Based on http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Screen.cs
    /// </summary>
    internal class Screen
    {
        private static class NativeMethods
        {
            private const string User32 = "user32.dll";

            [DllImport(User32, ExactSpelling = true, CharSet = CharSet.Auto)]
            [ResourceExposure(ResourceScope.None)]
            public static extern int GetSystemMetrics(int nIndex);

            [DllImport(User32, CharSet = CharSet.Auto)]
            [ResourceExposure(ResourceScope.None)]
            public static extern bool GetMonitorInfo(HandleRef hmonitor, [In, Out]MONITORINFOEX info);

            [DllImport(User32, ExactSpelling = true)]
            [ResourceExposure(ResourceScope.None)]
            public static extern bool EnumDisplayMonitors(HandleRef hdc, COMRECT rcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);

            [DllImport(User32, ExactSpelling = true)]
            [ResourceExposure(ResourceScope.None)]
            public static extern IntPtr MonitorFromPoint(POINTSTRUCT pt, int flags);

            [DllImport(User32, ExactSpelling = true)]
            [ResourceExposure(ResourceScope.None)]
            public static extern IntPtr MonitorFromRect(ref RECT rect, int flags);

            public delegate bool MonitorEnumProc(IntPtr monitor, IntPtr hdc, IntPtr lprcMonitor, IntPtr lParam);

            [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)]
            public class MONITORINFOEX
            {
                internal int cbSize = Marshal.SizeOf(typeof(MONITORINFOEX));
                internal RECT rcMonitor = new RECT();
                internal RECT rcWork = new RECT();
                internal int dwFlags = 0;
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
                internal char[] szDevice = new char[32];
            }

            [StructLayout(LayoutKind.Sequential)]
            public struct RECT
            {
                public int left;
                public int top;
                public int right;
                public int bottom;
后面还有 350 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。