Commit 6b08837f 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
...@@ -5,11 +5,20 @@ using System.ComponentModel; ...@@ -5,11 +5,20 @@ using System.ComponentModel;
namespace Svg namespace Svg
{ {
/// <summary>Specifies the shape to be used at the corners of paths or basic shapes when they are stroked.</summary>
[TypeConverter(typeof(SvgStrokeLineJoinConverter))] [TypeConverter(typeof(SvgStrokeLineJoinConverter))]
public enum SvgStrokeLineJoin public enum SvgStrokeLineJoin
{ {
/// <summary>The value is inherited from the parent element.</summary>
Inherit,
/// <summary>The corners of the paths are joined sharply.</summary>
Miter, Miter,
/// <summary>The corners of the paths are rounded off.</summary>
Round, Round,
/// <summary>The corners of the paths are "flattened".</summary>
Bevel Bevel
} }
} }
...@@ -85,13 +85,12 @@ namespace Svg ...@@ -85,13 +85,12 @@ namespace Svg
private bool IsInheritValue(object value) private bool IsInheritValue(object value)
{ {
return (value == null || return (value == null ||
(value is SvgFontStyle && (SvgFontStyle)value == SvgFontStyle.inherit) || (value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.Inherit) ||
(value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.inherit) || (value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.Inherit) ||
(value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.inherit) || (value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.Inherit) ||
(value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.inherit) || (value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.Inherit) ||
(value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.inherit) ||
(value is XmlSpaceHandling && (XmlSpaceHandling)value == XmlSpaceHandling.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 == SvgColourServer.Inherit) ||
(value is string && (string)value == "inherit") (value is string && (string)value == "inherit")
); );
......
...@@ -475,7 +475,7 @@ namespace Svg ...@@ -475,7 +475,7 @@ namespace Svg
renderer.ScaleTransform(bitmap.Width / size.Width, bitmap.Height / size.Height); 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. //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); this.Render(renderer);
} }
......
...@@ -572,9 +572,11 @@ namespace Svg ...@@ -572,9 +572,11 @@ namespace Svg
(!attr.Attribute.InAttributeDictionary || _attributes.ContainsKey(attr.Attribute.Name))) (!attr.Attribute.InAttributeDictionary || _attributes.ContainsKey(attr.Attribute.Name)))
{ {
object propertyValue = attr.Property.GetValue(this); object propertyValue = attr.Property.GetValue(this);
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
forceWrite = false; forceWrite = false;
writeStyle = (attr.Attribute.Name == "fill"); writeStyle = (attr.Attribute.Name == "fill");
if ((attr.Attribute.Name == "fill") && (Parent != null)) if ((attr.Attribute.Name == "fill") && (Parent != null))
{ {
if(propertyValue == SvgColourServer.NotSet) continue; if(propertyValue == SvgColourServer.NotSet) continue;
...@@ -593,9 +595,9 @@ namespace Svg ...@@ -593,9 +595,9 @@ namespace Svg
if (propertyValue != null) if (propertyValue != null)
{ {
var type = propertyValue.GetType(); var type = propertyValue.GetType();
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
//Only write the attribute's value if it is not the default value, not null/empty, or we're forcing the write.
if (!SvgDefaults.IsDefault(attr.Attribute.Name, value) || forceWrite) if ((!string.IsNullOrEmpty(value) && !SvgDefaults.IsDefault(attr.Attribute.Name, value)) || forceWrite)
{ {
if (writeStyle) if (writeStyle)
{ {
...@@ -609,7 +611,6 @@ namespace Svg ...@@ -609,7 +611,6 @@ namespace Svg
} }
else if(attr.Attribute.Name == "fill") //if fill equals null, write 'none' else if(attr.Attribute.Name == "fill") //if fill equals null, write 'none'
{ {
string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
if (writeStyle) if (writeStyle)
{ {
styles[attr.Attribute.Name] = value; styles[attr.Attribute.Name] = value;
......
...@@ -173,7 +173,7 @@ namespace Svg ...@@ -173,7 +173,7 @@ namespace Svg
[SvgAttribute("font-style", true)] [SvgAttribute("font-style", true)]
public virtual SvgFontStyle FontStyle 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; } set { this.Attributes["font-style"] = value; this.IsPathDirty = true; }
} }
...@@ -183,7 +183,7 @@ namespace Svg ...@@ -183,7 +183,7 @@ namespace Svg
[SvgAttribute("font-variant", true)] [SvgAttribute("font-variant", true)]
public virtual SvgFontVariant FontVariant 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; } set { this.Attributes["font-variant"] = value; this.IsPathDirty = true; }
} }
...@@ -193,7 +193,7 @@ namespace Svg ...@@ -193,7 +193,7 @@ namespace Svg
[SvgAttribute("text-decoration", true)] [SvgAttribute("text-decoration", true)]
public virtual SvgTextDecoration TextDecoration 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; } set { this.Attributes["text-decoration"] = value; this.IsPathDirty = true; }
} }
...@@ -203,7 +203,7 @@ namespace Svg ...@@ -203,7 +203,7 @@ namespace Svg
[SvgAttribute("font-weight", true)] [SvgAttribute("font-weight", true)]
public virtual SvgFontWeight FontWeight 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; } set { this.Attributes["font-weight"] = value; this.IsPathDirty = true; }
} }
...@@ -328,12 +328,12 @@ namespace Svg ...@@ -328,12 +328,12 @@ namespace Svg
// Get the font-weight // Get the font-weight
switch (this.FontWeight) switch (this.FontWeight)
{ {
case SvgFontWeight.bold: //Note: Bold is not listed because it is = W700.
case SvgFontWeight.bolder: case SvgFontWeight.Bolder:
case SvgFontWeight.w600: case SvgFontWeight.W600:
case SvgFontWeight.w700: case SvgFontWeight.W700:
case SvgFontWeight.w800: case SvgFontWeight.W800:
case SvgFontWeight.w900: case SvgFontWeight.W900:
fontStyle |= System.Drawing.FontStyle.Bold; fontStyle |= System.Drawing.FontStyle.Bold;
break; break;
} }
...@@ -341,8 +341,8 @@ namespace Svg ...@@ -341,8 +341,8 @@ namespace Svg
// Get the font-style // Get the font-style
switch (this.FontStyle) switch (this.FontStyle)
{ {
case SvgFontStyle.italic: case SvgFontStyle.Italic:
case SvgFontStyle.oblique: case SvgFontStyle.Oblique:
fontStyle |= System.Drawing.FontStyle.Italic; fontStyle |= System.Drawing.FontStyle.Italic;
break; break;
} }
...@@ -350,10 +350,10 @@ namespace Svg ...@@ -350,10 +350,10 @@ namespace Svg
// Get the text-decoration // Get the text-decoration
switch (this.TextDecoration) switch (this.TextDecoration)
{ {
case SvgTextDecoration.lineThrough: case SvgTextDecoration.LineThrough:
fontStyle |= System.Drawing.FontStyle.Strikeout; fontStyle |= System.Drawing.FontStyle.Strikeout;
break; break;
case SvgTextDecoration.underline: case SvgTextDecoration.Underline:
fontStyle |= System.Drawing.FontStyle.Underline; fontStyle |= System.Drawing.FontStyle.Underline;
break; break;
} }
......
...@@ -84,7 +84,7 @@ namespace Svg ...@@ -84,7 +84,7 @@ namespace Svg
[SvgAttribute("font-style")] [SvgAttribute("font-style")]
public virtual SvgFontStyle FontStyle 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; } set { this.Attributes["font-style"] = value; }
} }
...@@ -94,7 +94,7 @@ namespace Svg ...@@ -94,7 +94,7 @@ namespace Svg
[SvgAttribute("font-variant")] [SvgAttribute("font-variant")]
public virtual SvgFontVariant FontVariant 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; } set { this.Attributes["font-variant"] = value; }
} }
...@@ -104,7 +104,7 @@ namespace Svg ...@@ -104,7 +104,7 @@ namespace Svg
[SvgAttribute("font-weight")] [SvgAttribute("font-weight")]
public virtual SvgFontWeight FontWeight 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; } set { this.Attributes["font-weight"] = value; }
} }
......
...@@ -12,7 +12,8 @@ namespace Svg ...@@ -12,7 +12,8 @@ namespace Svg
[TypeConverter(typeof(SvgTextAnchorConverter))] [TypeConverter(typeof(SvgTextAnchorConverter))]
public enum SvgTextAnchor public enum SvgTextAnchor
{ {
inherit, /// <summary>The value is inherited from the parent element.</summary>
Inherit,
/// <summary> /// <summary>
/// The rendered characters are aligned such that the start of the text string is at the initial current text position. /// The rendered characters are aligned such that the start of the text string is at the initial current text position.
/// </summary> /// </summary>
......
...@@ -36,7 +36,7 @@ namespace Svg ...@@ -36,7 +36,7 @@ namespace Svg
[SvgAttribute("text-anchor", true)] [SvgAttribute("text-anchor", true)]
public virtual SvgTextAnchor TextAnchor 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; } set { this.Attributes["text-anchor"] = value; this.IsPathDirty = true; }
} }
...@@ -167,7 +167,7 @@ namespace Svg ...@@ -167,7 +167,7 @@ namespace Svg
[SvgAttribute("lengthAdjust", true)] [SvgAttribute("lengthAdjust", true)]
public virtual SvgTextLengthAdjust LengthAdjust 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; } set { this.Attributes["lengthAdjust"] = value; this.IsPathDirty = true; }
} }
...@@ -365,7 +365,7 @@ namespace Svg ...@@ -365,7 +365,7 @@ namespace Svg
var diff = (actLength - specLength); var diff = (actLength - specLength);
if (Math.Abs(diff) > 1.5) 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); origState.LetterSpacingAdjust = -1 * diff / (state.NumChars - origState.NumChars - 1);
SetPath(origState, false); SetPath(origState, false);
......
...@@ -42,14 +42,14 @@ namespace Svg ...@@ -42,14 +42,14 @@ namespace Svg
[SvgAttribute("method")] [SvgAttribute("method")]
public virtual SvgTextPathMethod 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; } set { this.Attributes["method"] = value; }
} }
[SvgAttribute("spacing")] [SvgAttribute("spacing")]
public virtual SvgTextPathSpacing 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; } 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