Example #1
0
        private void Indexer_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            DecodingProgress ip = (DecodingProgress)e.UserState;

            if (!String.IsNullOrEmpty(ip.Message))
            {
                textBox.AppendText(ip.Message + Environment.NewLine);
            }
            if (!String.IsNullOrEmpty(ip.ETA))
            {
                labelETA.Text = String.Format(Properties.Resources.ETA, ip.ETA);
            }

            if (e.ProgressPercentage > 0)
            {
                progressBar.Value = e.ProgressPercentage;
            }

            if (ip.DecodingState == DecodingProgress.State.Failure)
            {
                btnDone.Text = Properties.Resources.CloseIndexingForm;
            }

            if (ip.DecodingState == DecodingProgress.State.Finished)
            {
                indexingRunning = false;

                labelETA.Text = Properties.Resources.IndexingDoneETA;

                DialogResult = btnDone.Enabled ? DialogResult.OK : DialogResult.Abort;

                Close();
            }
        }
Example #2
0
        public void ReportProgress(int percentage, DecodingProgress.State status, string message)
        {
            int eta;
            DecodingProgress ip = new DecodingProgress();

            ip.DecodingState = status;
            ip.Message       = message;

            // a naive ETA formula: ETA = ElapsedMinutes * 100 / percentDone - Elapsed

            if (percentage > 0)
            {
                elapsed = (DateTime.Now.Subtract(startTime));
                eta     = (int)(elapsed.TotalMinutes * 100 / percentage - elapsed.TotalMinutes);

                if (eta <= 0)
                {
                    ip.ETA = Properties.Resources.FinishingSoon;
                }
                else
                {
                    TimeSpan remaining = TimeSpan.FromMinutes(eta + 1);
                    ip.ETA = String.Format(Properties.Resources.FinishingInHours, (int)remaining.TotalHours, remaining.Minutes);
                }
            }
            else
            {
                ip.ETA = "n/a";
            }

            OnProgressChanged(new ProgressChangedEventArgs(percentage, ip));
        }
Example #3
0
        internal static DecodingProgress CreateProgress(string message, DecodingProgress.State state)
        {
            DecodingProgress ip = new DecodingProgress();

            ip.Message       = message;
            ip.DecodingState = state;
            ip.ETA           = "n/a";
            return(ip);
        }
Example #4
0
 internal static DecodingProgress CreateProgress(string message, DecodingProgress.State state)
 {
     DecodingProgress ip = new DecodingProgress();
     ip.Message = message;
     ip.DecodingState = state;
     ip.ETA = "n/a";
     return ip;
 }
Example #5
0
            public void ReportProgress(int percentage, DecodingProgress.State state, string message)
            {
                DecodingProgress ip = CreateProgress(message, state);

                ProgressChanged(this, new ProgressChangedEventArgs(percentage, ip));
            }
Example #6
0
            public void ReportProgress(int percentage, DecodingProgress.State state, string message)
            {
                DecodingProgress ip = CreateProgress(message, state);

                ProgressChanged(this, new ProgressChangedEventArgs(percentage, ip));
            }
Example #7
0
        public void ReportProgress(int percentage, DecodingProgress.State status, string message)
        {
            int eta;
            DecodingProgress ip = new DecodingProgress();

            ip.DecodingState = status;
            ip.Message = message;

            // a naive ETA formula: ETA = ElapsedMinutes * 100 / percentDone - Elapsed

            if (percentage > 0)
            {
                elapsed = (DateTime.Now.Subtract(startTime));
                eta = (int)(elapsed.TotalMinutes * 100 / percentage - elapsed.TotalMinutes);

                if (eta <= 0)
                {
                    ip.ETA = Properties.Resources.FinishingSoon;
                }
                else
                {
                    TimeSpan remaining = TimeSpan.FromMinutes(eta + 1);
                    ip.ETA = String.Format(Properties.Resources.FinishingInHours, (int)remaining.TotalHours, remaining.Minutes);
                }
            }
            else
            {
                ip.ETA = "n/a";
            }

            OnProgressChanged(new ProgressChangedEventArgs(percentage, ip));
        }