SourceCode/PROMS/Volian.Svg.Library/SvgLineSettings.cs
2010-03-25 19:38:51 +00:00

168 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
namespace Volian.Svg.Library
{
public class SvgLineSettings
{
#region ctor
public SvgLineSettings() { ;}
public SvgLineSettings(Color myColor, SvgMeasurement myWidth)
{
_Stroke = ColorTranslator.ToHtml(myColor);
_StrokeWidth = myWidth.ToString();
}
//public SvgLineSettings(string myStroke, string myStrokeWidth)
//{
// _Stroke = myStroke;
// _StrokeWidth = myStrokeWidth;
//}
#endregion
#region Inheritance
private SvgLineSettings _MyParentsSettings = null;
public SvgLineSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion
#region Internal Inherited Properties
protected string InheritedStroke
{
get
{
// Stroke = "", "0" - Default, otherwise the value
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
}
}
//protected string InheritedOutlineWidth
//{
// get
// {
// // StrokeWidth = "", "none" - Default, otherwise the value
// if (_StrokeWidth != "" && _StrokeWidth.ToLower() != "none") return _StrokeWidth; // Current Value
// if (_MyParent != null) return _MyParent.InheritedLineWidth; // Inherited
// return "1PX"; // Default
// }
//}
#endregion
#region Inherited Values
public SvgMeasurement LineWidth
{
get
{
// Stroke = "None" - Light, otherwise the value
// StrokeWidth = "None" Light, otherwise the value
string myStroke = InheritedStroke;
string myWidth = InheritedLineWidth;
//if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none") // Light
// return new SvgMeasurement(.001F, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement;
}
set
{
_StrokeWidth = value.ToString();
}
}
public SvgMeasurement OutlineWidth
{
get
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate
return new SvgMeasurement(0, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement;
}
set
{
_StrokeWidth = value.ToString();
}
}
public Color LineColor
{
get
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "None" Eliminate, otherwise the value
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
{
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
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
private string _Stroke = string.Empty; // Default value is None
public string Stroke
{
get { return _Stroke; }
set { _Stroke = value; }
}
private string _StrokeWidth = string.Empty; // Default value is 1PX
public string StrokeWidth
{
get { return _StrokeWidth; }
set { _StrokeWidth = value; }
}
#endregion
}
}