예제 #1
0
        public void Analyse()
        {
            DateTime start      = DateTime.Now;
            int      frameIndex = 0;

            SampleAnalyser analyser = new SampleAnalyser(_condition, _parameters);

            foreach (var frame in _frames)
            {
                if (!_running)
                {
                    break;
                }

                analyser.AddSample(frame);

                if ((frameIndex + 1) % 100 == 0)
                {
                    double progress01 = (double)frameIndex / _frames.Count;
                    string progress   = $"{frameIndex} / {_frames.Count} ({progress01:P})";

                    TimeSpan elapsed         = DateTime.Now - start;
                    TimeSpan averagePerFrame = elapsed.Divide(frameIndex + 1);
                    int      left            = Math.Max(0, _frames.Count - frameIndex - 1);
                    TimeSpan timeLeft        = averagePerFrame.Multiply(left);

                    progress += $" {timeLeft:mm\\:ss}";

                    Dispatcher.Invoke(() =>
                    {
                        TaskbarItemInfo.ProgressValue = progress01;
                        proProgress.Value             = progress01;
                        txtProgress.Text = progress;
                    });
                }

                frameIndex++;
            }

            List <long>     frames = analyser.GetResults();
            List <TimeSpan> result = frames.Select(frame => _frames.FrameIndexToTimeSpan(frame)).ToList();

            Dispatcher.BeginInvoke(new Action(() =>
            {
                Result       = result;
                DialogResult = true;
            }));
        }
예제 #2
0
        public void Analyse()
        {
            int frameIndex = 0;

            SampleAnalyser analyser = new SampleAnalyser(_condition, _parameters);

            foreach (var frame in _frames)
            {
                if (!_running)
                {
                    break;
                }

                analyser.AddSample(frame);

                if ((frameIndex + 1) % 100 == 0)
                {
                    double progress01 = (double)frameIndex / _frames.Count;
                    string progress   = $"{frameIndex} / {_frames.Count} ({progress01:P})";

                    Dispatcher.Invoke(() =>
                    {
                        TaskbarItemInfo.ProgressValue = progress01;
                        proProgress.Value             = progress01;
                        txtProgress.Text = progress;
                    });
                }

                frameIndex++;
            }

            List <long>     frames = analyser.GetResults();
            List <TimeSpan> result = frames.Select(frame => _frames.FrameIndexToTimeSpan(frame)).ToList();

            Dispatcher.BeginInvoke(new Action(() =>
            {
                Result       = result;
                DialogResult = true;
            }));
        }