示例#1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            fpsCounter = 0;
            fpsStart   = DateTime.Now;
            double angle           = (double)e.Argument;
            int    counter         = 0;
            int    pctCounterValue = (trackBar1.Maximum * currentTimeFactor) / 100;

            if (pctCounterValue == 0)
            {
                pctCounterValue = 1;
            }
            //for (int ii = 0; ii < trackBar1.Maximum * currentTimeFactor; ii++)
            System.Threading.Tasks.Parallel.For(0, trackBar1.Maximum * currentTimeFactor, (ii) =>
            {
                int i = System.Threading.Interlocked.Increment(ref counter);
                if (backgroundWorker1.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                double currentTime = (double)i / currentTimeFactor;
                root.PlaceInTime(currentTime);
                var tmpDists = new DistPoint[pictureBox2.Width, pictureBox2.Height];
                List <RendererHelper.StarMoved> stars = RendererHelper.GetAngledStars(root, currentTime, angle);
                renderer.Render(stars, tmpDists, flux, i);
                SetDists(tmpDists);
                System.Threading.Interlocked.Increment(ref fpsCounter);
                if (i % pctCounterValue == 0)
                {
                    backgroundWorker1.ReportProgress(i * 100 / trackBar1.Maximum, i);
                }
            });
        }
示例#2
0
        private void rendererComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            renderer = renderers[rendererComboBox.SelectedIndex];
            List <RendererHelper.StarMoved> stars = RendererHelper.GetAngledStars(root, currentTime, Extensions.DegToRad(trackBar2.Value));

            DistPoint[,] tmpDists = LockDists();
            renderer.Render(stars, tmpDists, flux, currentTime * currentTimeFactor);
            SetDists(tmpDists);
            pictureBox2.Invalidate();
        }
示例#3
0
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            angleLabel.Text = trackBar2.Value.ToString() + "°";
            currentTime     = trackBar1.Value;
            root.PlaceInTime(currentTime);
            List <RendererHelper.StarMoved> stars = RendererHelper.GetAngledStars(root, currentTime, Extensions.DegToRad(trackBar2.Value));

            DistPoint[,] tmpDists = LockDists();
            renderer.Render(stars, tmpDists, flux, currentTime * currentTimeFactor);
            SetDists(tmpDists);

            pictureBox1.Invalidate();
            pictureBox2.Invalidate();
            pictureBox3.Invalidate();
        }