149 lines
4.4 KiB
C#
149 lines
4.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
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);
|
|
}
|
|
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
|
|
#endregion
|
|
#region Location1
|
|
private SvgMeasurement _X1 = new SvgMeasurement();
|
|
[XmlIgnore]
|
|
public SvgMeasurement X1
|
|
{
|
|
get { return _X1; }
|
|
set { _X1 = value; }
|
|
}
|
|
[XmlAttribute("x1")]
|
|
[Browsable(false)]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public string X1_XmlSurrogate
|
|
{
|
|
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X1); }
|
|
set { _X1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
|
|
}
|
|
private SvgMeasurement _Y1 = new SvgMeasurement();
|
|
[XmlIgnore]
|
|
public SvgMeasurement Y1
|
|
{
|
|
get { return _Y1; }
|
|
set { _Y1 = value; }
|
|
}
|
|
[XmlAttribute("y1")]
|
|
[Browsable(false)]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public string Y1_XmlSurrogate
|
|
{
|
|
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y1); }
|
|
set { _Y1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
|
|
}
|
|
#endregion
|
|
#region Location2
|
|
private SvgMeasurement _X2 = new SvgMeasurement();
|
|
[XmlIgnore]
|
|
public SvgMeasurement X2
|
|
{
|
|
get { return _X2; }
|
|
set { _X2 = value; }
|
|
}
|
|
[XmlAttribute("x2")]
|
|
[Browsable(false)]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public string X2_XmlSurrogate
|
|
{
|
|
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X2); }
|
|
set { _X2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
|
|
}
|
|
private SvgMeasurement _Y2 = new SvgMeasurement();
|
|
[XmlIgnore]
|
|
public SvgMeasurement Y2
|
|
{
|
|
get { return _Y2; }
|
|
set { _Y2 = value; }
|
|
}
|
|
[XmlAttribute("y2")]
|
|
[Browsable(false)]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public string Y_XmlSurrogate
|
|
{
|
|
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y2); }
|
|
set { _Y2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
|
|
}
|
|
#endregion
|
|
#region LineColor
|
|
//protected Color _LineColor = Color.Empty;
|
|
//[XmlIgnoreAttribute()]
|
|
//public Color LineColor
|
|
//{
|
|
// get { return _LineWidth.Value == 0 ? Color.LightGray : _LineColor == Color.Empty ? Color.Gray : _LineColor; }
|
|
// set { _LineColor = value; }
|
|
//}
|
|
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);
|
|
}
|
|
// Serializes the 'BackgroundColor' Color to XML.
|
|
//[System.ComponentModel.DefaultValueAttribute("none")]
|
|
//[XmlAttribute("stroke")]
|
|
//public string Stroke
|
|
//{
|
|
// get { return _LineColor == Color.Empty ? "none" : _LineColor == Color.Black ? "" : ColorTranslator.ToHtml(_LineColor); }
|
|
// set { _LineColor = (value == "none" ? Color.Empty : (value == "" ? Color.Empty : ColorTranslator.FromHtml(value))); }
|
|
//}
|
|
#endregion
|
|
#region LineWidth
|
|
//private SvgMeasurement GetLineWidth()
|
|
//{
|
|
// if (_LineWidth.Value == -1) return new SvgMeasurement(1F);// Minimum Strokewidth
|
|
// if (_LineWidth.Value == 0) return new SvgMeasurement(.01F);// Minimum Strokewidth
|
|
// if (_LineColor == Color.Empty) return new SvgMeasurement( .01F);// No Color - Minimum Strokewidth
|
|
// return _LineWidth;
|
|
//}
|
|
//private SvgMeasurement _LineWidth = new SvgMeasurement();
|
|
//[XmlIgnore]
|
|
//public SvgMeasurement LineWidth
|
|
//{
|
|
// get { return _LineWidth; }
|
|
// set { _LineWidth = value; }
|
|
//}
|
|
//[XmlAttribute("stroke-width")]
|
|
//[Browsable(false)]
|
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
|
//public string LineWidth_XmlSurrogate
|
|
//{
|
|
// get
|
|
// {
|
|
// if (_LineWidth.Value == -1)
|
|
// return "none";
|
|
// return VolianXmlConverter<SvgMeasurement>.GetString(_LineWidth);
|
|
// }
|
|
// set
|
|
// {
|
|
// if (value == "none")
|
|
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject("-1");
|
|
// else
|
|
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject(value);
|
|
// }
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|