/// <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 override Layout MergeContent(Layout other) { if (_merge) { PhotoTableLayout src = other as PhotoTableLayout; if (src != null) { // Move the source's photos into us _photos.AddRange(src._photos); src._photos.Clear(); } } return(base.MergeContent(this)); }
private void RenderPhotoTable(PhotoTableLayout layout, IContentContainer container) { // Create a table s.TableStyle tableStyle = null; if (layout.Style != null) { s.PhotoStyle photoStyle = (s.PhotoStyle)layout.Style; tableStyle = new s.TableStyle { Border = photoStyle.Border, Padding = photoStyle.Padding }; } int columnWidth = layout.Bounds.Width / layout.NumColumns; int[] columnWidths = new int[layout.NumColumns]; for (int x = 0; x < columnWidths.Length; ++x) { columnWidths[x] = columnWidth; } ITable table = container.AddTable(layout.Bounds.Width, columnWidths, tableStyle, layout.TrackingInfo); // Create a table row for each photo row foreach (PhotoRowLayout photoRow in layout.SubLayouts) { s.TableRowStyle rowStyle = null; if (photoRow.Style != null) { s.PhotoStyle photoStyle = (s.PhotoStyle)photoRow.Style; rowStyle = new s.TableRowStyle { BackColor = photoRow.BackgroundColor, Padding = photoStyle.Padding }; } ITableRow tableRow = table.AddRow(rowStyle, photoRow.TrackingInfo); RenderPhotoRow(photoRow, tableRow); } }
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? } }
/// <summary> /// Return a user-friendly navigation path from the /// root of a document to a particular control. /// </summary> /// <param name="path">The path is returned in this list. The list is /// sorted in reverse order, working up from the control to the document. /// </param> internal void GetObjectPath(ControlType controlType, string controlId, List <string> path) { switch (controlType) { case ControlType.Section: { Section section = _unitOfWork.Repository <Section>().GetById(controlId); if (!string.IsNullOrWhiteSpace(section.Title)) { path.Add(section.Title); } if (section.ParentSectionId != null) { GetObjectPath(ControlType.Section, section.ParentSectionId, path); } break; } case ControlType.Checkbox: { Checkbox checkbox = _unitOfWork.Repository <Checkbox>().GetById(controlId); if (!string.IsNullOrWhiteSpace(checkbox.Caption)) { path.Add(checkbox.Caption); } GetObjectPath(ControlType.MultiSelect, checkbox.ListId, path); break; } case ControlType.RadioButton: { RadioButton radioButton = _unitOfWork.Repository <RadioButton>().GetById(controlId); if (!string.IsNullOrWhiteSpace(radioButton.Caption)) { path.Add(radioButton.Caption); } GetObjectPath(ControlType.SingleSelect, radioButton.ListId, path); break; } case ControlType.MultiSelect: { MultiSelectList list = _unitOfWork.Repository <MultiSelectList>().GetById(controlId); if (!string.IsNullOrWhiteSpace(list.Caption)) { path.Add(list.Caption); } GetObjectPath(ControlType.Form, list.FormId, path); break; } case ControlType.SingleSelect: { SingleSelectList list = _unitOfWork.Repository <SingleSelectList>().GetById(controlId); if (!string.IsNullOrWhiteSpace(list.Caption)) { path.Add(list.Caption); } GetObjectPath(ControlType.Form, list.FormId, path); break; } case ControlType.Photo: { Photo photo = _unitOfWork.Repository <Photo>().GetById(controlId); string caption = PhotoTableLayout.GetPhotoCaption(photo, this); if (!string.IsNullOrWhiteSpace(caption)) { path.Add(caption); } GetObjectPath(ControlType.PhotoList, photo.ListId, path); break; } case ControlType.PhotoList: { PhotoList list = _unitOfWork.Repository <PhotoList>().GetById(controlId); // There's nothing useful to say about the photo list itself GetObjectPath(ControlType.Form, list.FormId, path); break; } case ControlType.Form: { Form form = _unitOfWork.Repository <Form>().GetById(controlId); if (!string.IsNullOrWhiteSpace(form.Description)) { path.Add(form.Description); } GetObjectPath((ControlType)form.TriggerType, form.TriggerId, path); break; } } }