void ShowTextInTextViewer(string text)
        {
            var tempFileName = tempFilesManager.GenerateNewName() + ".txt";

            using (var w = new StreamWriter(tempFileName))
                w.Write(text);
            shellOpen.OpenInTextEditor(tempFileName);
        }
Ejemplo n.º 2
0
        async void IViewControlHandler.ExecuteAction(string actionId, ClickFlags flags)
        {
            switch (actionId)
            {
            case Constants.ShowVisualizerActionId:
                visualizerPresenter().Show();
                break;

            case Constants.RunActionId:
            {
                await this.postprocessorsManager.RunPostprocessors(getOutputs());

                var outputs = getOutputs();
                if (outputs.Any(x => x.OutputStatus == LogSourcePostprocessorState.Status.Finished))
                {
                    visualizerPresenter().Show();
                }
            }
            break;

            case "report":
            {
                var outputs   = getOutputs();
                var summaries =
                    outputs
                    .Select(output => output.LastRunSummary)
                    .Where(summary => summary != null)
                    .OrderBy(summary => summary.HasErrors ? 0 : summary.HasWarnings ? 1 : 2);
                var text = new StringBuilder();
                foreach (var summary in summaries)
                {
                    text.Append(summary.Report ?? "");
                    text.AppendLine();
                    text.AppendLine();
                }
                if (text.Length > 0)
                {
                    var fname = Path.ChangeExtension(tempFiles.GenerateNewName(), ".txt");
                    File.WriteAllText(fname, text.ToString());
                    shellOpen.OpenInTextEditor(fname);
                }
            }
            break;
            }
        }