private static void GenericErrorExtendedSafe(string fullInfo) { var trimmed = fullInfo.Length > 1000 ? fullInfo.Substring(0, 997) + "..." : fullInfo; if (CustomMessageBox.ShowDialog(DefaultOwner, new CmbBasicSettings(Localisation.PremadeDialogs_GenericError_Title, Localisation.PremadeDialogs_GenericErrorExtendedSafe_Heading, trimmed, SystemIcons.Error, Buttons.ButtonCopy, Buttons.ButtonClose)) == CustomMessageBox.PressedButton.Middle) { try { if (DefaultOwner != null) { DefaultOwner.SafeInvoke(() => Clipboard.SetText(fullInfo)); } else { Clipboard.SetText(fullInfo); } } catch (ExternalException) { } } }
private static void GenericErrorSafe(string errorType, string fullInfo) { switch (CustomMessageBox.ShowDialog(DefaultOwner, new CmbBasicSettings(Localisation.PremadeDialogs_GenericError_Title, Localisation.PremadeDialogs_GenericError_Heading, string.Format(Localisation.PremadeDialogs_GenericError_Details, errorType), SystemIcons.Error, Buttons.ButtonCopy, Buttons.ButtonDetails, Buttons.ButtonClose))) { case CustomMessageBox.PressedButton.Middle: GenericErrorExtendedSafe(fullInfo); break; case CustomMessageBox.PressedButton.Left: try { if (DefaultOwner != null) { DefaultOwner.SafeInvoke(() => Clipboard.SetText(fullInfo)); } else { Clipboard.SetText(fullInfo); } } catch (ExternalException) { } break; } }
/// <summary> /// Show a generic error message. /// </summary> public static void GenericError(string errorType, string additionalInfo = null) { if (string.IsNullOrEmpty(errorType)) { return; } if (string.IsNullOrEmpty(additionalInfo)) { additionalInfo = errorType; } var entryAsy = Assembly.GetEntryAssembly(); if (entryAsy != null) { var asyName = entryAsy.GetName(); var bits = ProcessTools.Is64BitProcess ? "64bit" : "32bit"; additionalInfo = $"{asyName.FullName} | {asyName.ProcessorArchitecture} | {Environment.OSVersion} | {bits}\n{additionalInfo}"; } if (DefaultOwner != null) { DefaultOwner.SafeInvoke(() => GenericErrorSafe(errorType, additionalInfo)); } else { GenericErrorSafe(errorType, additionalInfo); } }
/// <summary> /// If user choses to send error information, SendErrorAction is called. /// </summary> private static void SendErrorQuestion(Exception ex) { switch (CustomMessageBox.ShowDialog(DefaultOwner, new CmbBasicSettings(Localisation.PremadeDialogs_GenericError_Title, Localisation.PremadeDialogs_GenericError_Heading, string.Format(Localisation.PremadeDialogs_GenericError_Details, ex.Message), SystemIcons.Error, Buttons.ButtonSubmit, Buttons.ButtonCopy, Buttons.ButtonClose))) { case CustomMessageBox.PressedButton.Left: SendErrorAction.Invoke(ex); break; case CustomMessageBox.PressedButton.Middle: var fullInfo = GetExceptionDetailString(ex); try { if (DefaultOwner != null) { DefaultOwner.SafeInvoke(() => Clipboard.SetText(fullInfo)); } else { Clipboard.SetText(fullInfo); } } catch (ExternalException) { } break; } }
public static bool KillRunningProcessesQuestion() { var result = false; if (DefaultOwner != null) { DefaultOwner.SafeInvoke(() => result = KillRunningProcessesQuestionSafe()); } else { result = KillRunningProcessesQuestionSafe(); } return(result); }