using System.Drawing; namespace Volian.Svg.Library { public class SvgLineSettings { #region ctor public SvgLineSettings() { ;} public SvgLineSettings(Color myColor, SvgMeasurement myWidth) { Stroke = ColorTranslator.ToHtml(myColor); StrokeWidth = myWidth.ToString(); } #endregion #region Inheritance public SvgLineSettings MyParentsSettings { get; set; } = null; #endregion #region Internal Inherited Properties protected string InheritedStroke { get { if (Stroke != "" && Stroke != "0") return Stroke; // Current Value if (MyParentsSettings != null) return MyParentsSettings.InheritedStroke;// Inherited return "None"; // Default } } protected string InheritedLineWidth { get { // StrokeWidth = "", "none" - Default, otherwise the value if (StrokeWidth != "" && StrokeWidth != "none") return StrokeWidth; // Current Value if (MyParentsSettings != null) return MyParentsSettings.InheritedLineWidth; // Inherited return "1PX"; // Default } } #endregion #region Inherited Values public SvgMeasurement LineWidth { get { string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); return myMeasurement; } set { StrokeWidth = value.ToString(); } } public SvgMeasurement OutlineWidth { get { string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate return new SvgMeasurement(0, E_MeasurementUnits.PX); SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); return myMeasurement; } set { StrokeWidth = value.ToString(); } } public Color LineColor { get { string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none" || myWidth == "0") // Light return Color.LightGray; return ColorTranslator.FromHtml(myStroke); } set { if (value == Color.Empty) Stroke = "none"; else Stroke = ColorTranslator.ToHtml(value); } } public Color OutlineColor { get { string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate return Color.Empty; return ColorTranslator.FromHtml(myStroke); } set { if (value == Color.Empty) Stroke = "none"; else Stroke = ColorTranslator.ToHtml(value); } } #endregion #region Properties public string Stroke { get; set; } = string.Empty; public string StrokeWidth { get; set; } = string.Empty; #endregion } }