Пример #1
0
 /// <summary>
 ///     Returns the corresponding <see cref="DisplayDevice"/> instance
 /// </summary>
 /// <returns>An instance of <see cref="DisplayDevice"/>, or null</returns>
 public DisplayDevice ToDisplayDevice()
 {
     return
         (DisplayAdapter.GetDisplayAdapters()
          .SelectMany(adapter => adapter.GetDisplayDevices())
          .FirstOrDefault(device => device.DevicePath.Equals(DevicePath)));
 }
Пример #2
0
 /// <summary>
 ///     Returns the corresponding DisplayDevice instances
 /// </summary>
 /// <returns>An enumerable list of DisplayDevices</returns>
 public IEnumerable <DisplayDevice> ToDisplayDevices()
 {
     return
         (DisplayAdapter.GetDisplayAdapters()
          .SelectMany(adapter => adapter.GetDisplayDevices())
          .Where(device => device.DisplayName.Equals(DisplayName)));
 }
Пример #3
0
        private static void DeviceContext()
        {
            var navigation = new Dictionary <object, Action>
            {
                {
                    "DeviceContext: Display Adapters",
                    () =>
                    ConsoleNavigation.PrintObject(DisplayAdapter.GetDisplayAdapters().ToArray(),
                                                  display =>
                                                  ConsoleNavigation.PrintObject(display.GetDisplayDevices(),
                                                                                "Display.GetDisplayDevices()"),
                                                  "DisplayAdapter.GetDisplayAdapters()", "Select an adapter to show connected devices.")
                },
                {
                    "DeviceContext: Connected Displays",
                    () =>
                    ConsoleNavigation.PrintObject(Display.GetDisplays().ToArray(),
                                                  display => ConsoleNavigation.PrintObject(display.CurrentSetting, () =>
                    {
                        ConsoleNavigation.PrintObject(
                            display.GetPossibleSettings()
                            .OrderByDescending(
                                setting =>
                                (ulong)setting.Resolution.Height * (ulong)setting.Resolution.Width)
                            .Take(10)
                            .ToArray(),
                            setting => { display.SetSettings(new DisplaySetting(setting), true); },
                            "Display.GetValidSettings()", "Select a display setting to apply and enable.");
                    }, "Display.CurrentSetting", ""),
                                                  "Display.GetDisplays()", "Select a display to show current settings.")
                },
                {
                    "DeviceContext: Disconnected Displays",
                    () =>
                    ConsoleNavigation.PrintObject(UnAttachedDisplay.GetUnAttachedDisplays().ToArray(), display =>
                    {
                        ConsoleNavigation.PrintObject(
                            display.GetPossibleSettings()
                            .OrderByDescending(
                                setting =>
                                (ulong)setting.Resolution.Height * (ulong)setting.Resolution.Width)
                            .Take(10)
                            .ToArray(), setting =>
                        {
                            display.Enable(new DisplaySetting(setting));
                            DisplaySetting.ApplySavedSettings();
                        }, "Display.GetValidSettings()", "Select a display setting to apply and enable.");
                    }, "UnAttachedDisplay.GetUnAttachedDisplays()",
                                                  "Select an unattached display to show possible display settings to activate.")
                },
                {
                    "DeviceContext: Disable All Except Primary",
                    () =>
                    {
                        var displays = Display.GetDisplays().ToArray();
                        foreach (var display in displays.Where(display => !display.IsGDIPrimary))
                        {
                            display.Disable(false);
                        }
                        DisplaySetting.ApplySavedSettings();
                    }
                },
                {
                    "DeviceContext: Enable All",
                    () =>
                    {
                        var displays = UnAttachedDisplay.GetUnAttachedDisplays().ToArray();
                        foreach (var display in displays)
                        {
                            display.Enable(new DisplaySetting(display.GetPreferedSetting()));
                        }
                        DisplaySetting.ApplySavedSettings();
                    }
                }
            };

            ConsoleNavigation.PrintNavigation(navigation, "DeviceContext functions",
                                              "Select a DeviceContext sample.");
        }
