void CompilePalLogger_OnError(string errorText, Error e) { Dispatcher.Invoke(() => { Hyperlink errorLink = new Hyperlink(); Run text = new Run(errorText); text.Foreground = e.ErrorColor; errorLink.Inlines.Add(text); errorLink.TargetName = e.ID.ToString(); errorLink.Click += errorLink_Click; var underline = new TextDecoration { Location = TextDecorationLocation.Underline, Pen = new Pen(e.ErrorColor, 1), PenThicknessUnit = TextDecorationUnit.FontRecommended }; errorLink.TextDecorations = new TextDecorationCollection(new[] { underline }); OutputParagraph.Inlines.Add(errorLink); CompileOutputTextbox.ScrollToEnd(); }); }
Run Logger_OnWrite(string s, Brush b = null) { return(Dispatcher.Invoke(() => { if (string.IsNullOrEmpty(s)) { return null; } Run textRun = new Run(s); if (b != null) { textRun.Foreground = b; } OutputParagraph.Inlines.Add(textRun); // scroll to end only if already scrolled to the bottom. 1.0 is an epsilon value for double comparison if (CompileOutputTextbox.VerticalOffset + CompileOutputTextbox.ViewportHeight >= CompileOutputTextbox.ExtentHeight - 1.0) { CompileOutputTextbox.ScrollToEnd(); } return textRun; })); }
void CompilePalLogger_OnError(string errorText, Error e) { Dispatcher.Invoke(() => { Hyperlink errorLink = new Hyperlink(); Run text = new Run(errorText); text.Foreground = e.ErrorColor; errorLink.Inlines.Add(text); errorLink.TargetName = e.ID.ToString(); errorLink.Click += errorLink_Click; if (CompileOutputTextbox.Document.Blocks.Any()) { var lastPara = (Paragraph)CompileOutputTextbox.Document.Blocks.LastBlock; lastPara.Inlines.Add(errorLink); } else { var newPara = new Paragraph(errorLink); CompileOutputTextbox.Document.Blocks.Add(newPara); } CompileOutputTextbox.ScrollToEnd(); }); }
void Logger_OnWrite(string s, Brush b = null) { Dispatcher.Invoke(() => { if (string.IsNullOrEmpty(s)) { return; } //OutputTab.Focus(); if (b != null) { TextRange tr = new TextRange(CompileOutputTextbox.Document.ContentEnd, CompileOutputTextbox.Document.ContentEnd) { Text = s }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, b); } else { CompileOutputTextbox.AppendText(s); } CompileOutputTextbox.ScrollToEnd(); }); }
void CompilingManager_OnClear() { Dispatcher.Invoke(() => { CompileOutputTextbox.Document.Blocks.Clear(); CompileOutputTextbox.AppendText(Environment.NewLine); }); }
Run Logger_OnWrite(string s, Brush b = null) { return(Dispatcher.Invoke(() => { if (string.IsNullOrEmpty(s)) { return null; } Run textRun = new Run(s); if (b != null) { textRun.Foreground = b; } OutputParagraph.Inlines.Add(textRun); CompileOutputTextbox.ScrollToEnd(); return textRun; })); }