Example #1
0
        private void HandleAcceptExecuted(object obj)
        {
            if (!Directory.Exists(_edidFolder))
            {
                Directory.CreateDirectory(_edidFolder);
            }

            string file = Filename + Extension;
            string path = Path.Combine(_edidFolder, file);

            switch (Extension)
            {
            case ".bin":
                EDID.SaveToHex(path);
                break;

            case ".dat":
                EDID.SaveToDat(path);
                break;

            default:
                EDID.SaveToTxt(path);
                break;
            }
            Messenger <Prompts> .Invoke(Prompts.None);
        }
Example #2
0
        private void HandleFromProgrammerExecuted(object obj)
        {
            byte[] buffer = IoC.Get <Programmer>().ReadEDID();
            if (buffer == null || buffer.Length < 1)
            {
                IoC.Get <PromptProgrammerViewModel>().State = ProgrammerStates.ReadFailed;
                Messenger <Prompts> .Invoke(Prompts.Programmer);

                return;
            }

            EDID edid = new EDID(buffer);

            if (edid == null)
            {
                IoC.Get <PromptProgrammerViewModel>().State = ProgrammerStates.ReadFailed;
                Messenger <Prompts> .Invoke(Prompts.Programmer);

                return;
            }

            EDID = edid;
            IoC.Get <PromptProgrammerViewModel>().State = ProgrammerStates.ReadSuccess;
            Messenger <Prompts> .Invoke(Prompts.Programmer);
        }
            public static Descriptor GetDescriptor(EDID parent, int firstByte)
            {
                if (parent.Buffer[firstByte] > 0)
                {
                    return(new DetailedTimingDescriptor(parent, firstByte));
                }
                else
                {
                    switch (parent.Buffer[firstByte + 3])
                    {
                    case 0xff:
                        return(new StringDescriptor(parent, firstByte, 0xff));

                    case 0xfe:
                        return(new StringDescriptor(parent, firstByte, 0xfe));

                    case 0xfc:
                        return(new StringDescriptor(parent, firstByte, 0xfc));

                    case 0xfd:
                        return(new MonitorRangeLimitsDescriptor(parent, firstByte));

                    case 0xfb:
                        return(new AdditionalWhitePointDescriptor(parent, firstByte));

                    case 0xfa:
                        return(new CustomTiming(parent, firstByte));
                    }
                };
                return(new Descriptor(parent, firstByte, 0));
            }
