コード例 #1
0
        /// <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;
        }