static Color GetColor(ControlData.StatusColor statusColor) { switch (statusColor) { case ControlData.StatusColor.Error: return(Color.Red); case ControlData.StatusColor.Warning: return(Color.Salmon); case ControlData.StatusColor.Success: return(Color.FromArgb(0, 176, 80)); default: return(Color.Black); } }
static ControlData GetCurrentData(CorrelationStateSummary state) { if (state.Status == CorrelationStateSummary.StatusCode.PostprocessingUnavailable) { return(new ControlData(true, "Fix clock skew: N/A")); } string content = null; ControlData.StatusColor color = ControlData.StatusColor.Neutral; double?progress = null; switch (state.Status) { case CorrelationStateSummary.StatusCode.NeedsProcessing: content = string.Format("Logs clocks may be{0}out of sync.{0}*{1} Fix clock skew*", Environment.NewLine, Constants.RunActionId); color = ControlData.StatusColor.Warning; break; case CorrelationStateSummary.StatusCode.ProcessingInProgress: content = "Fixing clock skew..."; progress = state.Progress; break; case CorrelationStateSummary.StatusCode.Processed: case CorrelationStateSummary.StatusCode.ProcessingFailed: bool wasSuccessful = state.Status == CorrelationStateSummary.StatusCode.Processed; content = (wasSuccessful ? "Clock skew is fixed." : "Failed to fix clock skew.") + Environment.NewLine; if (state.Report != null) { content += "*1 View report.* "; } content += wasSuccessful ? $"*{Constants.RunActionId} Fix again*" : $"*{Constants.RunActionId} Try again*"; if (!wasSuccessful) { color = ControlData.StatusColor.Error; } else { color = ControlData.StatusColor.Success; } break; } return(new ControlData(false, content, color, progress)); }
static NSColor MapColor(ControlData.StatusColor c) { switch (c) { case ControlData.StatusColor.Error: return(NSColor.Red); case ControlData.StatusColor.Warning: return(Color.Salmon.ToNSColor()); case ControlData.StatusColor.Success: return(Color.FromArgb(0, 176, 80).ToNSColor()); default: return(NSColor.Text); } }
static NSColor MapColor(ControlData.StatusColor c) { switch (c) { case ControlData.StatusColor.Error: return(NSColor.Red); case ControlData.StatusColor.Warning: return(LogJoint.Drawing.Extensions.ToNSColor(System.Drawing.Color.Salmon)); case ControlData.StatusColor.Success: return(LogJoint.Drawing.Extensions.ToNSColor(System.Drawing.Color.FromArgb(0, 176, 80))); default: return(NSColor.Black); } }
void UpdateActionLink(NSLinkLabel lbl, string value, ControlData.StatusColor color, bool enabled, ViewControlId id) { lbl.SetAttributedContents(value); lbl.TextColor = MapColor(color); lbl.IsEnabled = enabled; if (lbl.LinkClicked == null) { lbl.LinkClicked = (s, e) => { if (!string.IsNullOrEmpty(e.Link.Tag as string)) { var flags = ClickFlags.None; // todo: flags viewModel.OnActionClick((string)e.Link.Tag, id, flags); } }; } }
static ControlData GetCurrentData(ImmutableList <LogSourcePostprocessorState> outputs, PostprocessorKind postprocessorKind) { if (outputs.Count == 0) { return(new ControlData(true, postprocessorKind.ToDisplayString() + ": N/A")); } int nrOfRunning = 0; int nrOfLoading = 0; int nrOfProcessed = 0; int nrOfUnprocessed = 0; int nrOfOutdated = 0; int nrOfProcessedWithWarnings = 0; int nrOfProcessedWithErrors = 0; double?progress = null; foreach (var output in outputs) { switch (output.OutputStatus) { case LogSourcePostprocessorState.Status.Finished: case LogSourcePostprocessorState.Status.Failed: if (output.LastRunSummary != null) { if (output.LastRunSummary.HasWarnings) { ++nrOfProcessedWithWarnings; } if (output.LastRunSummary.HasErrors) { ++nrOfProcessedWithErrors; } } ++nrOfProcessed; break; case LogSourcePostprocessorState.Status.Outdated: ++nrOfOutdated; ++nrOfProcessed; break; case LogSourcePostprocessorState.Status.InProgress: ++nrOfRunning; progress = output.Progress; break; case LogSourcePostprocessorState.Status.Loading: ++nrOfLoading; progress = output.Progress; break; case LogSourcePostprocessorState.Status.NeverRun: ++nrOfUnprocessed; break; } } var isClickableCaption = false; string action = null; string statusText = null; string controlContent = ""; ControlData.StatusColor controlColor = ControlData.StatusColor.Neutral; double?controlProgress = null; Action appendReportLinkIfRequired = () => { if (nrOfProcessedWithErrors > 0) { statusText += " *report with errors*"; } else if (nrOfProcessedWithWarnings > 0) { statusText += " *report with warnings*"; } }; if (nrOfLoading > 0 && nrOfRunning == 0) { statusText = string.Format("loading... ({0} of {1} logs completed)", nrOfLoading, nrOfLoading + nrOfProcessed); controlProgress = progress; } else if (nrOfRunning > 0) { statusText = string.Format("running... ({0} of {1} logs completed)", nrOfProcessed, nrOfRunning + nrOfProcessed + nrOfLoading); controlProgress = progress; } else if (nrOfUnprocessed > 0 || nrOfOutdated > 0) { statusText = string.Format("{0} of {1} logs processed", nrOfProcessed, nrOfProcessed + nrOfUnprocessed); appendReportLinkIfRequired(); if (nrOfOutdated > 0) { statusText += string.Format(", {0} outdated", nrOfOutdated); } if (nrOfProcessed > 0) { isClickableCaption = true; } action = "run postprocessor"; controlColor = ControlData.StatusColor.Warning; } else { statusText = string.Format("all logs processed"); if (nrOfProcessed > 0) { isClickableCaption = true; } appendReportLinkIfRequired(); action = "re-process"; if (nrOfProcessedWithErrors > 0) { controlColor = ControlData.StatusColor.Error; } else { controlColor = ControlData.StatusColor.Success; } } var contentBuilder = new StringBuilder(); if (isClickableCaption) { contentBuilder.AppendFormat("*{1} {0}:*", outputs[0].Postprocessor.Kind.ToDisplayString(), Constants.ShowVisualizerActionId); } else { contentBuilder.AppendFormat("{0}:", outputs[0].Postprocessor.Kind.ToDisplayString()); } if (statusText != null) { contentBuilder.AppendFormat(" {0}", statusText); } if (action != null) { contentBuilder.AppendFormat(" *{1} {0}*", action, Constants.RunActionId); } controlContent += contentBuilder.ToString(); return(new ControlData(false, controlContent, controlColor, controlProgress)); }