Ejemplo n.º 1
0
 private void btnDecode_Click(object sender, EventArgs e)
 {
     if (sender == btnDecodeDisplayTimings)
     {
         try
         {
             var timings = MonitorTimings.CreateFromByteArray(StructureExtensions.StringToByteArrayFastest(textDisplayTimings.Text));
             ApplyMonitorTimings(timings);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error parsing encoded display timings");
             return;
         }
     }
     else if (sender == btnDecodeGlassesTimings)
     {
         try
         {
             var timings = GlassesTimings.CreateFromByteArray(StructureExtensions.StringToByteArrayFastest(textGlassesTimings.Text));
             ApplyGlassesTimings(timings);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error parsing encoded glasses timings");
             return;
         }
     }
 }
Ejemplo n.º 2
0
        private void GlassesSlider_ValueChanged(object sender, EventArgs e)
        {
            TrackBar widget = (TrackBar)sender;

            if (suppressValueChangedEvent)
            {
                return;
            }

            suppressValueChangedEvent = true;
            try
            {
                if (widget == sliderX)
                {
                    numX.Value = GlassesTimings.TicksToMicros((UInt32)widget.Value);
                }
                else if (widget == sliderY)
                {
                    numY.Value = GlassesTimings.TicksToMicros((UInt32)widget.Value);
                }
                else if (widget == sliderZ)
                {
                    numZ.Value = GlassesTimings.TicksToMicros((UInt32)widget.Value);
                }
                else if (widget == sliderW)
                {
                    numW.Value = GlassesTimings.TicksToMicros((UInt32)widget.Value);
                }
            }
            finally { suppressValueChangedEvent = false; }
            UpdateSliderParams();
        }
Ejemplo n.º 3
0
        private void GlassesNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            NumericUpDown widget = (NumericUpDown)sender;

            if (suppressValueChangedEvent)
            {
                return;
            }

            suppressValueChangedEvent = true;
            try
            {
                if (widget == numX)
                {
                    sliderX.Value = (int)GlassesTimings.MicrosToTicks(widget.Value);
                }
                else if (widget == numY)
                {
                    sliderY.Value = (int)GlassesTimings.MicrosToTicks(widget.Value);
                }
                else if (widget == numZ)
                {
                    sliderZ.Value = (int)GlassesTimings.MicrosToTicks(widget.Value);
                }
                else if (widget == numW)
                {
                    sliderW.Value = (int)GlassesTimings.MicrosToTicks(widget.Value);
                }
            }
            finally { suppressValueChangedEvent = false; }
            UpdateSliderParams();
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public GlassesTimings GetGlassesTimings()
        {
            var dst = new GlassesTimings();

            dst.z = (UInt32)sliderZ.Value;
            dst.w = (UInt32)sliderW.Value;
            dst.x = (UInt32)sliderX.Value;
            dst.y = (UInt32)sliderY.Value;

            var dataSrc = (ICollection <GlassesCommand>)listWaveforms.DataSource;

            dst.cmd1 = dataSrc.ElementAt(0).cmdIdx;
            dst.cmd2 = dataSrc.ElementAt(1).cmdIdx;
            dst.cmd3 = dataSrc.ElementAt(2).cmdIdx;
            dst.cmd4 = dataSrc.ElementAt(3).cmdIdx;

            return(dst);
        }
Ejemplo n.º 6
0
        private void UpdateSliderParams()
        {
            numX.Maximum = GlassesTimings.TicksToMicros((uint)sliderX.Maximum);
            numY.Maximum = GlassesTimings.TicksToMicros((uint)sliderY.Maximum);
            numZ.Maximum = GlassesTimings.TicksToMicros((uint)sliderZ.Maximum);
            numW.Maximum = GlassesTimings.TicksToMicros((uint)sliderW.Maximum);

            if (numActualRefresh.Value >= 1)
            {
                btnCopyFromRefresh.Enabled = (1 / numActualRefresh.Value) * 1000000 < numZ.Maximum;
            }
            else
            {
                btnCopyFromRefresh.Enabled = false;
            }

            if (sliderZ.Value >= 1)
            {
                btnRescaleOthers.Enabled = sliderX.Value <= sliderZ.Value &&
                                           sliderY.Value <= sliderZ.Value &&
                                           sliderW.Value <= sliderZ.Value;
            }
            else
            {
                btnRescaleOthers.Enabled = false;
            }

            if (sliderW.Maximum == sliderZ.Value &&
                sliderY.Maximum == sliderZ.Value &&
                sliderX.Maximum == sliderZ.Value)
            {
                btnRescaleOthers.Text    = str_ResetScale;
                btnRescaleOthers.Enabled = true;
            }
            else
            {
                btnRescaleOthers.Text = str_Rescale;
            }
        }
Ejemplo n.º 7
0
        public void ApplyGlassesTimings(GlassesTimings tim)
        {
            sliderZ.Maximum = int_DefaultSliderMaximum;
            sliderX.Maximum = sliderZ.Maximum;
            sliderY.Maximum = sliderZ.Maximum;
            sliderW.Maximum = sliderZ.Maximum;

            sliderZ.Value = (int)tim.z;
            sliderW.Value = (int)tim.w;
            sliderX.Value = (int)tim.x;
            sliderY.Value = (int)tim.y;

            var newDataSrc = new GlassesCommand[defaultGlassesCmds.Count()];

            newDataSrc[0] = defaultGlassesCmds.FirstOrDefault(s => s.cmdIdx == tim.cmd1);
            newDataSrc[1] = defaultGlassesCmds.FirstOrDefault(s => s.cmdIdx == tim.cmd2);
            newDataSrc[2] = defaultGlassesCmds.FirstOrDefault(s => s.cmdIdx == tim.cmd3);
            newDataSrc[3] = defaultGlassesCmds.FirstOrDefault(s => s.cmdIdx == tim.cmd4);

            listWaveforms.SelectedIndex = 0;
            listWaveforms.DataSource    = newDataSrc;
            UpdateListBoxButtons();
            UpdateSliderParams();
        }