157 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Text;
 | 
						|
using System.Drawing;
 | 
						|
using System.Drawing.Drawing2D;
 | 
						|
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
 | 
						|
		private SvgJustify _Justify = SvgJustify.Left;
 | 
						|
		[XmlAttribute("Justify")]
 | 
						|
		public SvgJustify Justify
 | 
						|
		{
 | 
						|
			get { return _Justify; }
 | 
						|
			set { _Justify = value; }
 | 
						|
		}
 | 
						|
		private SvgMeasurement _X = new SvgMeasurement();
 | 
						|
		[XmlIgnore]
 | 
						|
		public SvgMeasurement X
 | 
						|
		{
 | 
						|
			get { return _X; }
 | 
						|
			set { _X = value; }
 | 
						|
		}
 | 
						|
		[XmlAttribute("x")]
 | 
						|
		[Browsable(false)]
 | 
						|
		[EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
		public string X_XmlSurrogate
 | 
						|
		{
 | 
						|
			get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); }
 | 
						|
			set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
 | 
						|
		}
 | 
						|
		private SvgMeasurement _Y = new SvgMeasurement();
 | 
						|
		[XmlIgnore]
 | 
						|
		public SvgMeasurement Y
 | 
						|
		{
 | 
						|
			get { return _Y; }
 | 
						|
			set { _Y = value; }
 | 
						|
		}
 | 
						|
		[XmlAttribute("y")]
 | 
						|
		[Browsable(false)]
 | 
						|
		[EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
		public string Y_XmlSurrogate
 | 
						|
		{
 | 
						|
			get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); }
 | 
						|
			set { _Y = SvgXmlConverter<SvgMeasurement>.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
 | 
						|
		private string _Description = string.Empty;
 | 
						|
		[System.ComponentModel.DefaultValueAttribute("")]
 | 
						|
		[XmlElement("desc")]
 | 
						|
		public string Description
 | 
						|
		{
 | 
						|
			get { return _Description; }
 | 
						|
			set { _Description = value; }
 | 
						|
		}
 | 
						|
		#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
 | 
						|
	}
 | 
						|
}
 |