CSharpUtils.Forms.ProgressForm.SetStep C# (CSharp) Метод

SetStep() публичный Метод

public SetStep ( double Value, String Details ) : void
Value double
Details String
Результат void
		public void SetStep(double Value, String Details)
		{
			try
			{
				this.progressBar1.Invoke(new Action(delegate()
				{
					try
					{
						this.labelAction.Text = Details;
						this.progressBar1.Minimum = 0;
						this.progressBar1.Maximum = 10000;
						this.progressBar1.Value = (int)(Value * 10000);
					}
					catch (Exception e) {
						Console.Error.WriteLine("Waring: " + e);
					}
				}));
			}
			catch (Exception e)
			{
				Console.Error.WriteLine("Waring: " + e);
			}
		}
	}

Usage Example

Пример #1
0
        public void ShowProgressForm(Action Start = null, Action Complete = null)
        {
            var ProgressForm = new ProgressForm();
            ProgressForm.WaitObject = this.IsFinishedLockObject;

            this.OnStep += delegate(double Value, String Details)
            {
                ProgressForm.SetStep(Value, Details);
            };

            ProgressForm.SetOriginDestination(
                SourceFileSystem.Title,
                DestinationFileSystem.Title
            );

            this.OnError += delegate(Exception Exception)
            {
                if (!Canceling)
                {
                    MessageBox.Show(Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            };

            ProgressForm.OnCancelClick = delegate()
            {
                return (MessageBox.Show("¿Está seguro de querer cancelar la sincronización?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes);
            };

            if (Complete != null)
            {
                ProgressForm.Complete += Complete;
            }

            ProgressForm.Process = delegate()
            {
                RetrySource:

                try
                {
                    CallStep(0, String.Format(ConnectingToFormat, SourceFileSystem.Title));
                    SourceFileSystem.TryInitialize();
                }
                catch (Exception Exception)
                {
                    Console.WriteLine(Exception);
                    if (!Canceling)
                    {
                        if (MessageBox.Show(Exception.Message + "\n\n" + Exception.StackTrace, "Can't connect to local FileSystem", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Retry)
                        {
                            goto RetrySource;
                        }
                    }
                }

                RetryDestination:

                try
                {
                    CallStep(0, String.Format(ConnectingToFormat, DestinationFileSystem.Title));
                    DestinationFileSystem.TryInitialize();
                }
                catch (Exception Exception)
                {
                    Console.WriteLine(Exception);
                    if (!Canceling)
                    {
                        if (MessageBox.Show(Exception.Message + "\n\n" + Exception.StackTrace, "Can't connect to remote FileSystem", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Retry)
                        {
                            goto RetryDestination;
                        }
                    }
                }

                Console.WriteLine("Started SynchronizeFolder ({0} -> {1})...", SourceFileSystem, DestinationFileSystem);
                this.SynchronizeFolder();
            };

            ProgressForm.Cancel = delegate()
            {
                this.Cancel();
            };

            if (Start != null)
            {
                Start();
            }

            //ProgressForm.ShowDialog();
            ProgressForm.ExecuteProcess();
        }