Exemplo n.º 1
0
        private static void PrintsDescriptors(ILogger logger, DataBlock dataBlock)
        {
            logger.Info("");
            logger.Info($@" Extracted contents:");
            logger.Info($@" ┌{new string('─', 48)}");

            DataSection headerSection = dataBlock.Sections[(int)EdidSection.Header];

            logger.Info($@" │ Header:{'\t'}{'\t'}{string.Join(" ", headerSection.RawData.AsHexadecimal())}");

            DataSection         vendorSection      = dataBlock.Sections[(int)EdidSection.Vendor];
            QueryPropertyResult serialNumberResult = vendorSection.GetProperty(EedidProperty.Edid.Vendor.IdSerialNumber);

            if (serialNumberResult.Success)
            {
                logger.Info($@" │ Serial number:{'\t'}{serialNumberResult.Result.Value}");
            }
            else
            {
                logger.Info($@" │ Serial number:{'\t'}...");
            }

            DataSection versionSection = dataBlock.Sections[(int)EdidSection.Version];

            logger.Info($@" │ Version:{'\t'}{'\t'}{string.Join(" ", versionSection.RawData.AsHexadecimal())}");

            DataSection basicDisplaySection = dataBlock.Sections[(int)EdidSection.BasicDisplay];

            logger.Info($@" │ Basic params:{'\t'}{string.Join(" ", basicDisplaySection.RawData.AsHexadecimal())}");

            DataSection colorCharacteristicsTimingsSection = dataBlock.Sections[(int)EdidSection.ColorCharacteristics];

            logger.Info($@" │ Chroma info:{'\t'}{'\t'}{string.Join(" ", colorCharacteristicsTimingsSection.RawData.AsHexadecimal())}");

            DataSection establishedTimingsSection = dataBlock.Sections[(int)EdidSection.EstablishedTimings];

            logger.Info($@" │ Established:{'\t'}{'\t'}{string.Join(" ", establishedTimingsSection.RawData.AsHexadecimal())}");

            DataSection standardTimingsSection = dataBlock.Sections[(int)EdidSection.StandardTimings];

            logger.Info($@" │ Standard:{'\t'}{'\t'}{string.Join(" ", standardTimingsSection.RawData.AsHexadecimal())}");

            DataSection dataBlocksSection = dataBlock.Sections[(int)EdidSection.DataBlocks];

            logger.Info($@" │ Descriptor 1:{'\t'}{string.Join(" ", ((ReadOnlyCollection<byte>)dataBlocksSection.GetProperty(EedidProperty.Edid.DataBlock.Descriptor1).Result.Value).AsHexadecimal())}");
            logger.Info($@" │ Descriptor 2:{'\t'}{string.Join(" ", ((ReadOnlyCollection<byte>)dataBlocksSection.GetProperty(EedidProperty.Edid.DataBlock.Descriptor2).Result.Value).AsHexadecimal())}");
            logger.Info($@" │ Descriptor 3:{'\t'}{string.Join(" ", ((ReadOnlyCollection<byte>)dataBlocksSection.GetProperty(EedidProperty.Edid.DataBlock.Descriptor3).Result.Value).AsHexadecimal())}");
            logger.Info($@" │ Descriptor 4:{'\t'}{string.Join(" ", ((ReadOnlyCollection<byte>)dataBlocksSection.GetProperty(EedidProperty.Edid.DataBlock.Descriptor4).Result.Value).AsHexadecimal())}");

            DataSection extensionSection = dataBlock.Sections[(int)EdidSection.ExtensionBlocks];

            logger.Info($@" │ Extensions:{'\t'}{'\t'}{string.Join(" ", extensionSection.RawData.AsHexadecimal())}");

            DataSection checksumSection = dataBlock.Sections[(int)EdidSection.Checksum];

            logger.Info($@" │ Checksum:{'\t'}{'\t'}{string.Join(" ", checksumSection.RawData.AsHexadecimal())}");

            logger.Info("");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            EEDID[] instances = EEDID.Instance;
            foreach (var instance in instances)
            {
                //EEDID instance = EEDID.Parse(MacBookPro2018.IntegratedLaptopPanelEdidTable3);

                Console.WriteLine();
                Console.WriteLine(@" Implemented Blocks");
                Console.WriteLine(@" ══════════════════");

                DataBlockCollection blocks = instance.Blocks;
                foreach (KnownDataBlock block in blocks.ImplementedBlocks)
                {
                    Console.WriteLine($@" │ {block}");
                }

                foreach (DataBlock block in blocks)
                {
                    var blockLiteral = $@"{block.Key} Block";

                    Console.WriteLine();
                    Console.WriteLine($@" {blockLiteral}");
                    Console.WriteLine($@" {new string('═', blockLiteral.Length)}");

                    Console.WriteLine();
                    Console.WriteLine(@" Implemented Sections");
                    Console.WriteLine(@" ┌───────────────────");
                    var implSections = instance.Blocks[block.Key].Sections.ImplementedSections;
                    foreach (Enum section in implSections)
                    {
                        Console.WriteLine($@" │ {GetFriendlyName(section)}");
                    }

                    Console.WriteLine();
                    Console.WriteLine(@" Sections");
                    Console.WriteLine(@" ┌───────");
                    BaseDataSectionCollection sections = block.Sections;
                    foreach (DataSection section in sections)
                    {
                        var sectionLiteral = $"{GetFriendlyName(section.Key) } Section";

                        Console.WriteLine($@" │");
                        Console.WriteLine($@" ├ {sectionLiteral}");
                        Console.WriteLine($@" │ ┌{new string('─', sectionLiteral.Length - 1)}");

                        IEnumerable <IPropertyKey> properties = section.ImplementedProperties;
                        foreach (IPropertyKey property in properties)
                        {
                            string       friendlyName = property.GetPropertyName();
                            PropertyUnit valueUnit    = property.PropertyUnit;
                            string       unit         = valueUnit == PropertyUnit.None ? string.Empty : valueUnit.ToString();

                            QueryPropertyResult queryResult  = section.GetProperty(property);
                            PropertyItem        propertyItem = queryResult.Value;
                            object value = propertyItem.Value;
                            if (value == null)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: NULL");
                                continue;
                            }

                            if (value is string)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit}");
                            }
                            else if (value is bool)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit}");
                            }
                            else if (value is double)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit}");
                            }
                            else if (value is byte)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X2}h]");
                            }
                            else if (value is short)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X4}h]");
                            }
                            else if (value is ushort)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X4}h]");
                            }
                            else if (value is int)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X4}h]");
                            }
                            else if (value is uint)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X4}h]");
                            }
                            else if (value is long)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X8}h]");
                            }
                            else if (value is ulong)
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {value}{unit} [{value:X8}h]");
                            }
                            else if (value is PointF)
                            {
                                var pointLiteral = $"{ friendlyName }";
                                Console.WriteLine($@" │ │ {pointLiteral}");
                                Console.WriteLine($@" │ │ ┌{new string('─', pointLiteral.Length - 1)}");
                                Console.WriteLine($@" │ │ │ X: {((PointF)value).X}");
                                Console.WriteLine($@" │ │ │ Y: {((PointF)value).Y}");
                                Console.WriteLine($@" │ │");
                            }
                            else if (value is StandardTimingIdentifierDescriptorItem)
                            {
                                Console.WriteLine($@" │ │ {(StandardTimingIdentifierDescriptorItem)value}");
                            }
                            else if (value.GetType() == typeof(ReadOnlyCollection <byte>))
                            {
                                Console.WriteLine($@" │ │ {friendlyName}: {string.Join(", ", (ReadOnlyCollection<byte>)value)}");
                            }
                            else if (value.GetType() == typeof(ReadOnlyCollection <string>))
                            {
                                Console.WriteLine($@" │ │ {friendlyName}");
                                Console.WriteLine($@" │ │ ┌{new string('─', friendlyName.Length - 1)}");
                                var items = (ReadOnlyCollection <string>)value;
                                foreach (string item in items)
                                {
                                    Console.WriteLine($@" │ │ │ {item}");
                                }
                            }
                            else if (value.GetType() == typeof(ReadOnlyCollection <MonitorResolutionInfo>))
                            {
                                var items = (ReadOnlyCollection <MonitorResolutionInfo>)value;
                                foreach (MonitorResolutionInfo item in items)
                                {
                                    Console.WriteLine($@" │ │ {item}");
                                }
                            }
                            else if (value.GetType() == typeof(SectionPropertiesTable))
                            {
                                Console.WriteLine($@" │ │ {friendlyName}");
                                Console.WriteLine($@" │ │ ┌{new string('─', friendlyName.Length - 1)}");
                                var dataBlockProperties = (SectionPropertiesTable)value;
                                foreach (PropertyItem dataBlockProperty in dataBlockProperties)
                                {
                                    IPropertyKey dataBlockPropertyKey  = (PropertyKey)dataBlockProperty.Key;
                                    string       dataBlockPropertyName = dataBlockPropertyKey.GetPropertyName();

                                    PropertyUnit dataBlockPropertyUnit = dataBlockPropertyKey.PropertyUnit;
                                    string       dataUnit = dataBlockPropertyKey.PropertyUnit == PropertyUnit.None ? string.Empty : dataBlockPropertyUnit.ToString();

                                    object dataBlockPropertyValue = dataBlockProperty.Value;
                                    if (dataBlockPropertyValue.GetType() == typeof(ReadOnlyCollection <byte>))
                                    {
                                        Console.WriteLine($@" │ │ │ {dataBlockPropertyName}: {string.Join(" ", (ReadOnlyCollection<byte>)dataBlockPropertyValue)}");
                                    }
                                    else if (dataBlockPropertyValue.GetType() == typeof(ReadOnlyCollection <string>))
                                    {
                                        var items = (ReadOnlyCollection <string>)dataBlockPropertyValue;
                                        foreach (string item in items)
                                        {
                                            Console.WriteLine($@" │ │ │ {item}");
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine($@" │ │ │ {dataBlockPropertyName}: {dataBlockPropertyValue} {dataUnit}");
                                    }
                                }

                                Console.WriteLine($@" │ │");
                            }
                            else if (value.GetType() == typeof(List <SectionPropertiesTable>))
                            {
                                Console.WriteLine($@" │ │ {friendlyName}");
                                Console.WriteLine($@" │ │ ┌{new string('─', friendlyName.Length - 1)}");
                                var sectionPropertiesCollection = (List <SectionPropertiesTable>)value;
                                foreach (SectionPropertiesTable sectionProperty in sectionPropertiesCollection)
                                {
                                    foreach (PropertyItem dataBlockProperty in sectionProperty)
                                    {
                                        IPropertyKey dataBlockPropertyKey  = (PropertyKey)dataBlockProperty.Key;
                                        string       dataBlockPropertyName = dataBlockPropertyKey.GetPropertyName();

                                        PropertyUnit dataBlockPropertyUnit = dataBlockPropertyKey.PropertyUnit;
                                        string       dataUnit = dataBlockPropertyKey.PropertyUnit == PropertyUnit.None ? string.Empty : dataBlockPropertyUnit.ToString();

                                        object dataBlockPropertyValue = dataBlockProperty.Value;
                                        if (dataBlockPropertyValue.GetType() == typeof(ReadOnlyCollection <string>))
                                        {
                                            Console.WriteLine($@" │ │ │ {dataBlockPropertyName}");
                                            Console.WriteLine($@" │ │ │ ┌{new string('─', dataBlockPropertyName.Length - 1)}");
                                            var items = (ReadOnlyCollection <string>)dataBlockPropertyValue;
                                            foreach (string item in items)
                                            {
                                                Console.WriteLine($@" │ │ │ │ {item}");
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine($@" │ │ │ {dataBlockPropertyName}: {dataBlockPropertyValue} {dataUnit}");
                                        }
                                    }
                                }

                                Console.WriteLine($@" │ │");
                            }
                            else
                            {
                                Console.WriteLine($@" │ │ {friendlyName} > {value}{unit}");
                            }
                        }
                    }

                    Console.WriteLine();
                }
            }

            Console.WriteLine();
            Console.WriteLine(@" > Gets A Single Property Directly From Parsed EDID Data");
            EEDID     parsed    = EEDID.Parse(MacBookPro2018.IntegratedLaptopPanelEdidTable);
            DataBlock edidBlock = parsed.Blocks[KnownDataBlock.EDID];
            BaseDataSectionCollection edidSections  = edidBlock.Sections;
            DataSection         basicDisplaySection = edidSections[(int)KnownEdidSection.BasicDisplay];
            QueryPropertyResult gammaResult         = basicDisplaySection.GetProperty(EedidProperty.Edid.BasicDisplay.Gamma);

            if (gammaResult.Success)
            {
                Console.WriteLine($@"   > Gamma > {gammaResult.Value.Value}");
            }

            Console.ReadLine();
        }