public static List <Paragraph> Flow(TextBox textBox, Win32DCSafeHandle hdc, float dpiX, FontCache fontCache, FlowContext flowContext, bool keepLines, out float height) { if (!(flowContext.Height <= 0.0) && !(flowContext.Width <= 0.0)) { int num = TextBox.ConvertToPixels(flowContext.ContentOffset, dpiX); int pixels = num; TextBoxContext context = flowContext.Context; RPLFormat.Directions direction = textBox.TextBoxProps.Direction; List <Paragraph> list = new List <Paragraph>(); Win32ObjectSafeHandle win32ObjectSafeHandle = Win32.SelectObject(hdc, Win32ObjectSafeHandle.Zero); SizeF flowContextSize; if (textBox.VerticalText) { flowContext.VerticalCanGrow = textBox.TextBoxProps.CanGrow; flowContextSize = new SizeF((float)TextBox.ConvertToPixels(flowContext.Height, dpiX), (float)TextBox.ConvertToPixels(flowContext.Width, dpiX)); } else { flowContextSize = new SizeF((float)TextBox.ConvertToPixels(flowContext.Width, dpiX), (float)TextBox.ConvertToPixels(flowContext.Height, dpiX)); } fontCache.WritingMode = textBox.TextBoxProps.WritingMode; try { while (context.ParagraphIndex < textBox.Paragraphs.Count) { Paragraph paragraph = textBox.Paragraphs[context.ParagraphIndex]; paragraph.OffsetY = num; bool flag = LineBreaker.FlowParagraph(paragraph, direction, hdc, dpiX, fontCache, flowContext, keepLines, flowContextSize, ref pixels); num += paragraph.Height; if (!keepLines) { paragraph.TextLines = null; } if (!flag) { break; } list.Add(paragraph); if ((float)num >= flowContextSize.Height) { if (paragraph.AtEndOfParagraph(context)) { context.IncrementParagraph(); } break; } context.IncrementParagraph(); } if ((float)num < flowContextSize.Height) { flowContext.AtEndOfTextBox = true; } } finally { if (!win32ObjectSafeHandle.IsInvalid) { Win32ObjectSafeHandle win32ObjectSafeHandle2 = Win32.SelectObject(hdc, win32ObjectSafeHandle); win32ObjectSafeHandle2.SetHandleAsInvalid(); win32ObjectSafeHandle.SetHandleAsInvalid(); } } height = TextBox.ConvertToMillimeters(num, dpiX); flowContext.ContentOffset = TextBox.ConvertToMillimeters(pixels, dpiX); return(list); } height = 0f; return(null); }