#region MigraDoc - Creating Documents on the Fly // // Authors: // Stefan Lange // Klaus Potzesny // David Stephensen // // Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany) // // http://www.pdfsharp.com // http://www.migradoc.com // http://sourceforge.net/projects/pdfsharp // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion using MigraDoc.DocumentObjectModel.publics; using MigraDoc.DocumentObjectModel.Tables; using MigraDoc.DocumentObjectModel.Visitors; namespace MigraDoc.DocumentObjectModel.Shapes.Charts { /// /// An area object in the chart which contain text or legend. /// public class TextArea : ChartObject, IVisitable { /// /// Initializes a new instance of the TextArea class. /// public TextArea() { } /// /// Initializes a new instance of the TextArea class with the specified parent. /// public TextArea(DocumentObject parent) : base(parent) { } #region Methods /// /// Creates a deep copy of this object. /// public new TextArea Clone() { return (TextArea)DeepCopy(); } /// /// Implements the deep copy of the object. /// protected override object DeepCopy() { TextArea textArea = (TextArea)base.DeepCopy(); if (textArea._format != null) { textArea._format = textArea._format.Clone(); textArea._format._parent = textArea; } if (textArea._lineFormat != null) { textArea._lineFormat = textArea._lineFormat.Clone(); textArea._lineFormat._parent = textArea; } if (textArea._fillFormat != null) { textArea._fillFormat = textArea._fillFormat.Clone(); textArea._fillFormat._parent = textArea; } if (textArea._elements != null) { textArea._elements = textArea._elements.Clone(); textArea._elements._parent = textArea; } return textArea; } /// /// Adds a new paragraph to the text area. /// public Paragraph AddParagraph() { return Elements.AddParagraph(); } /// /// Adds a new paragraph with the specified text to the text area. /// public Paragraph AddParagraph(string paragraphText) { return Elements.AddParagraph(paragraphText); } /// /// Adds a new table to the text area. /// public Table AddTable() { return Elements.AddTable(); } /// /// Adds a new Image to the text area. /// public Image AddImage(string fileName) { return Elements.AddImage(fileName); } /// /// Adds a new legend to the text area. /// public Legend AddLegend() { return Elements.AddLegend(); } /// /// Adds a new paragraph to the text area. /// public void Add(Paragraph paragraph) { Elements.Add(paragraph); } /// /// Adds a new table to the text area. /// public void Add(Table table) { Elements.Add(table); } /// /// Adds a new image to the text area. /// public void Add(Image image) { Elements.Add(image); } /// /// Adds a new legend to the text area. /// public void Add(Legend legend) { Elements.Add(legend); } #endregion #region Properties /// /// Gets or sets the height of the area. /// public Unit Height { get { return _height; } set { _height = value; } } [DV] public Unit _height = Unit.NullValue; /// /// Gets or sets the width of the area. /// public Unit Width { get { return _width; } set { _width = value; } } [DV] public Unit _width = Unit.NullValue; /// /// Gets or sets the default style name of the area. /// public string Style { get { return _style.Value; } set { _style.Value = value; } } [DV] public NString _style = NString.NullValue; /// /// Gets or sets the default paragraph format of the area. /// public ParagraphFormat Format { get { return _format ?? (_format = new ParagraphFormat(this)); } set { SetParent(value); _format = value; } } [DV] public ParagraphFormat _format; /// /// Gets the line format of the area's border. /// public LineFormat LineFormat { get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); } set { SetParent(value); _lineFormat = value; } } [DV] public LineFormat _lineFormat; /// /// Gets the background filling of the area. /// public FillFormat FillFormat { get { return _fillFormat ?? (_fillFormat = new FillFormat(this)); } set { SetParent(value); _fillFormat = value; } } [DV] public FillFormat _fillFormat; /// /// Gets or sets the left padding of the area. /// public Unit LeftPadding { get { return _leftPadding; } set { _leftPadding = value; } } [DV] public Unit _leftPadding = Unit.NullValue; /// /// Gets or sets the right padding of the area. /// public Unit RightPadding { get { return _rightPadding; } set { _rightPadding = value; } } [DV] public Unit _rightPadding = Unit.NullValue; /// /// Gets or sets the top padding of the area. /// public Unit TopPadding { get { return _topPadding; } set { _topPadding = value; } } [DV] public Unit _topPadding = Unit.NullValue; /// /// Gets or sets the bottom padding of the area. /// public Unit BottomPadding { get { return _bottomPadding; } set { _bottomPadding = value; } } [DV] public Unit _bottomPadding = Unit.NullValue; /// /// Gets or sets the Vertical alignment of the area. /// public VerticalAlignment VerticalAlignment { get { return (VerticalAlignment)_verticalAlignment.Value; } set { _verticalAlignment.Value = (int)value; } } [DV(Type = typeof(VerticalAlignment))] public NEnum _verticalAlignment = NEnum.NullValue(typeof(VerticalAlignment)); /// /// Gets the document objects that creates the text area. /// public DocumentElements Elements { get { return _elements ?? (_elements = new DocumentElements(this)); } set { SetParent(value); _elements = value; } } [DV(ItemType = typeof(DocumentObject))] public DocumentElements _elements; #endregion #region public /// /// Converts TextArea into DDL. /// public override void Serialize(Serializer serializer) { Chart chartObject = _parent as Chart; serializer.WriteLine("\\" + chartObject.CheckTextArea(this)); int pos = serializer.BeginAttributes(); if (!_style.IsNull) serializer.WriteSimpleAttribute("Style", Style); if (!IsNull("Format")) _format.Serialize(serializer, "Format", null); if (!_topPadding.IsNull) serializer.WriteSimpleAttribute("TopPadding", TopPadding); if (!_leftPadding.IsNull) serializer.WriteSimpleAttribute("LeftPadding", LeftPadding); if (!_rightPadding.IsNull) serializer.WriteSimpleAttribute("RightPadding", RightPadding); if (!_bottomPadding.IsNull) serializer.WriteSimpleAttribute("BottomPadding", BottomPadding); if (!_width.IsNull) serializer.WriteSimpleAttribute("Width", Width); if (!_height.IsNull) serializer.WriteSimpleAttribute("Height", Height); if (!_verticalAlignment.IsNull) serializer.WriteSimpleAttribute("VerticalAlignment", VerticalAlignment); if (!IsNull("LineFormat")) _lineFormat.Serialize(serializer); if (!IsNull("FillFormat")) _fillFormat.Serialize(serializer); serializer.EndAttributes(pos); serializer.BeginContent(); if (_elements != null) _elements.Serialize(serializer); serializer.EndContent(); } /// /// Returns the meta object of this instance. /// public override Meta Meta { get { return _meta ?? (_meta = new Meta(typeof(TextArea))); } } static Meta _meta; #endregion void IVisitable.AcceptVisitor(DocumentObjectVisitor visitor, bool visitChildren) { visitor.VisitTextArea(this); if (_elements != null && visitChildren) ((IVisitable)_elements).AcceptVisitor(visitor, visitChildren); } } }