Skip to content

Commit

Permalink
Minor refactoring (#447)
Browse files Browse the repository at this point in the history
- fixed UTF8 encoding in documentation
- use var
- some code simplification.
  • Loading branch information
H1Gdev authored and mrbean-bremen committed May 3, 2019
1 parent 404f1fa commit 97174bf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Source/Document Structure/SvgSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Svg
{
/// <summary>
/// The switch element evaluates the requiredFeatures’, ‘requiredExtensions and systemLanguage attributes on its direct child elements in order, and then processes and renders the first child for which these attributes evaluate to true
/// The 'switch' element evaluates the 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' attributes on its direct child elements in order, and then processes and renders the first child for which these attributes evaluate to true
/// </summary>
[SvgElement("switch")]
public class SvgSwitch : SvgVisualElement
Expand Down
2 changes: 1 addition & 1 deletion Source/Extensibility/SvgForeignObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Svg
{
/// <summary>
/// The foreignObject element allows for inclusion of a foreign namespace which has its graphical content drawn by a different user agent
/// The 'foreignObject' element allows for inclusion of a foreign namespace which has its graphical content drawn by a different user agent
/// </summary>
[SvgElement("foreignObject")]
public class SvgForeignObject : SvgVisualElement
Expand Down
8 changes: 4 additions & 4 deletions Source/Painting/SvgGradientStop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Svg
public class SvgGradientStop : SvgElement
{
private SvgUnit _offset;

/// <summary>
/// Gets or sets the offset, i.e. where the stop begins from the beginning, of the gradient stop.
/// </summary>
Expand Down Expand Up @@ -59,7 +59,7 @@ public SvgUnit Offset
[TypeConverter(typeof(SvgPaintServerFactory))]
public override SvgPaintServer StopColor
{
get
get
{
var direct = this.Attributes.GetAttribute<SvgPaintServer>("stop-color", SvgColourServer.NotSet);
if (direct == SvgColourServer.Inherit) return this.Attributes["stop-color"] as SvgPaintServer ?? SvgColourServer.NotSet;
Expand All @@ -74,7 +74,7 @@ public override SvgPaintServer StopColor
[SvgAttribute("stop-opacity")]
public override float Opacity
{
get { return (this.Attributes["stop-opacity"] == null) ? 1.0f : (float)this.Attributes["stop-opacity"]; }
get { return (this.Attributes["stop-opacity"] == null) ? 1.0f : (float)this.Attributes["stop-opacity"]; }
set { this.Attributes["stop-opacity"] = FixOpacityValue(value); }
}

Expand Down Expand Up @@ -115,4 +115,4 @@ public override SvgElement DeepCopy<T>()
return newObj;
}
}
}
}
15 changes: 6 additions & 9 deletions Source/Paths/SvgPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class SvgPath : SvgMarkerElement
[SvgAttribute("d", true)]
public SvgPathSegmentList PathData
{
get { return this.Attributes.GetAttribute<SvgPathSegmentList>("d"); }
get { return this.Attributes.GetAttribute<SvgPathSegmentList>("d"); }
set
{
this.Attributes["d"] = value;
value._owner = this;
this.Attributes["d"] = value;
value._owner = this;
this.IsPathDirty = true;
}
}
Expand All @@ -36,8 +36,6 @@ public float PathLength
set { this.Attributes["pathLength"] = value; }
}



/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
Expand All @@ -47,7 +45,7 @@ public override GraphicsPath Path(ISvgRenderer renderer)
{
this._path = new GraphicsPath();

foreach (SvgPathSegment segment in this.PathData)
foreach (var segment in this.PathData)
{
segment.AddToPath(_path);
}
Expand All @@ -74,7 +72,7 @@ public override GraphicsPath Path(ISvgRenderer renderer)
internal void OnPathUpdated()
{
this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "d", Value = this.Attributes.GetAttribute<SvgPathSegmentList>("d") });
OnAttributeChanged(new AttributeEventArgs { Attribute = "d", Value = this.Attributes.GetAttribute<SvgPathSegmentList>("d") });
}

/// <summary>
Expand Down Expand Up @@ -110,7 +108,6 @@ public override SvgElement DeepCopy<T>()
newObj.MarkerStart = this.MarkerStart;
newObj.MarkerEnd = this.MarkerEnd;
return newObj;

}
}
}
}
7 changes: 3 additions & 4 deletions Source/Rendering/SvgRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
Expand Down Expand Up @@ -129,9 +128,9 @@ Graphics IGraphicsProvider.GetGraphics()
private static Graphics CreateGraphics(Image image)
{
var g = Graphics.FromImage(image);
g.PixelOffsetMode = PixelOffsetMode.Half;
g.CompositingQuality = CompositingQuality.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.TextContrast = 1;
return g;
}
Expand Down

0 comments on commit 97174bf

Please sign in to comment.