private protected void Done(bool isSuccess) { try { AppendMessage("Done"); ProgressBar.Visible = false; Ok.Enabled = true; Ok.Focus(); AcceptButton = Ok; Abort.Enabled = false; TaskbarProgress.SetProgress(isSuccess ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.Error, 100, 100); Bitmap image = isSuccess ? Images.StatusBadgeSuccess : Images.StatusBadgeError; SetIcon(image); _errorOccurred = !isSuccess; if (isSuccess && (_useDialogSettings && AppSettings.CloseProcessDialog)) { Close(); } } catch (ConEmu.WinForms.GuiMacroExecutor.GuiMacroException) { // Do nothing } }
private protected async Task SetProgressAsync(string text) { // This has to happen on the UI thread await this.SwitchToMainThreadAsync(); int index = text.LastIndexOf('%'); if (index > 4 && int.TryParse(text.Substring(index - 3, 3), out var progressValue) && progressValue >= 0) { ProgressBar.Style = ProgressBarStyle.Blocks; ProgressBar.Value = Math.Min(100, progressValue); TaskbarProgress.SetProgress(TaskbarProgressBarState.Normal, progressValue, 100); } // Show last progress message in the title, unless it's showing in the control body already if (!ConsoleOutput.IsDisplayingFullProcessOutput) { Text = text; } }
public void Done(bool isSuccess) { try { AppendMessageCrossThread("Done"); ProgressBar.Visible = false; Ok.Enabled = true; Ok.Focus(); AcceptButton = Ok; Abort.Enabled = false; TaskbarProgress.SetProgress( isSuccess ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.Error, 100, 100); picBoxSuccessFail.Image = isSuccess ? Images.StatusBadgeSuccess : Images.StatusBadgeError; _errorOccurred = !isSuccess; if (isSuccess && !_showOnError && (_useDialogSettings && AppSettings.CloseProcessDialog)) { Close(); } } catch (ConEmu.WinForms.GuiMacroExecutor.GuiMacroException) { // Do nothing } finally { _modalController?.EndModal(isSuccess); } }