/// <summary> /// Copy constructor used during layout expansion and page break handling. /// </summary> public PhotoLayout(PhotoLayout src) : base(src) { _photo = src._photo; _maxPhotoSize = src._maxPhotoSize; _style = src._style; }
public override void Load(XElement root) { base.Load(root); XNamespace ns = root.GetDefaultNamespace(); _style = _generator.ReportDesign.LoadStyle <PhotoStyle>(root.Element(ns + "Style")); if (_style == null) { _style = _generator.ReportDesign.DefaultPhotoStyle; } // Default to a single column, overrideable by the designer. But if the // design explicitly specifies zero or negative columns then that's an error. _columns = _generator.ReportDesign.LoadInt(root.Element(ns + "Columns")) ?? 1; if (_columns <= 0) { throw new Exception("Photo table must have at least one column."); } // if(_style.MaxWidth <= 0 || _style.MaxHeight <= 0) // throw new Exception("Max photo size cannot be zero or negative."); _maxPhotoSize = new Size(_style.MaxWidth, _style.MaxHeight); _merge = _generator.ReportDesign.LoadBoolean(root.Element(ns + "Merge")) ?? false; }
/// <summary> /// Copy constructor used during layout expansion and page break handling. /// </summary> public PhotoTableLayout(PhotoTableLayout src) : base(src) { _columns = src._columns; _columnWidth = src._columnWidth; _maxPhotoSize = src._maxPhotoSize; _merge = src._merge; _style = src._style; }
public PhotoLayout( Photo photo, Size maxPhotoSize, PhotoStyle style, Generator generator, int lineNumber, int linePosition) : base(generator, lineNumber, linePosition) { _photo = photo; _maxPhotoSize = maxPhotoSize; _style = style; // A photo layout doesn't have its own conditions because it's not // defined in the design file. Any conditions governing the inclusion // of a photo are evaluated in the photo table layout when it loads // its content. So static conditions are implicitly satisfied here. _staticConditionsSatisfied = true; }
private void RenderPhotoTableLayout(PhotoTableLayout table, Page page) { foreach (PhotoRowLayout row in table.SubLayouts) { RenderPhotoRowLayout(row, page); } // Draw borders around the photos (including their captions) PhotoStyle style = (PhotoStyle)table.Style; Border border = style.Border; if (border.Thickness > 0) { List <List <Position> > lines = new List <List <Position> >(); foreach (PhotoRowLayout row in table.SubLayouts) { // The row's bounds includes both photo and caption. Note that // there's no padding possible on a photo table or photo row, // so we don't have to allow for that. int top = row.Bounds.Top; int bottom = row.Bounds.Bottom; for (int col = 0; col < row.NumPhotos; ++col) { int left = row.Bounds.Left + (table.ColumnWdith * col); int right = left + table.ColumnWdith; if ((border.Parts & BorderPart.Left) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(left, top)); line.Add(new Position(left, bottom)); } if ((border.Parts & BorderPart.Right) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(right, top)); line.Add(new Position(right, bottom)); } if ((border.Parts & BorderPart.Top) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(left, top)); line.Add(new Position(right, top)); } if ((border.Parts & BorderPart.Bottom) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(left, bottom)); line.Add(new Position(right, bottom)); } } } Demon.PDF.Color color = Convert.Color(border.Color); foreach (List <Position> line in lines) { page.AddPath(line, border.Thickness, color, null); } //TODO: draw all lines in a single PDF path? } }