This commit is contained in:
167
PROMS/Volian.Svg.Library/SvgLineSettings.cs
Normal file
167
PROMS/Volian.Svg.Library/SvgLineSettings.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user