/// <summary>
        /// Draw the interpolation results.
        /// </summary>
        public void Draw()
        {
            VolumeInterpolation volumeInterpolation = workerThread.GetVolumeInterpolation();
            int scale = volumeInterpolation.GetScale();

            double[] minMax = GetMinMax();

            // draw result for all coordinates
            for (int x = 0; x < volumeInterpolation.Values.GetLength(0); x++)
            {
                for (int y = 0; y < volumeInterpolation.Values.GetLength(1); y++)
                {
                    Rectangle rect = new Rectangle();
                    rect.Width  = scale;
                    rect.Height = scale;
                    byte intensity = (byte)(255 - (255 / (minMax[1] - minMax[0])) * (volumeInterpolation.Values[x, y, speakerIndex, 0] - minMax[0]));
                    rect.Fill = new SolidColorBrush(Color.FromRgb(intensity, intensity, 255));

                    canvas.Children.Add(rect);
                    Canvas.SetLeft(rect, x * scale);
                    Canvas.SetTop(rect, (volumeInterpolation.Values.GetLength(1) - y) * scale);
                }
            }

            // add the current position
            currentPosition        = new Rectangle();
            currentPosition.Width  = scale;
            currentPosition.Height = scale;
            currentPosition.Fill   = Brushes.Orange;
            canvas.Children.Add(currentPosition);
            Canvas.SetLeft(currentPosition, -10);
            Canvas.SetTop(currentPosition, -10);

            workerThread.ResultReady += ResultReady;
        }
 /// <summary>
 /// Update the current position when it changes.
 /// </summary>
 /// <param name="sender">Worker thread.</param>
 /// <param name="e">Event arguments.</param>
 private void ResultReady(object sender, ResultReadyEventArgs e)
 {
     if (e.Result.GetCoordinates().HasValue)
     {
         VolumeInterpolation volumeInterpolation = workerThread.GetVolumeInterpolation();
         int scale = volumeInterpolation.GetScale();
         Canvas.SetLeft(currentPosition, volumeInterpolation.MapCoordinate(e.Result.GetCoordinates().Value.X) * scale);
         Canvas.SetTop(currentPosition, (volumeInterpolation.Values.GetLength(1) - volumeInterpolation.MapCoordinate(e.Result.GetCoordinates().Value.Y)) * scale);
     }
 }