title: Unfocus live-updating chart
body: <p>I have a project which consists of two forms, <code>MainForm</code> and <code>CrossCorrPlotForm</code>. On <code>CrossCorrPlotForm</code>, I have two <code>charts</code> (<code>CrossCorrExpChart</code> and <code>CrossCorrRefChart</code>) which I enabled scroll wheel zooming on, using the code described <a href="https://stackoverflow.com/questions/13584061/how-to-enable-zooming-in-microsoft-chart-control-by-using-mouse-wheel">here</a> and <a href="https://stackoverflow.com/questions/16787050/enabling-mouse-wheel-zooming-in-a-microsoft-chart-control">here</a>.</p>
  
  <p>Everything was working perfectly fine, until I added another <code>chart</code> (<code>histChart</code>), on <code>MainForm</code>, which is updated on each frame incoming from a camera (15-20 FPS), using a <code>BackgroundWorker</code> to collect and plot the data from the images. Now, both my charts on <code>CrossCorrPlotChart</code> are not zoomable anymore.</p>
  
  <p>I presume this has something to do with the live-updating chart taking back the focus on each update. I tried adding <code>histChart.Focus = false</code> in the code but to no avail, as it seems "Control.Focused is read-only".</p>
  
  <p>Does anyone have an idea how to make my <code>charts</code> zoomable again ?</p>
  
  <p>Thanks</p>
  
  <p>EDIT : Here is the code for the <code>BackgroundWorker</code> that updates <code>chartHist</code> : </p>
  
  <pre><code>    private void OnFrameReceived(Frame frame)
      {
          bgw1.RunWorkerAsync(frame);
      }
  
      private void bgw1_DoWork(object s, DoWorkEventArgs e)
      {
          Frame frame = (Frame)e.Argument;
          myBitmap = null;
          try
          {
              frame.Fill(ref myBitmap);
              mycamera.QueueFrame(frame);
              SaveBitmap = myBitmap.Clone(cloneRect, myBitmap.PixelFormat);
              BitmapToPrint = myBitmap.Clone(cloneRect, myBitmap.PixelFormat);
          }
          catch {}
      }
  
      private void bgw1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {
          if (this.InvokeRequired)
          {
              BeginInvoke((Action)(() =&gt; bgw1_RunWorkerCompleted(sender, e)));
          }
          else
          {
              new Thread(() =&gt;
              {
                  Thread.CurrentThread.IsBackground = true;
                  DataFromBitmap DataFromBitmapHist = new DataFromBitmap(SaveBitmap.Clone(cloneRect, SaveBitmap.PixelFormat));
                  PixelColorCount = DataFromBitmapHist.ColorCountOutput();
              }).Start();
  
              chartHist.Titles["Title2"].Visible = false;
              chartHist.Series["Pixel count"].Points.Clear();
  
              //Plotting the pixel counter, to detect saturation
              for (int i = 0; i &lt; PixelColorCount.Length; i++)
              {
                  chartHist.Series["Pixel count"].Points.AddXY(i, PixelColorCount[i]);
              }
  
              //If there are saturated pixels : toggle a title on chartHist to warn the user
              if (PixelColorCount.Last() &gt; 1)
              {
                  chartHist.Titles["Title1"].Visible = false;
                  chartHist.Titles["Title2"].Visible = true;
              }
              else
              {
                  chartHist.Titles["Title1"].Visible = true;
                  chartHist.Titles["Title2"].Visible = false;
              }
          }
      }
  </code></pre>
  
  <p>NOTES : </p>
  
  <ul>
  <li><code>OnFrameReceived</code> is a function from the API of the camera, it contains code that fires when a <code>Frame</code> is received from the camera.</li>
  <li><code>frame.Fill</code> puts the image contained in the <code>Frame</code> object in a <code>Bitmap</code>.</li>
  <li><code>mycamera.QueueFrame</code> sends back the <code>Frame</code> object to the camera, to receive a new image.</li>
  <li>I had to use multiple threads, because using the UI thread too much resulted in blocking the reception from the camera.</li>
  </ul>