Пример #4
0
 /// <summary>
 ///     Gets the corresponding DisplayAdapter instance
 /// </summary>
 /// <returns>An instance of DisplayAdapter, or null</returns>
 public DisplayAdapter ToDisplayAdapter()
 {
     return
         (DisplayAdapter.GetDisplayAdapters()
          .FirstOrDefault(adapter => DevicePath.StartsWith("\\\\?\\" + adapter.DevicePath.Replace("\\", "#"))));
 }
Пример #5
0
        private static void Main(string[] args)
        {
            _writer = new StreamWriter(new FileStream(
                                           string.Format("HeliosDisplayManagement.Reporting.{0}.log", Process.GetCurrentProcess().Id),
                                           FileMode.CreateNew));

            try
            {
                Dump(DisplayAdapter.GetDisplayAdapters(), "WindowsDisplayAPI.DisplayAdapter.GetDisplayAdapters()");
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(Display.GetDisplays(), "WindowsDisplayAPI.Display.GetDisplays()", new[]
                {
                    new Tuple <Func <Display, object>, string>(display => display.GetPossibleSettings(),
                                                               "GetPossibleSettings()")
                });
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(UnAttachedDisplay.GetUnAttachedDisplays(),
                     "WindowsDisplayAPI.UnAttachedDisplay.GetUnAttachedDisplays()");
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(PathDisplayAdapter.GetAdapters(),
                     "WindowsDisplayAPI.DisplayConfig.PathDisplayAdapter.GetAdapters()",
                     new[]
                {
                    new Tuple <Func <PathDisplayAdapter, object>, string>(adapter => adapter.ToDisplayAdapter(),
                                                                          "ToDisplayAdapter()")
                });
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(PathDisplaySource.GetDisplaySources(),
                     "WindowsDisplayAPI.DisplayConfig.PathDisplaySource.GetDisplaySources()", new[]
                {
                    new Tuple <Func <PathDisplaySource, object>, string>(source => source.ToDisplayDevices(),
                                                                         "ToDisplayDevices()")
                });
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(PathDisplayTarget.GetDisplayTargets(),
                     "WindowsDisplayAPI.DisplayConfig.PathDisplayTarget.GetDisplayTargets()", new[]
                {
                    new Tuple <Func <PathDisplayTarget, object>, string>(target => target.ToDisplayDevice(),
                                                                         "ToDisplayDevice()")
                });
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                if (PathInfo.IsSupported)
                {
                    Dump(PathInfo.GetActivePaths(), "WindowsDisplayAPI.DisplayConfig.PathInfo.GetActivePaths()", null,
                         2);
                }
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(LogicalGPU.GetLogicalGPUs(), "NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs()", null, 1);
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(PhysicalGPU.GetPhysicalGPUs(), "NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs()");
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(NvAPIWrapper.Display.Display.GetDisplays(), "NvAPIWrapper.Display.Display.GetDisplays()", new[]
                {
                    new Tuple <Func <NvAPIWrapper.Display.Display, object>, string>(
                        display => display.GetSupportedViews(),
                        "GetSupportedViews()")
                });
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays(),
                     "NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays()");
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(NvAPIWrapper.Display.PathInfo.GetDisplaysConfig(),
                     "NvAPIWrapper.Display.PathInfo.GetDisplaysConfig()",
                     null, 3);
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            try
            {
                Dump(GridTopology.GetGridTopologies(), "NvAPIWrapper.Mosaic.GridTopology.GetGridTopologies()", null, 3);
            }
            catch (Exception e)
            {
                WriteException(e);
            }


            try
            {
                Dump(Profile.GetAllProfiles(), "HeliosDisplayManagement.Shared.Profile.GetAllProfiles()", null, 99);
            }
            catch (Exception e)
            {
                WriteException(e);
            }

            _writer.Flush();
            _writer.Close();
            _writer.Dispose();

            Console.WriteLine(@"Done, press enter to exit.");
            Console.ReadLine();
        }