using System.Drawing; using System.Xml.Serialization; using System.ComponentModel; namespace Volian.Svg.Library { public partial class SvgText : SvgShapePart { #region ctor public SvgText() { ;} public SvgText(PointF location, string text, Font font, Color fillColor) { X.Value = location.X; Y.Value = location.Y; Text = text; Font = font; FillColor = fillColor; LineColor = Color.Empty; LineWidth = new SvgMeasurement(0); } #endregion #region Location [XmlAttribute("Justify")] public SvgJustify Justify { get; set; } = SvgJustify.Left; [XmlIgnore] public SvgMeasurement X { get; set; } = new SvgMeasurement(); [XmlAttribute("x")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { get { return SvgXmlConverter.GetString(X); } set { X = SvgXmlConverter.GetObject(value); } } [XmlIgnore] public SvgMeasurement Y { get; set; } = new SvgMeasurement(); [XmlAttribute("y")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { get { return SvgXmlConverter.GetString(Y); } set { Y = SvgXmlConverter.GetObject(value); } } #endregion #region Text private string _Text; [XmlText()] public string Text { get { return _Text; } set { _Text = value.Replace("{sp}"," "); } } #endregion #region Font Settings private SvgFontSettings _MyFontSettings = new SvgFontSettings(); [XmlIgnore] public Font Font { get { //if (_MyFontSettings.Font.Size < 10) // Console.WriteLine("It didn't work!"); return _MyFontSettings.Font; } set { //if (value.Size < 10) // Console.WriteLine("It didn't work!"); _MyFontSettings.Font = value; } } [System.ComponentModel.DefaultValueAttribute("")] [XmlAttribute("font-family")] public string FontFamily { get { return _MyFontSettings.FontFamily; } set { _MyFontSettings.FontFamily = value; } } [System.ComponentModel.DefaultValueAttribute("")] [XmlAttribute("font-size")] public string FontSize { get { return _MyFontSettings.FontSize; } set { _MyFontSettings.FontSize = value; } } [System.ComponentModel.DefaultValueAttribute("")] [XmlAttribute("font-style")] public string SVGFontStyle { get { return _MyFontSettings.SVGFontStyle; } set { _MyFontSettings.SVGFontStyle = value; } } [System.ComponentModel.DefaultValueAttribute("")] [XmlAttribute("font-weight")] public string FontWeight { get { return _MyFontSettings.FontWeight; } set { _MyFontSettings.FontWeight = value; } } [System.ComponentModel.DefaultValueAttribute("")] [XmlAttribute("text-decoration")] public string TextDecoration { get { return _MyFontSettings.TextDecoration; } set { _MyFontSettings.TextDecoration = value; } } #endregion #region Description [System.ComponentModel.DefaultValueAttribute("")] [XmlElement("desc")] public string Description { get; set; } = string.Empty; #endregion #region Setup Inheritance override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { base.SetupInheritance(myParentsSettings); _MyFontSettings.MyParentsSettings = myParentsSettings.MyFontSettings; } #endregion public override string ToString() { return string.Format("({0}, {1}) - '{2}'",this.X,this.Y,this.Text); } } public enum SvgJustify { Left = 0, Center = 1, Right =2 } }