Exemple #1
0
        public TimingsEditor(MainWindow parent, SharedDisposable <RegistryKey> monitorKey, bool isCopy, string encodedMonitor, byte[] encodedGlasses)
        {
            InitializeComponent();
            listWaveforms.DataSource = defaultGlassesCmds;

            this.parent       = parent;
            this.monitorKey   = monitorKey;
            this.previousName = isCopy ? null : encodedMonitor;

            if (encodedMonitor != null)
            {
                this.textDisplayTimings.Text = encodedMonitor;
            }
            if (encodedGlasses != null)
            {
                this.textGlassesTimings.Text = StructureExtensions.ByteArrayToString(encodedGlasses);
            }

            if (encodedMonitor != null)
            {
                btnDecode_Click(btnDecodeDisplayTimings, null);
            }
            if (encodedGlasses != null)
            {
                btnDecode_Click(btnDecodeGlassesTimings, null);
            }

            UpdateListBoxButtons();
            UpdateSliderParams();
        }
Exemple #2
0
 private void btnEncode_Click(object sender, EventArgs e)
 {
     if (sender == btnEncodeDisplayTimings)
     {
         var timings = GetMonitorTimings();
         textDisplayTimings.Text = StructureExtensions.ByteArrayToString(timings.ToByteArray());
     }
     else if (sender == btnEncodeGlassesTimings)
     {
         var timings = GetGlassesTimings();
         textGlassesTimings.Text = StructureExtensions.ByteArrayToString(timings.ToByteArray());
     }
 }
Exemple #3
0
        public static GlassesTimings CreateFromByteArray(byte[] bytes)
        {
            var timingsStr     = new GlassesTimings();
            var requiredLength = Marshal.SizeOf(timingsStr);

            if (bytes.Length != requiredLength)
            {
                throw new ArgumentException(String.Format("Encoded glasses timing parameters must be {0} bytes long: {1}",
                                                          requiredLength, StructureExtensions.ByteArrayToString(bytes)));
            }

            timingsStr = StructureExtensions.ToStructure <GlassesTimings>(bytes);
            return(timingsStr);
        }
Exemple #4
0
        private bool ApplyChangesAndNotify()
        {
            try
            {
                var monitorTimings = StructureExtensions.ByteArrayToString(GetMonitorTimings().ToByteArray());
                var glassesTimings = GetGlassesTimings().ToByteArray();

                if (previousName == null || !previousName.Equals(monitorTimings, StringComparison.OrdinalIgnoreCase))
                {
                    if (monitorKey.Value.GetValue(monitorTimings) != null)
                    {
                        var dlgRes = MessageBox.Show("This monitor timing already exists. Do you wish to overwrite it?",
                                                     "Overwrite monitor timing?", MessageBoxButtons.YesNo);
                        if (dlgRes != DialogResult.Yes)
                        {
                            return(false);
                        }
                    }
                }

                monitorKey.Value.SetValue(monitorTimings, glassesTimings, RegistryValueKind.Binary);
                if (previousName != null && !previousName.Equals(monitorTimings, StringComparison.OrdinalIgnoreCase))
                {
                    monitorKey.Value.DeleteValue(previousName, false);
                }

                parent.TimingChangedCallback(previousName, monitorTimings);
                previousName = monitorTimings;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error writing new values to registry");
                return(false);
            }
        }