예제 #1
0
        /// <summary>
        /// GetSupportedDisplayModes 获取系统支持的所有的屏幕分辨率的详细信息。
        /// </summary>
        public static List <DisplayMode> GetSupportedDisplayModes()
        {
            List <DisplayMode> list        = new List <DisplayMode>();
            DisplayMode        displayMode = new DisplayMode();

            for (int i = 0; ScreenHelper.EnumDisplaySettings(0, i, ref displayMode); i++)
            {
                list.Add(displayMode);
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// GetSupportedDisplayModes 获取系统支持的屏幕分辨率。
        /// </summary>
        public static List <ScreenResolution> GetSupportedScreenResolutions()
        {
            Dictionary <string, DisplayMode> dic = new  Dictionary <string, DisplayMode>();

            foreach (DisplayMode mode in ScreenHelper.GetSupportedDisplayModes())
            {
                if (mode.dmPelsWidth >= mode.dmPelsHeight)
                {
                    string token = string.Format("{0}*{1}", mode.dmPelsWidth, mode.dmPelsHeight);
                    if (!dic.ContainsKey(token))
                    {
                        dic.Add(token, mode);
                    }
                    else
                    {
                        if (mode.dmBitsPerPel > dic[token].dmBitsPerPel)
                        {
                            dic[token] = mode;
                        }
                        else if (mode.dmBitsPerPel == dic[token].dmBitsPerPel)
                        {
                            if (mode.dmDisplayFrequency > dic[token].dmDisplayFrequency)
                            {
                                dic[token] = mode;
                            }
                        }
                    }
                }
            }

            List <ScreenResolution> list = new List <ScreenResolution>();

            foreach (DisplayMode mode in dic.Values)
            {
                list.Add(mode.GetScreenResolution());
            }
            return(list);
        }
예제 #3
0
 public static void ChangeDisplayMode(DisplayMode displayMode)
 {
     ScreenHelper.ChangeDisplaySettings(ref displayMode, 0);
 }
예제 #4
0
 /// <summary>
 /// CaptureScreen 截取全屏。
 /// </summary>
 public static Bitmap CaptureScreen()
 {
     return(ScreenHelper.CaptureScreen(new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)));
 }