private void FrameRendering(object Sender, DoWorkEventArgs e)
        {
            BackgroundWorker BW = Sender as BackgroundWorker;
            RenderData       RD = e.Argument as RenderData;

            if (RD == null)
            {
                return;
            }

            PlaneRenderer PR = new PlaneRenderer();

            for (int i = 0; i < RD.FrameCount; i++)
            {
                SetStatusText("Rendering frame " + (i + 1).ToString() + " of " + RD.FrameCount.ToString());
                switch (RD.ColorSpaceName)
                {
                case "RGB":
                    PR.RenderRGBPlane(RGBAxisDefinitions.RGB, i, RD.RenderSurface, RD.FrameWidth, RD.FrameHeight);
                    break;

                case "CMY":
                    PR.RenderCMYPlane(CMYAxisDefinitions.CMY, i, RD.RenderSurface, RD.FrameWidth, RD.FrameHeight);
                    break;

                case "HSV":
                    PR.RenderHSVPlane(HSVAxisDefinitions.HSV, i, RD.RenderSurface, RD.FrameWidth, RD.FrameHeight);
                    break;
                }
                BW.ReportProgress(i, RD.RenderSurface);
#if false
                string FileName   = i.ToString("D3") + "_" + RD.ColorSpaceName + RD.AxisOrder.ToString();
                var    PngEncoder = new PngBitmapEncoder();
                PngEncoder.Frames.Add(BitmapFrame.Create((BitmapSource)RD.RenderSurface.Source));
                using (FileStream stream = new FileStream(FileName, FileMode.Create))
                    PngEncoder.Save(stream);
#endif
            }
        }
        private void RenderFramesHandler(object Sender, RoutedEventArgs e)
        {
            RD = new RenderData();
            PopulateRenderData(ref RD);
            if (RD == null)
            {
                SetStatusText("Error gathering render data.");
                return;
            }

            RenderStart        = DateTime.Now;
            DurationBlock.Text = "";
            BackgroundWorker BW = new BackgroundWorker();

            BW.WorkerReportsProgress = true;
            BW.DoWork              += FrameRendering;
            BW.RunWorkerCompleted  += FrameRenderingCompleted;
            BW.ProgressChanged     += HandleRenderProgressChanged;
            RenderButton.IsEnabled  = false;
            RD.RenderSurface        = new Image();
            RD.RenderSurface.Width  = RD.FrameWidth;
            RD.RenderSurface.Height = RD.FrameHeight;
            BW.RunWorkerAsync(RD);
        }