private static void AdjustVerticaly(Rectangle textBounds, List <SMWordLine> drawWords, SMVerticalAlign valign) { int col = -1; int pg = -1; List <SMWordLine> lines = new List <SMWordLine>(); foreach (SMWordLine wl in drawWords) { if (wl.Count > 0) { if (col < 0) { col = wl[0].ColumnNo; } if (pg < 0) { pg = wl[0].PageNo; } if (wl[0].ColumnNo != col || wl[0].PageNo != pg) { AdjustLinesVerticaly(textBounds, lines, valign); col = wl[0].ColumnNo; pg = wl[0].PageNo; lines.Clear(); } lines.Add(wl); } } if (lines.Count > 0) { AdjustLinesVerticaly(textBounds, lines, valign); } }
private static void AdjustLinesVerticaly(Rectangle textBounds, List <SMWordLine> drawWords, SMVerticalAlign valign) { float diff = 0f; float lineY = 0; float lineTop = 10000; foreach (SMWordLine wl in drawWords) { foreach (SMWordBase wb in wl) { lineTop = Math.Min(wb.rect.Top, lineTop); lineY = Math.Max(wb.rect.Bottom, lineY); } } switch (valign) { case SMVerticalAlign.Center: diff = (textBounds.Bottom + textBounds.Top) / 2 - (lineY + lineTop) / 2; break; case SMVerticalAlign.Bottom: diff = (textBounds.Bottom - lineY); break; } if (diff != 0) { foreach (SMWordLine wt in drawWords) { foreach (SMWordBase wbase in wt) { wbase.rect.Y += diff; } } } }
private static void AdjustLinesVerticaly(Rectangle textBounds, List <SMTextContainerLine> drawWords, SMVerticalAlign valign) { float diff = 0f; float textBottom = 0; float textTop = 10000; foreach (SMTextContainerLine line in drawWords) { foreach (SMTextContainerWord wb in line) { textTop = Math.Min(wb.rect.Top, textTop); textBottom = Math.Max(wb.rect.Bottom, textBottom); } } switch (valign) { case SMVerticalAlign.Center: diff = (textBounds.Bottom + textBounds.Top) / 2 - (textBottom + textTop) / 2; break; case SMVerticalAlign.Bottom: diff = (textBounds.Bottom - textBottom); break; } if (diff != 0) { foreach (SMTextContainerLine wt in drawWords) { foreach (SMTextContainerWord wbase in wt) { wbase.rect.Y += (int)diff; } } } }