示例#1
0
        // <summary>
        // set the progress to a new value
        // </summary>
        // <param name="Percent">progress in percent</param>
        // <remarks></remarks>
        private void progressUpdate(Int32 Percent)
        {
            try {
                if (ProgressBar1.InvokeRequired)
                {
                    ProgressBar1.Invoke(new del_Sub_PInt32(this.progressUpdate), Percent);
                }
                else
                {
                    ProgressBar1.Value = Percent;
                    if (Percent > 0 && Percent < 100)
                    {
                        ProgressBar1.Value = Percent - 1;
                    }

                    lblProgress.Text = string.Format("{0}%", Percent);
                    ProgressBar1.Refresh();

                    if (m_SelfDoEvents)
                    {
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex) {
                throw new Exception("error while setting a new value", ex);
            }
        }
        private void BeginProcess(string spreadSheetPath, IProgress <double> progress)
        {
            var process = new ProcessController(spreadSheetPath);

            process.OnProgressChanged += (d) =>
            {
                progress?.Report(d);
                ProgressBar1.Invoke((Action)(() => ProgressBar1.Value = d));
                return(d);
            };
            process.OnProgressFinished += (s, e) =>
            {
                TxtFilePath.Invoke((Action)(() => TxtFilePath.IsEnabled = true));
                BtnBrowse.Invoke((Action)(() => BtnBrowse.IsEnabled = true));
                BtnStartProcess.Invoke((Action)(() => BtnStartProcess.IsEnabled = true));
                System.Windows.MessageBox.Show("Operation Done Successfully.");

                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    var report = new OperationReport(new OperationReportContext()
                    {
                        Success = e.SuccessEmails,
                        Errors  = e.FailedEmails
                    });
                    report.ShowDialog();
                }));
            };
            process.BeginProcessing();
        }
示例#3
0
//#7------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Threadhandler()
        {
            try
            {
                BenchTimer.Start();
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Minimum = s; }), 0);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), 1);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 0);
                AllFilesToConvert.Clear();
                AllActionMessages.Clear();
                if (FilePath.Length > 0)
                {
                    ConvertString(FilePath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 1);
                }
                if (FolderPath.Length > 0)
                {
                    CheckSubFolders(FolderPath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), AllFilesToConvert.Count - 1);
                    for (int i = 0; i < AllFilesToConvert.Count; i++)
                    {
                        ConvertString(AllFilesToConvert[i]);
                        ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), i);
                    }
                }
                MethodInvoker AddItems = delegate
                {
                    for (int i = 0; i < AllActionMessages.Count; i++)
                    {
                        ActionBox.Items.Add(AllActionMessages[i]);
                    }
                };
                ActionBox.BeginInvoke(AddItems);
                BenchTimer.Stop();
                MessageBox.Show(string.Format(FinalMessage, ChangeCount, ChangedFileCount, BenchTimer.ElapsedMilliseconds.ToString()));
                BenchTimer.Reset();
                FileBrowse.Invoke(new Action <bool>(s => { FileBrowse.Enabled = s; }), true);
                FolderBrowse.Invoke(new Action <bool>(s => { FolderBrowse.Enabled = s; }), true);
                ConvertButton.Invoke(new Action <bool>(s => { ConvertButton.Enabled = s; }), true);
                OldStringTextBox.Invoke(new Action <bool>(s => { OldStringTextBox.Enabled = s; }), true);
                NewStringTextBox.Invoke(new Action <bool>(s => { NewStringTextBox.Enabled = s; }), true);
                CaseSensitiveCheckBox.Invoke(new Action <bool>(s => { CaseSensitiveCheckBox.Enabled = s; }), true);
                WholeWordCheckBox.Invoke(new Action <bool>(s => { WholeWordCheckBox.Enabled = s; }), true);
                if (!SourceFilePathBox.Text.Equals(TempPath))
                {
                    SourceBrowse.Invoke(new Action <bool>(s => { SourceBrowse.Enabled = s; }), true);
                    DownloadSourceButton.Invoke(new Action <bool>(s => { DownloadSourceButton.Enabled = s; }), true);
                }
            }
            catch
            {
            }
        }
示例#4
0
 public void BackgroundWorker2_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try {
         while (!(ProgressBar1.Value == 99))
         {
             if (OhNoesShutDOWN == true)
             {
                 return;
             }
             ProgressBar1.Invoke((MethodInvoker)Increase);
             Sleep(45);
         }
         ProgressBar1.Invoke((MethodInvoker)one00Percent);
     } catch (Exception ex) {
     }
 }