private StringFormat GetFromBlock(Block block) { StringFormat fmt = new StringFormat(); if (block.VerticalContentAlignment == VerticalAlignment.Top) { fmt.LineAlignment = StringAlignment.Near; } else if (block.VerticalContentAlignment == VerticalAlignment.Middle) { fmt.LineAlignment = StringAlignment.Center; } else { fmt.LineAlignment = StringAlignment.Far; } return fmt; }
private void DrawBlock(Block block) { RectangleF bounds = new RectangleF(this.CurrentX, this.CurrentY, 0, 0); if (block.Content is String) { Rect b = block.Bounds; PrintElementBase parent = (PrintElementBase)block.Parent; b.Width = printArgs.PageBounds.Width - parent.Bounds.Width ; b.Height = parent.Bounds.Height -this.CurrentY; block.Bounds = b; DrawContentString(block); bounds = this.Rect2Rectangle(block.Bounds); return; } if (block.Childs.Count > 0) { PrintElementBase prev = null; foreach (PrintElementBase current in block.Childs) { if (current is LineBreak) { DrawLineBreak((LineBreak)current,prev); } else current.Render(this); prev = current; if (bounds.Right < current.Bounds.Right) { bounds.Width = (current.Bounds.Right - bounds.Right) - bounds.Left; } if (bounds.Bottom < current.Bounds.Bottom) { bounds.Height = (current.Bounds.Bottom - bounds.Bottom) - bounds.Top; } block.Bounds = this.Rectangle2Rect(bounds); } } block.Bounds = this.Rectangle2Rect(bounds); this.currentY = bounds.Bottom; this.currentX = bounds.Right; }