private async Task ReaderListenerAsync() { while (!UpdateChannel.Reader.Completion.IsCompleted) { var ui = await UpdateChannel.Reader.ReadAsync(); for (var i = 0; i < ui.NumLineInfos; i++) { LineInfos2.AddLast(ui.LineInfos[i]); } // fixme //CharInfos.AddRange(ui.CharInfos); var dg = ui.DrawingGroup; var dg2 = new DrawingGroup(); foreach (var dgChild in dg.Children) { dg2.Children.Add(dgChild); } TextDestination.Children.Add(dg2); var uiRect = dg2.Bounds; _debugFn?.Invoke($"UIRect is {uiRect}"); var maxY = Math.Max(MaxY, uiRect.Bottom); MaxY = maxY; var maxX = Math.Max(MaxX, uiRect.Right); MaxX = maxX; var boundsLeft = Math.Min(TextDestination.Bounds.Left, 0) - Rectangle?.StrokeThickness ?? 0; boundsLeft -= 3; var boundsTop = Math.Min(TextDestination.Bounds.Top, 0) - Rectangle?.StrokeThickness ?? 0; boundsTop -= 3; var width = maxX - boundsLeft; var height = maxY - boundsTop; DrawingBrush.Viewbox = DrawingBrushViewbox = new Rect(boundsLeft, boundsTop, width, height); if (Rectangle == null) { continue; } Rectangle.Width = width + Rectangle.StrokeThickness; Rectangle.Height = height + Rectangle.StrokeThickness; } }
/// <inheritdoc /> public virtual void Reset() { LineInfos2.Clear(); Rectangle.Width = 0; Rectangle.Height = 0; }