diff --git a/HeliosDisplayManagement.Reporting/App.config b/HeliosDisplayManagement.Reporting/App.config new file mode 100644 index 0000000..b50c74f --- /dev/null +++ b/HeliosDisplayManagement.Reporting/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/FodyWeavers.xml b/HeliosDisplayManagement.Reporting/FodyWeavers.xml new file mode 100644 index 0000000..c6e1b7c --- /dev/null +++ b/HeliosDisplayManagement.Reporting/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj b/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj new file mode 100644 index 0000000..bd39f29 --- /dev/null +++ b/HeliosDisplayManagement.Reporting/HeliosDisplayManagement.Reporting.csproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + {76DF2BCF-911B-4820-B63E-8F3468DB5E79} + Exe + HeliosDisplayManagement.Reporting + HeliosDisplayManagement.Reporting + v4.6.2 + 512 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\packages\Costura.Fody.3.1.0\lib\net46\Costura.dll + + + ..\packages\NvAPIWrapper.Net.0.6.0.4\lib\net45\NvAPIWrapper.dll + + + + + ..\packages\WindowsDisplayAPI.1.1.0.2\lib\net45\WindowsDisplayAPI.dll + + + + + + + + + + + + + {1cacda43-01c7-4cd4-bf6e-9421a29510fc} + HeliosDisplayManagement.Shared + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/Program.cs b/HeliosDisplayManagement.Reporting/Program.cs new file mode 100644 index 0000000..0102395 --- /dev/null +++ b/HeliosDisplayManagement.Reporting/Program.cs @@ -0,0 +1,327 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using WindowsDisplayAPI; +using WindowsDisplayAPI.DisplayConfig; +using HeliosDisplayManagement.Shared; +using NvAPIWrapper.GPU; +using NvAPIWrapper.Mosaic; + +namespace HeliosDisplayManagement.Reporting +{ + internal class Program + { + private static StreamWriter _writer; + + private static void Dump( + IEnumerable items, + string title, + Tuple, string>[] actions = null, + int deepIn = 0) + { + Console.WriteLine(title); + _writer.WriteLine(title + new string('=', Console.BufferWidth - title.Length)); + var totalTime = TimeSpan.Zero; + var stopWatch = new Stopwatch(); + stopWatch.Start(); + + foreach (var item in items) + { + var actionResults = actions?.Select(tuple => + new Tuple(tuple.Item2, tuple.Item1.Invoke(item))).ToArray(); + stopWatch.Stop(); + WriteObject(item, 0, stopWatch.Elapsed, actionResults, deepIn); + totalTime += stopWatch.Elapsed; + stopWatch.Reset(); + stopWatch.Start(); + } + + stopWatch.Stop(); + totalTime += stopWatch.Elapsed; + Console.Write(@"-- Elapsed: {0}", totalTime); + _writer.WriteLine(@"-- Total Elapsed: {0}", totalTime); + Console.WriteLine(); + _writer.WriteLine(); + } + + 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, 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, string>(adapter => adapter.ToDisplayAdapter(), + "ToDisplayAdapter()") + }); + } + catch (Exception e) + { + WriteException(e); + } + + try + { + Dump(PathDisplaySource.GetDisplaySources(), + "WindowsDisplayAPI.DisplayConfig.PathDisplaySource.GetDisplaySources()", new[] + { + new Tuple, string>(source => source.ToDisplayDevices(), + "ToDisplayDevices()") + }); + } + catch (Exception e) + { + WriteException(e); + } + + try + { + Dump(PathDisplayTarget.GetDisplayTargets(), + "WindowsDisplayAPI.DisplayConfig.PathDisplayTarget.GetDisplayTargets()", new[] + { + new Tuple, 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, 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(); + } + + private static void WriteException(Exception ex) + { + _writer.WriteLine("{0} - Error: {1}", ex.GetType().Name, ex.Message); + } + + private static void WriteObject( + object obj, + int padding = 0, + TimeSpan elapsed = default(TimeSpan), + Tuple[] extraProperties = null, + int deepIn = 0) + { + try + { + if (padding == 0) + { + if (!elapsed.Equals(TimeSpan.Zero)) + { + var elapsedFormated = string.Format("_{0}_", elapsed); + _writer.WriteLine(elapsedFormated + + new string('_', Console.BufferWidth - elapsedFormated.Length)); + } + else + { + _writer.WriteLine(new string('_', Console.BufferWidth)); + } + _writer.WriteLine("({0}) {{", obj.GetType().Name); + } + + if (obj.GetType().IsValueType || obj is string) + { + _writer.WriteLine(new string(' ', padding * 3 + 2) + obj); + } + else if (obj is IEnumerable) + { + var i = 0; + + foreach (var arrayItem in (IEnumerable) obj) + { + _writer.WriteLine(new string(' ', padding * 3 + 2) + "[{0}]: ({1}) {{", i, arrayItem?.GetType().Name); + WriteObject(arrayItem, padding + 1, default(TimeSpan), null, deepIn - 1); + _writer.WriteLine(new string(' ', padding * 3 + 2) + "},"); + i++; + } + } + else + { + foreach (var propertyInfo in obj.GetType().GetProperties().OrderBy(info => info.Name)) + { + if (propertyInfo.CanRead) + { + object value; + + try + { + value = propertyInfo.GetValue(obj); + } + catch (TargetInvocationException ex) + { + value = ex.InnerException?.GetType().ToString(); + } + catch (Exception ex) + { + value = ex.GetType().ToString(); + } + + if (deepIn > 0 && + value != null && + !value.GetType().IsValueType && + value.GetType() != typeof(string)) + { + _writer.WriteLine(new string(' ', padding * 3 + 2) + "{0}: ({1}) {{", propertyInfo.Name, propertyInfo.PropertyType.Name); + WriteObject(value, padding + 1, default(TimeSpan), null, deepIn - 1); + _writer.WriteLine(new string(' ', padding * 3 + 2) + "},"); + } + else + { + _writer.WriteLine( + $"{new string(' ', padding * 3 + 2)}{propertyInfo.Name}: {value ?? "[NULL]"},"); + } + } + } + } + + if (extraProperties != null) + { + foreach (var extraProperty in extraProperties) + { + _writer.WriteLine(new string(' ', padding * 3 + 2) + "{0}: ({1}) {{", extraProperty.Item1, extraProperty.Item2?.GetType().Name); + WriteObject(extraProperty.Item2, padding + 1, default(TimeSpan), null, deepIn); + _writer.WriteLine(new string(' ', padding * 3 + 2) + "},"); + } + } + + if (padding == 0) + { + _writer.WriteLine("};"); + _writer.WriteLine(new string('_', Console.BufferWidth)); + } + } + catch (Exception ex) + { + WriteException(ex); + } + } + } +} \ No newline at end of file diff --git a/HeliosDisplayManagement.Reporting/Properties/AssemblyInfo.cs b/HeliosDisplayManagement.Reporting/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..37177d2 --- /dev/null +++ b/HeliosDisplayManagement.Reporting/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HeliosDisplayManagement.Reporting")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HeliosDisplayManagement.Reporting")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("76df2bcf-911b-4820-b63e-8f3468db5e79")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/HeliosDisplayManagement.Reporting/packages.config b/HeliosDisplayManagement.Reporting/packages.config new file mode 100644 index 0000000..09e9ce8 --- /dev/null +++ b/HeliosDisplayManagement.Reporting/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/HeliosDisplayManagement.sln b/HeliosDisplayManagement.sln index a3ecf28..f4d05dc 100644 --- a/HeliosDisplayManagement.sln +++ b/HeliosDisplayManagement.sln @@ -1,6 +1,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2003 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeliosDisplayManagement", "HeliosDisplayManagement\HeliosDisplayManagement.csproj", "{608D941A-B431-400C-A91D-C6F971C29577}" EndProject @@ -14,6 +16,7 @@ Project("{E729F059-12D4-455F-A2A4-FDA8DD25E08A}") = "HeliosDisplayManagement.Set {1CACDA43-01C7-4CD4-BF6E-9421A29510FC} = {1CACDA43-01C7-4CD4-BF6E-9421A29510FC} {55D4FF65-EDC7-48EF-933E-B6E7F3809B68} = {55D4FF65-EDC7-48EF-933E-B6E7F3809B68} EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeliosDisplayManagement.Reporting", "HeliosDisplayManagement.Reporting\HeliosDisplayManagement.Reporting.csproj", "{76DF2BCF-911B-4820-B63E-8F3468DB5E79}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -35,9 +38,15 @@ Global {1CACDA43-01C7-4CD4-BF6E-9421A29510FC}.Release|AnyCPU.Build.0 = Release|Any CPU {8B2508A9-8167-46D0-83C7-D24BE7407910}.Debug|AnyCPU.ActiveCfg = x64 Release {8B2508A9-8167-46D0-83C7-D24BE7407910}.Release|AnyCPU.ActiveCfg = x64 Release - {8B2508A9-8167-46D0-83C7-D24BE7407910}.Release|AnyCPU.Build.0 = x64 Release + {76DF2BCF-911B-4820-B63E-8F3468DB5E79}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU + {76DF2BCF-911B-4820-B63E-8F3468DB5E79}.Debug|AnyCPU.Build.0 = Debug|Any CPU + {76DF2BCF-911B-4820-B63E-8F3468DB5E79}.Release|AnyCPU.ActiveCfg = Release|Any CPU + {76DF2BCF-911B-4820-B63E-8F3468DB5E79}.Release|AnyCPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2F7B8012-31EA-46A2-9B55-7BE90D969F61} + EndGlobalSection EndGlobal