Commit ee95905a authored by Josh McCullough's avatar Josh McCullough
Browse files

Fixed many attribute enums. Now they will 1) output the proper case, 2) only...

Fixed many attribute enums. Now they will 1) output the proper case, 2) only output if non-null and non-default, 3) include more documentation, 4) are marked as Flags where appropriate.
parent e4cb89ac
......@@ -85,13 +85,12 @@ namespace Svg
private bool IsInheritValue(object value)
{
return (value == null ||
(value is SvgFontStyle && (SvgFontStyle)value == SvgFontStyle.inherit) ||
(value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.inherit) ||
(value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.inherit) ||
(value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.inherit) ||
(value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.inherit) ||
(value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.Inherit) ||
(value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.Inherit) ||
(value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.Inherit) ||
(value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.Inherit) ||
(value is XmlSpaceHandling && (XmlSpaceHandling)value == XmlSpaceHandling.inherit) ||
(value is SvgOverflow && (SvgOverflow)value == SvgOverflow.inherit) ||
(value is SvgOverflow && (SvgOverflow)value == SvgOverflow.Inherit) ||
(value == SvgColourServer.Inherit) ||
(value is string && (string)value == "inherit")
);
......
......@@ -475,7 +475,7 @@ namespace Svg
renderer.ScaleTransform(bitmap.Width / size.Width, bitmap.Height / size.Height);
//EO, 2014-12-05: Requested to ensure proper zooming out (reduce size). Otherwise it clip the image.
this.Overflow = SvgOverflow.auto;
this.Overflow = SvgOverflow.Auto;
this.Render(renderer);
}
......
......@@ -572,9 +572,11 @@ namespace Svg
(!attr.Attribute.InAttributeDictionary || _attributes.ContainsKey(attr.Attribute.Name)))
{
object propertyValue = attr.Property.GetValue(this);
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
forceWrite = false;
writeStyle = (attr.Attribute.Name == "fill");
if ((attr.Attribute.Name == "fill") && (Parent != null))
{
if(propertyValue == SvgColourServer.NotSet) continue;
......@@ -593,9 +595,9 @@ namespace Svg
if (propertyValue != null)
{
var type = propertyValue.GetType();
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
if (!SvgDefaults.IsDefault(attr.Attribute.Name, value) || forceWrite)
//Only write the attribute's value if it is not the default value, not null/empty, or we're forcing the write.
if ((!string.IsNullOrEmpty(value) && !SvgDefaults.IsDefault(attr.Attribute.Name, value)) || forceWrite)
{
if (writeStyle)
{
......@@ -609,7 +611,6 @@ namespace Svg
}
else if(attr.Attribute.Name == "fill") //if fill equals null, write 'none'
{
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
if (writeStyle)
{
styles[attr.Attribute.Name] = value;
......
......@@ -173,7 +173,7 @@ namespace Svg
[SvgAttribute("font-style", true)]
public virtual SvgFontStyle FontStyle
{
get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.inherit : (SvgFontStyle)this.Attributes["font-style"]; }
get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.All : (SvgFontStyle)this.Attributes["font-style"]; }
set { this.Attributes["font-style"] = value; this.IsPathDirty = true; }
}
......@@ -183,7 +183,7 @@ namespace Svg
[SvgAttribute("font-variant", true)]
public virtual SvgFontVariant FontVariant
{
get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.Inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
set { this.Attributes["font-variant"] = value; this.IsPathDirty = true; }
}
......@@ -193,7 +193,7 @@ namespace Svg
[SvgAttribute("text-decoration", true)]
public virtual SvgTextDecoration TextDecoration
{
get { return (this.Attributes["text-decoration"] == null) ? SvgTextDecoration.inherit : (SvgTextDecoration)this.Attributes["text-decoration"]; }
get { return (this.Attributes["text-decoration"] == null) ? SvgTextDecoration.Inherit : (SvgTextDecoration)this.Attributes["text-decoration"]; }
set { this.Attributes["text-decoration"] = value; this.IsPathDirty = true; }
}
......@@ -203,7 +203,7 @@ namespace Svg
[SvgAttribute("font-weight", true)]
public virtual SvgFontWeight FontWeight
{
get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.Inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
set { this.Attributes["font-weight"] = value; this.IsPathDirty = true; }
}
......@@ -328,12 +328,12 @@ namespace Svg
// Get the font-weight
switch (this.FontWeight)
{
case SvgFontWeight.bold:
case SvgFontWeight.bolder:
case SvgFontWeight.w600:
case SvgFontWeight.w700:
case SvgFontWeight.w800:
case SvgFontWeight.w900:
//Note: Bold is not listed because it is = W700.
case SvgFontWeight.Bolder:
case SvgFontWeight.W600:
case SvgFontWeight.W700:
case SvgFontWeight.W800:
case SvgFontWeight.W900:
fontStyle |= System.Drawing.FontStyle.Bold;
break;
}
......@@ -341,8 +341,8 @@ namespace Svg
// Get the font-style
switch (this.FontStyle)
{
case SvgFontStyle.italic:
case SvgFontStyle.oblique:
case SvgFontStyle.Italic:
case SvgFontStyle.Oblique:
fontStyle |= System.Drawing.FontStyle.Italic;
break;
}
......@@ -350,10 +350,10 @@ namespace Svg
// Get the text-decoration
switch (this.TextDecoration)
{
case SvgTextDecoration.lineThrough:
case SvgTextDecoration.LineThrough:
fontStyle |= System.Drawing.FontStyle.Strikeout;
break;
case SvgTextDecoration.underline:
case SvgTextDecoration.Underline:
fontStyle |= System.Drawing.FontStyle.Underline;
break;
}
......
......@@ -84,7 +84,7 @@ namespace Svg
[SvgAttribute("font-style")]
public virtual SvgFontStyle FontStyle
{
get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.inherit : (SvgFontStyle)this.Attributes["font-style"]; }
get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.All : (SvgFontStyle)this.Attributes["font-style"]; }
set { this.Attributes["font-style"] = value; }
}
......@@ -94,7 +94,7 @@ namespace Svg
[SvgAttribute("font-variant")]
public virtual SvgFontVariant FontVariant
{
get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.Inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
set { this.Attributes["font-variant"] = value; }
}
......@@ -104,7 +104,7 @@ namespace Svg
[SvgAttribute("font-weight")]
public virtual SvgFontWeight FontWeight
{
get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.Inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
set { this.Attributes["font-weight"] = value; }
}
......
......@@ -12,7 +12,8 @@ namespace Svg
[TypeConverter(typeof(SvgTextAnchorConverter))]
public enum SvgTextAnchor
{
inherit,
/// <summary>The value is inherited from the parent element.</summary>
Inherit,
/// <summary>
/// The rendered characters are aligned such that the start of the text string is at the initial current text position.
/// </summary>
......
......@@ -36,7 +36,7 @@ namespace Svg
[SvgAttribute("text-anchor", true)]
public virtual SvgTextAnchor TextAnchor
{
get { return (this.Attributes["text-anchor"] == null) ? SvgTextAnchor.inherit : (SvgTextAnchor)this.Attributes["text-anchor"]; }
get { return (this.Attributes["text-anchor"] == null) ? SvgTextAnchor.Inherit : (SvgTextAnchor)this.Attributes["text-anchor"]; }
set { this.Attributes["text-anchor"] = value; this.IsPathDirty = true; }
}
......@@ -167,7 +167,7 @@ namespace Svg
[SvgAttribute("lengthAdjust", true)]
public virtual SvgTextLengthAdjust LengthAdjust
{
get { return (this.Attributes["lengthAdjust"] == null) ? SvgTextLengthAdjust.spacing : (SvgTextLengthAdjust)this.Attributes["lengthAdjust"]; }
get { return (this.Attributes["lengthAdjust"] == null) ? SvgTextLengthAdjust.Spacing : (SvgTextLengthAdjust)this.Attributes["lengthAdjust"]; }
set { this.Attributes["lengthAdjust"] = value; this.IsPathDirty = true; }
}
......@@ -365,7 +365,7 @@ namespace Svg
var diff = (actLength - specLength);
if (Math.Abs(diff) > 1.5)
{
if (this.LengthAdjust == SvgTextLengthAdjust.spacing)
if (this.LengthAdjust == SvgTextLengthAdjust.Spacing)
{
origState.LetterSpacingAdjust = -1 * diff / (state.NumChars - origState.NumChars - 1);
SetPath(origState, false);
......
......@@ -42,14 +42,14 @@ namespace Svg
[SvgAttribute("method")]
public virtual SvgTextPathMethod Method
{
get { return (this.Attributes["method"] == null ? SvgTextPathMethod.align : (SvgTextPathMethod)this.Attributes["method"]); }
get { return (this.Attributes["method"] == null ? SvgTextPathMethod.Align : (SvgTextPathMethod)this.Attributes["method"]); }
set { this.Attributes["method"] = value; }
}
[SvgAttribute("spacing")]
public virtual SvgTextPathSpacing Spacing
{
get { return (this.Attributes["spacing"] == null ? SvgTextPathSpacing.exact : (SvgTextPathSpacing)this.Attributes["spacing"]); }
get { return (this.Attributes["spacing"] == null ? SvgTextPathSpacing.Exact : (SvgTextPathSpacing)this.Attributes["spacing"]); }
set { this.Attributes["spacing"] = value; }
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment