private void OutputRichMessage(String date, String id, String message) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run dateEntry = new Run(date); Run idEntry = new Run(id); Run messageEntry = new Run(message); TextRange dateRange = new TextRange(dateEntry.ContentStart, dateEntry.ContentEnd); dateRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.GreenYellow); TextRange idRange = new TextRange(idEntry.ContentStart, idEntry.ContentEnd); idRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Cyan); TextRange messageRange = new TextRange(messageEntry.ContentStart, messageEntry.ContentEnd); messageRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.DarkOrange); paragraph.Inlines.AddRange(new Run[] { dateEntry, idEntry, messageEntry }); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void CancelBtn_Click(object sender, RoutedEventArgs e) { pendingProcessKill = true; if (KillProcesses()) { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("KILLED ALL PROCESSES")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }
private void OutputRichMessageWithImage(String date, String id, Byte[] imageBytes) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run dateEntry = new Run(date); Run idEntry = new Run(id); TextRange dateRange = new TextRange(dateEntry.ContentStart, dateEntry.ContentEnd); dateRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.GreenYellow); TextRange idRange = new TextRange(idEntry.ContentStart, idEntry.ContentEnd); idRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Cyan); BitmapImage bitmap = new BitmapImage(); using (var stream = new MemoryStream(imageBytes)) { stream.Seek(0, SeekOrigin.Begin); bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.BeginInit(); bitmap.StreamSource = stream; bitmap.EndInit(); } Image image = new Image { Source = bitmap, Width = 20 }; Figure imageFigure = new Figure() { Width = new FigureLength(100) }; imageFigure.Blocks.Add(new BlockUIContainer(image)); paragraph.Inlines.AddRange(new Run[] { dateEntry, idEntry }); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void OutputRichInfo(String message) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run entry = new Run(message); paragraph.Inlines.Add(entry); TextRange entryRange = new TextRange(entry.ContentStart, entry.ContentEnd); entryRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Teal); entryRange.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void RunBtn_Click(object sender, RoutedEventArgs e) { // Keep track of how many times we've ran ++timesRun; // We clicked build, so at this point we know the user doesn't want to cancel build pendingProcessKill = false; // Output this run's header Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run($"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RUN {timesRun} ~~~~~~~~~~~~~~~~~~~")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); // The directory that the uproject is in string uprojectDirectory = uProjectPath.Remove(uProjectPath.LastIndexOf('\\')); // The name of the uproject (excluding the ".uproject") string uprojectName = uProjectPath.Remove(uProjectPath.LastIndexOf(".uproject")).Remove(0, uProjectPath.Remove(uProjectPath.LastIndexOf(".uproject")).LastIndexOf('\\') + 1); // The name of this project's editor string editorName = uprojectName + "Editor"; // Run Unreal Build Tool ubtProcess = new Process() { StartInfo = new ProcessStartInfo() { FileName = $"{engineDirectory}\\Engine\\Build\\BatchFiles\\Build.bat", Arguments = $"{editorName} Win64 Development \"{uProjectPath}\" -WaitMutex", //Arguments = $"\"uprojectPath\" \"{uprojectDirectory}\\Intermediate\\Build\\Win64\\{editorName}\\DebugGame\\{editorName}.uhtmanifest\" -LogCmds=\"loginit warning, logexit warning, logdatabase error\" -Unattended -WarningsAsErrors -abslog=\"{engineDirectory}\\Engine\\Programs\\UnrealBuildTool\\Log_UHT.txt\"", // i forgot what this was from //Arguments = $"-Target=\"{editorName} Win64 DebugGame - Project =\"{uprojectPath}\"\" - Target = \"ShaderCompileWorker Win64 Development -Quiet\" - WaitMutex - FromMsBuild", // What VS runs CreateNoWindow = true }, EnableRaisingEvents = true }; ubtProcess.StartInfo.UseShellExecute = false; ubtProcess.StartInfo.RedirectStandardOutput = true; ubtProcess.OutputDataReceived += (sender, e) => Dispatcher.Invoke(() => { string output = e.Data; if (output != null) { Paragraph paragraph = new Paragraph(); if (output.Contains("ERROR: ", StringComparison.OrdinalIgnoreCase) || output.Contains("FAILED")) { paragraph.Foreground = errorColor; } else if (output.Contains("WARNING: ", StringComparison.OrdinalIgnoreCase)) { paragraph.Foreground = warningColor; } else if (output.Contains("**********")) { paragraph.Foreground = markerColor; } else if (output.Contains("SUCCESSFUL")) { paragraph.Foreground = goodColor; } else { paragraph.Foreground = logColor; } // Print the output paragraph.Inlines.Add(new Run(output)); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }); ubtProcess.ErrorDataReceived += (sender, e) => Dispatcher.Invoke(() => { string output = e.Data; if (output != null) { Paragraph paragraph = new Paragraph(); paragraph.Foreground = errorColor; // Print the output paragraph.Inlines.Add(new Run(output)); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }); // Ensure the user wants us to start this process if (pendingProcessKill) { return; } // Start the process if (File.Exists(ubtProcess.StartInfo.FileName) && ubtProcess.Start()) { Dispatcher.Invoke(() => { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("UBT Started")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }); // Read the process's output so we can display it in the text box ubtProcess.BeginOutputReadLine(); } ubtProcess.Exited += (sender, e) => { ubtProcess.Dispose(); ubtProcess = null; Dispatcher.Invoke(() => { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("UBT Exited")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }); // Ensure the user wants us to start this process if (pendingProcessKill) { return; } // Run Unreal Automation Tool string uatArguments = $"BuildCookRun -Platform=Win64 -Project=\"{uProjectPath}\" -NoCompileEditor -NoP4"; uatArguments += BuildUATArguments(); uatProcess = new Process() { StartInfo = new ProcessStartInfo() { FileName = $"{engineDirectory}\\Engine\\Build\\BatchFiles\\RunUAT.bat", Arguments = uatArguments, //Arguments = $"BuildCookRun -Project=\"{uprojectPath}\" -NoP4 -Distribution -TargetPlatform=Win64 -Platform=Win64 -ClientConfig=Shipping -ServerConfig=Shipping -Cook -Build -Stage -Pak -Archive -source -Prereqs -Package", // With compile - doesn't work for some reason CreateNoWindow = true }, EnableRaisingEvents = true }; uatProcess.StartInfo.UseShellExecute = false; uatProcess.StartInfo.RedirectStandardOutput = true; uatProcess.OutputDataReceived += (sender, e) => Dispatcher.Invoke(() => { string output = e.Data; if (output != null) { Paragraph paragraph = new Paragraph(); if (output.Contains("ERROR: ", StringComparison.OrdinalIgnoreCase) || output.Contains("FAILED")) { paragraph.Foreground = errorColor; } else if (output.Contains("WARNING: ", StringComparison.OrdinalIgnoreCase)) { paragraph.Foreground = warningColor; } else if (output.Contains("**********")) { paragraph.Foreground = markerColor; } else if (output.Contains("SUCCESSFUL")) { paragraph.Foreground = goodColor; } else { paragraph.Foreground = logColor; } // Print the output paragraph.Inlines.Add(new Run(output)); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }); uatProcess.ErrorDataReceived += (sender, e) => Dispatcher.Invoke(() => { string output = e.Data; if (output != null) { Paragraph paragraph = new Paragraph(); paragraph.Foreground = errorColor; // Print the output paragraph.Inlines.Add(new Run(output)); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }); // Start the process if (File.Exists(uatProcess.StartInfo.FileName) && uatProcess.Start()) { Dispatcher.Invoke(() => { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("UAT Started")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }); // Read the process's output so we can display it in the text box uatProcess.BeginOutputReadLine(); } uatProcess.Exited += (sender, e) => { uatProcess.Dispose(); uatProcess = null; Dispatcher.Invoke(() => { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("UAT Exited")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }); }; }; }