using System; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; namespace Volian.Svg.Library { public partial class SvgLine : SvgLinePart { #region ctor public SvgLine() { ;} public SvgLine(PointF location1, PointF location2, Color lineColor, float lineWidth) { X1.Value = location1.X; Y1.Value = location1.Y; X2.Value = location2.X; Y2.Value = location2.Y; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } #endregion #region Location1 [XmlIgnore] public SvgMeasurement X1 { get; set; } = new SvgMeasurement(); [XmlAttribute("x1")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X1_XmlSurrogate { get { return SvgXmlConverter.GetString(X1); } set { X1 = SvgXmlConverter.GetObject(value); } } [XmlIgnore] public SvgMeasurement Y1 { get; set; } = new SvgMeasurement(); [XmlAttribute("y1")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y1_XmlSurrogate { get { return SvgXmlConverter.GetString(Y1); } set { Y1 = SvgXmlConverter.GetObject(value); } } #endregion #region Location2 [XmlIgnore] public SvgMeasurement X2 { get; set; } = new SvgMeasurement(); [XmlAttribute("x2")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X2_XmlSurrogate { get { return SvgXmlConverter.GetString(X2); } set { X2 = SvgXmlConverter.GetObject(value); } } [XmlIgnore] public SvgMeasurement Y2 { get; set; } = new SvgMeasurement(); [XmlAttribute("y2")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { get { return SvgXmlConverter.GetString(Y2); } set { Y2 = SvgXmlConverter.GetObject(value); } } #endregion #region Description [System.ComponentModel.DefaultValueAttribute("")] [XmlElement("desc")] public string Description { get; set; } = string.Empty; #endregion #region LineColor private Color AdjustColorForWidth(Color myColor, float myWidth) { if (myWidth > 1F) return myColor; //Console.WriteLine("Line Width = {0}, Alpha = {1}", myWidth, Convert.ToInt32(myWidth * 255)); return Color.FromArgb(Convert.ToInt32(myWidth * 255), myColor); } #endregion } }