private async void OnShowFrameCodeMap(object sender, CodeMapEventArgs e) { var lines = await e.GetCodesAsync(); // Create a FlowDocument var mcFlowDoc = new FlowDocument(); if (lines == null || !lines.Any()) { mcFlowDoc.Blocks.Add(new Paragraph(new Bold(new Run("File Not Found !!!"))) { FontSize = 50, TextAlignment = TextAlignment.Center, Background = ExceptionLineBackground }); TxtCodes.Document = mcFlowDoc; LblAddress.Text = string.IsNullOrEmpty(e.CodeAddress.FilePath) ? "File Not Found !!!" : e.CodeAddress.FilePath; return; } LblAddress.Text = "File Path: " + e.CodeAddress.FilePath; LblAddress.ToolTip = LblAddress.Text; // Add paragraphs to the FlowDocument. mcFlowDoc.Blocks.Add(new Paragraph(new Run(string.Join(Environment.NewLine, lines.Take(e.CodeAddress.Line - 1))))); mcFlowDoc.Blocks.Add(new Paragraph(new Bold(new Run(lines[e.CodeAddress.Line - 1]))) { FontSize = ExceptionCodeFontSize, Background = ExceptionLineBackground }); mcFlowDoc.Blocks.Add(new Paragraph(new Run(string.Join(Environment.NewLine, lines.Skip(e.CodeAddress.Line))))); TxtCodes.Document = mcFlowDoc; if (!TextWrapping) { TxtCodes.Document.PageWidth = lines.Max(x => x.Length) * TxtCodes.FontSize; } var offset = (e.CodeAddress.Line * (TxtCodes.FontSize + 1.96)) - TxtCodes.ActualHeight / 2; TxtCodes.ScrollToVerticalOffset(offset); }
private async void OnShowFrameCodeMap(object sender, CodeMapEventArgs e) { var lines = await e.GetCodesAsync(); // Create a FlowDocument var mcFlowDoc = new FlowDocument(); if (lines == null || !lines.Any()) { mcFlowDoc.Blocks.Add(new Paragraph(new Bold(new Run("File Not Found !!!"))) { FontSize = 50, TextAlignment = TextAlignment.Center, Background = ExceptionLineBackground }); TxtCodes.Document = mcFlowDoc; LblAddress.Text = string.IsNullOrEmpty(e.CodeAddress.FilePath) ? "File Not Found !!!" : e.CodeAddress.FilePath; return; } LblAddress.Text = "File Path: " + e.CodeAddress.FilePath; LblAddress.ToolTip = LblAddress.Text; // Add paragraphs to the FlowDocument. mcFlowDoc.Blocks.Add(new Paragraph(new Run(string.Join(Environment.NewLine, lines.Take(e.CodeAddress.Line - 1))))); mcFlowDoc.Blocks.Add(new Paragraph(new Bold(new Run(lines[e.CodeAddress.Line - 1]))) { FontSize = ExceptionCodeFontSize, Background = ExceptionLineBackground }); mcFlowDoc.Blocks.Add(new Paragraph(new Run(string.Join(Environment.NewLine, lines.Skip(e.CodeAddress.Line))))); TxtCodes.Document = mcFlowDoc; if (!TextWrapping) TxtCodes.Document.PageWidth = lines.Max(x => x.Length) * TxtCodes.FontSize; var offset = (e.CodeAddress.Line * (TxtCodes.FontSize + 1.96)) - TxtCodes.ActualHeight / 2; TxtCodes.ScrollToVerticalOffset(offset); }