Ejemplo n.º 1
0
        protected override void AddAttributes(XElement xmlElement)
        {
            if (sourceField == null && !string.IsNullOrEmpty(text))
            {
                AddAttribute("text", text, xmlElement);
            }

            if (sourceField != null)
            {
                AddAttribute("sourceField", sourceField, xmlElement, true);
            }

            if (string.IsNullOrEmpty(sourceFormat) && !string.IsNullOrEmpty(format))
            {
                AddAttribute("format", format, xmlElement);
            }

            if (!string.IsNullOrEmpty(sourceFormat))
            {
                AddAttribute("sourceFormat", sourceFormat, xmlElement);
            }

            var defaultFont = new ObjectFont();

            if (font != defaultFont)
            {
                AddAttribute("font", font.ToString(defaultFont), xmlElement);
            }

            if (Trimming != StringTrimming.None)
            {
                AddAttribute("trimming", trimming.ToString(), xmlElement);
            }

            if (wrap)
            {
                AddAttribute("wrap", "true", xmlElement);
            }

            base.AddAttributes(xmlElement);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Implements caching of the measured sizes as this operation is one of the slowest
        /// and is likelly to be repeatedly called with same values
        /// </summary>
        /// <param name="width">Horizontal space available</param>
        /// <returns></returns>
        private SizeD MeasureString(double?width)
        {
            if (width == null)
            {
                if (lastText != Text || lastFont != font || lastSize == null)
                {
                    lastText = Text;
                    lastFont = font;
                    lastSize = DocumentHelper.DrawingProvider.MeasureString(Text, font, null);
                }
                return(lastSize.Value);
            }

            if (lastWrappedText != Text || lastWrappedFont != font || lastWidth != width || lastWrappedSize == null)
            {
                lastWrappedText = Text;
                lastWrappedFont = font;
                lastWidth       = width;
                lastWrappedSize = DocumentHelper.DrawingProvider.MeasureString(Text, font, width);
            }
            return(lastWrappedSize.Value);
        }
Ejemplo n.º 3
0
        public string ToString(ObjectFont defaultObjectFont)
        {
            StringBuilder sb = new StringBuilder();

            if (name != defaultObjectFont.name)
            {
                sb.AppendFormat("name:{0};", name);
            }

            if (!Number.IsEqualTo(size, defaultObjectFont.size))
            {
                sb.AppendFormat("size:{0};", size);
            }

            if (underline != defaultObjectFont.underline)
            {
                sb.AppendFormat("underline:{0};", underline.ToString().ToLowerInvariant());
            }

            if (bold != defaultObjectFont.bold)
            {
                sb.AppendFormat("bold:{0};", bold.ToString().ToLowerInvariant());
            }

            if (italic != defaultObjectFont.italic)
            {
                sb.AppendFormat("italic:{0};", italic.ToString().ToLowerInvariant());
            }

            if (strikeThrought != defaultObjectFont.strikeThrought)
            {
                sb.AppendFormat("strikethrough:{0};", strikeThrought.ToString().ToLowerInvariant());
            }

            return(sb.ToString().TrimEnd(';'));
        }
Ejemplo n.º 4
0
 private XElement AddTemplate(ICollection <FormObject> template, string templateName, ObjectFont templateFont, ObjectStyle templateStyle)
 {
     if (template.Count > 0)
     {
         XElement templateElement = new XElement(templateName);
         if (templateFont != null)
         {
             AddAttribute("font", templateFont, templateElement);
         }
         if (templateStyle != null)
         {
             AddAttribute("style", templateStyle.ToString(DefaultStyle), templateElement);
         }
         foreach (FormObject childObject in template)
         {
             templateElement.Add(childObject.GetXmlElement());
         }
         return(templateElement);
     }
     return(null);
 }