internal static void Show(Form owner, ELogLevel level, string message) { switch (level) { case ELogLevel.Information: FrmMsgBox.ShowInfo(owner, level.ToUiString(), message); break; case ELogLevel.Error: FrmMsgBox.ShowError(owner, level.ToUiString(), message); break; case ELogLevel.Warning: FrmMsgBox.ShowWarning(owner, level.ToUiString(), message); break; } }
/// <summary> /// Shows a message describing the logs (if any) /// </summary> private static void ShowLogMessage(Form owner, IReadOnlyList <ProgressReporter.LogRecord> logs) { if (logs.Count == 1) { // One line messagebox if one log var l = logs[0]; FrmMsgBox.Show(owner, l.Level, l.Message); } else if (logs.Count != 0) { // Messagebox with "details" buttons for multiple logs // (Messagebox icon reflects the highest log level) StringBuilder sb = new StringBuilder(); DataSet <ProgressReporter.LogRecord> ds = new DataSet <ProgressReporter.LogRecord>() { ListSource = logs, ListTitle = "Logs", HandleEdit = DisplayLog, }; ELogLevel max = logs.Max(z => z.Level); string msg; MsgBoxButton[] bts; if (max == ELogLevel.Information) { msg = "Update complete."; bts = new MsgBoxButton[] { new MsgBoxButton(DialogResult.OK), new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel) }; } else { msg = $"One or more {max.ToUiString().ToLower()}s were reported."; bts = new MsgBoxButton[] { new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel), new MsgBoxButton("Ignore", Resources.MnuCancel, DialogResult.OK) }; } if (FrmMsgBox.Show(owner, max.ToUiString(), null, msg, FrmMsgBox.GetIcon(max), bts) == DialogResult.Cancel) { ds.ShowListEditor(owner, FrmBigList.EShow.ReadOnly, null); } } }