ConfigurationDialog() public method

Display a configuration dialog. Return false if the operation should be cancelled.
public ConfigurationDialog ( ) : bool
return bool
Exemplo n.º 1
0
        private void RunTaskThread(Task task)
        {
            var errorLogFile = Path.Combine(Program.LogDir, "error.log");
            try
            {
                if (File.Exists(errorLogFile))
                    File.Delete(errorLogFile);

                if (!task.ConfigurationDialog())
                    return;

                if (!Program.SuppressWarnings.Get() && !task.StartupWarning())
                    return;

                try
                {
                    task.Run();

                    if (cancelSource.IsCancellationRequested)
                        throw new OperationCanceledException();
                }
                catch (OperationCanceledException e)
                {
                    Invoke(new Action(() =>
                    {
                        labelStatus.Text = "Cancelled";
                        if (e.Message != new OperationCanceledException().Message)
                            labelStatus.Text += ": " + e.Message;
                    }));
                    return;
                }

                if ((task.Failed() || task.Warnings() && !Program.SuppressWarnings.Get()))
                    task.FinishedDialog();

                Invoke(new Action(() =>
                {
                    labelStatus.Text = task.Failed() ? "Failed" : "Done";
                }));
            }
            catch (Exception e)
            {
                var status = "";
                Invoke(new Action(() =>
                {
                    status = labelStatus.Text;
                    labelStatus.Text = "Error: " + e.Message.Trim();
                }));

                Task.CreateDirectory(Program.LogDir);
                File.WriteAllText(errorLogFile, status + "\r\n" + e);
            }
            finally
            {
                Invoke(new Action(() =>
                {
                    foreach (var b in taskButtons.Keys) b.Enabled = true;
                    buttonCancel.Enabled = false;
                    progressBar.Value = 0;
                    if (closeOnCancel) Close();
                }));
            }
        }
Exemplo n.º 2
0
        private void RunTaskThread(Task task)
        {
            var errorLogFile = Path.Combine(Program.LogDir, "error.log");

            try
            {
                if (File.Exists(errorLogFile))
                {
                    File.Delete(errorLogFile);
                }

                if (!task.ConfigurationDialog())
                {
                    return;
                }

                if (!Program.SuppressWarnings.Get() && !task.StartupWarning())
                {
                    return;
                }

                try
                {
                    task.Run();

                    if (cancelSource.IsCancellationRequested)
                    {
                        throw new OperationCanceledException();
                    }
                }
                catch (OperationCanceledException e)
                {
                    Invoke(new Action(() =>
                    {
                        labelStatus.Text = "Cancelled";
                        if (e.Message != new OperationCanceledException().Message)
                        {
                            labelStatus.Text += ": " + e.Message;
                        }
                    }));
                    return;
                }

                if ((task.Failed() || task.Warnings() && !Program.SuppressWarnings.Get()))
                {
                    task.FinishedDialog();
                }

                Invoke(new Action(() =>
                {
                    labelStatus.Text = task.Failed() ? "Failed" : "Done";
                }));
            }
            catch (Exception e)
            {
                var status = "";
                Invoke(new Action(() =>
                {
                    status           = labelStatus.Text;
                    labelStatus.Text = "Error: " + e.Message.Trim();
                }));

                Task.CreateDirectory(Program.LogDir);
                File.WriteAllText(errorLogFile, status + "\r\n" + e);
            }
            finally
            {
                Invoke(new Action(() =>
                {
                    foreach (var b in taskButtons.Keys)
                    {
                        b.Enabled = true;
                    }
                    buttonCancel.Enabled = false;
                    progressBar.Value    = 0;
                    if (closeOnCancel)
                    {
                        Close();
                    }
                }));
            }
        }