Example #4
0
                public WhitePointDescriptor(EDID parent, int firstByte)
                {
                    _parent    = parent;
                    _firstByte = firstByte;

                    _parent.SetBit(_firstByte + 1, 7, false);
                    _parent.SetBit(_firstByte + 1, 6, false);
                    _parent.SetBit(_firstByte + 1, 5, false);
                    _parent.SetBit(_firstByte + 1, 4, false);
                }
 public Descriptor(EDID parent, int firstByte, int type)
 {
     _parent    = parent;
     _firstByte = firstByte;
     _type      = type;
     if (_type > 0)
     {
         Apply();
     }
 }
        private void HandleImportExecuted(object obj)
        {
            // For now fall back to standard windows dialoges; might be replaced with custom dialogs later on
            OpenFileDialog ofd = new OpenFileDialog
            {
                Title            = LocalString("OFD_Title"),
                InitialDirectory = _edidFolder,
                Multiselect      = false
            };
            string filter = LocalString("OFD_Filter");

            try
            {
                filter     = filter.Trim();
                ofd.Filter = filter;
            }
            catch (Exception ex) { }
            if (ofd.ShowDialog() == true)
            {
                if (!EDID.IsEDIDFile(ofd.FileName))
                {
                    MessageBox.Show(LocalString("OFD_NoEDID"), LocalString("Error"), MessageBoxButton.OK);
                    return;
                }

                string destPath = Path.Combine(_edidFolder, Path.GetFileName(ofd.FileName));
                if (File.Exists(destPath))
                {
                    var replace = MessageBox.Show(LocalString("OFD_Exists"), LocalString("Error"), MessageBoxButton.YesNoCancel);
                    if (replace == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                    if (replace == MessageBoxResult.No)
                    {
                        destPath = destPath.GetNextFilename();
                    }
                }
                File.Copy(ofd.FileName, destPath, true);

                if (!_edidFiles.Contains(Path.GetFileName(destPath)))
                {
                    _edidFiles.Add(Path.GetFileName(destPath));
                }
            }
        }
 internal AdditionalWhitePointDescriptor(EDID edid, BitAwareReader reader, int offset, int internalOffset)
     : base(edid, reader, offset)
 {
     if (internalOffset == 0)
     {
         IsValid = Reader.ReadBytes(Offset, 5).SequenceEqual(FixedHeader);
         if (IsValid)
         {
             NextDescriptor = new AdditionalWhitePointDescriptor(edid, reader, offset, internalOffset + 5);
         }
     }
     else
     {
         IsValid         = true;
         _internalOffset = internalOffset + 5;
     }
 }
        private void HandleAcceptExecuted(object obj)
        {
            Messenger <Prompts> .Invoke(Prompts.None);

            if (SelectedFile == null)
            {
                return;
            }

            EDID edid = EDID.FromFile(Path.Combine(_edidFolder, SelectedFile));

            if (edid == null)
            {
                return;
            }

            IoC.Get <EDIDViewModel>().EDID     = edid;
            IoC.Get <EDIDViewModel>().Filename = SelectedFile;
        }
 public SurroundTopologyDisplay(GridTopologyDisplay display)
 {
     DisplayId      = display.DisplayDevice.DisplayId;
     Rotation       = display.Rotation.ToRotation();
     Overlap        = new Point(display.Overlap.HorizontalOverlap, display.Overlap.VerticalOverlap);
     PixelShiftType = display.PixelShiftType;
     try
     {
         var bytes = display.DisplayDevice.PhysicalGPU.ReadEDIDData(display.DisplayDevice.Output);
         DisplayName = new EDID(bytes).Descriptors
                       .Where(descriptor => descriptor is StringDescriptor)
                       .Cast <StringDescriptor>()
                       .FirstOrDefault(descriptor => descriptor.Type == StringDescriptorType.MonitorName)?.Value;
     }
     catch
     {
         // ignored
     }
 }
Example #10
0
 internal StringDescriptor(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
     IsValid = true;
     if (Reader.ReadBytes(Offset, 5).SequenceEqual(MonitorNameHeader))
     {
         Type = StringDescriptorType.MonitorName;
     }
     else if (Reader.ReadBytes(Offset, 5).SequenceEqual(MonitorSerialHeader))
     {
         Type = StringDescriptorType.MonitorSerialNumber;
     }
     else if (Reader.ReadBytes(Offset, 5).SequenceEqual(UnspecifiedStringHeader))
     {
         Type = StringDescriptorType.UnspecifiedText;
     }
     else
     {
         IsValid = false;
     }
 }
        private void HandleLoadedExecuted(object obj)
        {
            if (Loading)
            {
                return;
            }

            Loading = true;
            Task.Factory.StartNew(() =>
            {
                if (!Directory.Exists(_edidFolder))
                {
                    Directory.CreateDirectory(_edidFolder);
                }

                var files = new DirectoryInfo(_edidFolder).GetFiles().Where(fi => EDID.IsEDIDFile(fi.FullName)).Select(fi => fi.Name);
                App.Current.Dispatcher.BeginInvoke(new Action(() => { EDIDFiles = new ObservableCollection <string>(files); }), null);
                App.Current.Dispatcher.BeginInvoke(new Action(() => { Loading = false; }), null);
            });
        }
Example #12
0
        private void HandleDisplayInfo(DisplayInfo di)
        {
            switch (_await)
            {
            case EDIDAwait.ScreenSelectLoad:
                if (di.Additional == null)
                {
                    break;
                }

                EDID edid = (EDID)di.Additional;
                if (edid == null)
                {
                    break;
                }

                EDID = edid;
                break;

            case EDIDAwait.ScreenSelectOverride:
                break;
            }
        }
Example #13
0
        private static void BrowseEDID(byte[] bytes, string title)
        {
            var edid = new EDID(bytes);

            ConsoleNavigation.PrintNavigation(new Dictionary <object, Action>
            {
                {
                    "View General Information",
                    () => { ConsoleNavigation.PrintObject(edid, "EDID"); }
                },
                {
                    "View Display Parameters",
                    () => { ConsoleNavigation.PrintObject(edid.DisplayParameters, "EDID.DisplayParameters"); }
                },
                {
                    "View Display Chromaticity Coordinates",
                    () =>
                    {
                        ConsoleNavigation.PrintObject(edid.DisplayParameters.ChromaticityCoordinates,
                                                      "EDID.DisplayParameters.ChromaticityCoordinates");
                    }
                },
                {
                    "View Descriptors",
                    () => { ConsoleNavigation.PrintObject(edid.Descriptors.ToArray(), "EDID.Descriptors"); }
                },
                {
                    "View Extensions",
                    () => { ConsoleNavigation.PrintObject(edid.Extensions.ToArray(), "EDID.Extensions"); }
                },
                {
                    "View Timings",
                    () => { ConsoleNavigation.PrintObject(edid.Timings.ToArray(), "EDID.Timings"); }
                }
            }, title, "Select an option to browse the EDID information.");
        }
Example #14
0
 internal ManufacturerDescriptor(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
     IsValid = Reader.ReadBytes(Offset, 3).Any(b => b == 0) &&
               (Reader.ReadByte(Offset + 3) < 16) &&
               (Reader.ReadByte(Offset + 4) == 0);
 }
 internal AdditionalWhitePointDescriptor(EDID edid, BitAwareReader reader, int offset)
     : this(edid, reader, offset, 0)
 {
 }
Example #16
0
 public override string ToString()
 {
     return(EDID.ToString());
 }
Example #17
0
 internal DetailedTimingDescriptor(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
     IsValid = Reader.ReadInt(Offset, 0, 2 * 8) != 0;
 }
Example #18
0
 public CustomTiming(EDID parent, int firstByte) : base(parent, firstByte, 0xfa)
 {
 }
Example #19
0
 internal BlockMapExtension(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
     IsValid = Type == ExtensionType.BlockMap;
 }
 internal MonitorRangeLimitsDescriptor(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
     IsValid = Reader.ReadBytes(Offset, 5).SequenceEqual(FixedHeader);
 }
Example #21
0
 internal UnknownExtension(EDID edid, BitAwareReader reader, int offset) : base(edid, reader, offset)
 {
 }
 internal AdditionalStandardTimingDescriptor(EDID edid, BitAwareReader reader, int offset)
     : base(edid, reader, offset)
 {
     IsValid = Reader.ReadBytes(Offset, 5).SequenceEqual(FixedHeader);
 }
Example #23
0
 public AdditionalWhitePointDescriptor(EDID parent, int firstByte) : base(parent, firstByte, 0xfb)
 {
     _whitePointDescriptors    = new WhitePointDescriptor[2];
     _whitePointDescriptors[1] = new WhitePointDescriptor(parent, firstByte + 5);
     _whitePointDescriptors[2] = new WhitePointDescriptor(parent, firstByte + 10);
 }