public ucScopeControls(AcquisitionEngine a, ucPhosphorDisplay v1, ucPhosphorDisplay v2)
        {
            acq = a;
            displayTrigger = v1;
            displayLong = v2;

            InitializeComponent();

            cbTrigger.DisplayMember = "Name";
            cbTrigger.ValueMember = "Name";
            cbTrigger.DataSource = a.TriggerSources;
            cbTrigger.SelectedIndex = 1;
            cbTrigger.SelectedIndexChanged += cbTrigger_SelectedIndexChanged;

            tbAmpPerDiv.Minimum = 0;
            tbSecPerDiv.Minimum = 0;
            tbSecPerDivScnd.Minimum = 0;

            tbAmpPerDiv.Maximum = verticalSteps.Length - 1;
            tbSecPerDiv.Maximum = timeSteps.Length - 1;
            tbSecPerDivScnd.Maximum = timeSteps.Length - 1;

            tbAmpPerDiv.ValueChanged += tbAmpPerDiv_ValueChanged;
            tbSecPerDiv.ValueChanged += tbSecPerDiv_ValueChanged;
            tbSecPerDivScnd.ValueChanged += tbSecPerDivScnd_ValueChanged;

            tbAmpPerDiv.Value = tbAmpPerDiv.Maximum;
            tbSecPerDiv.Value = timeSteps.Count(x => x < 2.0f / 1000);
            tbSecPerDivScnd.Value = timeSteps.Count(x=> x < 100.0f/1000);

            tbSecPerDivScnd_ValueChanged(null, new EventArgs());
            tbSecPerDiv_ValueChanged(null, new EventArgs());
            tbAmpPerDiv_ValueChanged(null, new EventArgs());

            cbAdcSpeed.SelectedIndex = 0;
            cbAdcType.SelectedIndex = 1;
            cbGain.SelectedIndex = 1;
        }
        public PhosphorDisplay()
        {
            InitializeComponent();

            acqEngine = new AcquisitionEngine(new NetStream());
            acqEngine.AcquisitionTime = 0.15f/1000;
            acqEngine.PretriggerTime = 0.0f/1000;

            // Zoom waveform
            displayTrig = new ucPhosphorDisplay();
            displayTrig.channels = 1;

            displayTrig.horizontalScale = (float) (acqEngine.AcquisitionTime/displayTrig.horizontalDivisions/2);
            displayTrig.verticalScale = new float[3] { 0.25f, 1, 1};

            Controls.Add(displayTrig);

            // Triggered waveform
            displayOverview = new ucPhosphorDisplay();
            displayOverview.channels = 1;
            displayOverview.verticalScale= displayTrig.verticalScale;
            displayOverview.horizontalScale = 1.0f;
            displayOverview.lowContrast = true;

            Controls.Add(displayOverview);

            // Measurement "DMM"
            dmm = new ucRmsMeter();
            Controls.Add(dmm);

            // Control panel
            controls = new ucScopeControls(acqEngine, displayTrig, displayOverview);
            Controls.Add(controls);

            this.Layout += Form1_Layout;

            acqEngine.OverviewWaveform += acqEngine_OverviewWaveform;
            acqEngine.TriggeredWaveform += acqEngine_Waveform;

            var t = new Timer();
            t.Tick += (sender, args) =>
                          {
                              if (triggerOk)
                              {
                                  triggerOk = false;

                                  displayTrig.Invalidate();
                              }
                              if(overviewRefresh)
                              {
                                  overviewRefresh = false;

                                  dmm.Invalidate();
                                  displayOverview.Invalidate();
                              }
                          };

            t.Interval = 40; // 25 fps
            t.Start();

            acqEngine.Source.HighresVoltage += voltage =>
                                                   {
                                                       dmm.sixDigitVoltage = voltage;
                                                       dmm.Invalidate();
                                                   };
            this.SizeChanged += Form1_SizeChanged;
        }