Commit c912ea85 authored by davescriven's avatar davescriven
Browse files

- Renamed SvgGraphicsElement to SvgVisualElement to better describe what the base class represents.

parent b6c5fa36
...@@ -12,7 +12,7 @@ namespace Svg ...@@ -12,7 +12,7 @@ namespace Svg
/// <summary> /// <summary>
/// An SVG element to render circles to the document. /// An SVG element to render circles to the document.
/// </summary> /// </summary>
public class SvgCircle : SvgGraphicsElement public class SvgCircle : SvgVisualElement
{ {
private GraphicsPath _path; private GraphicsPath _path;
......
...@@ -11,7 +11,7 @@ namespace Svg ...@@ -11,7 +11,7 @@ namespace Svg
/// <summary> /// <summary>
/// Represents and SVG ellipse element. /// Represents and SVG ellipse element.
/// </summary> /// </summary>
public class SvgEllipse : SvgGraphicsElement public class SvgEllipse : SvgVisualElement
{ {
private SvgUnit _radiusX; private SvgUnit _radiusX;
private SvgUnit _radiusY; private SvgUnit _radiusY;
......
...@@ -10,7 +10,7 @@ namespace Svg ...@@ -10,7 +10,7 @@ namespace Svg
/// <summary> /// <summary>
/// Represents and SVG line element. /// Represents and SVG line element.
/// </summary> /// </summary>
public class SvgLine : SvgGraphicsElement public class SvgLine : SvgVisualElement
{ {
private SvgUnit _startX; private SvgUnit _startX;
private SvgUnit _startY; private SvgUnit _startY;
......
...@@ -11,7 +11,7 @@ namespace Svg ...@@ -11,7 +11,7 @@ namespace Svg
/// <summary> /// <summary>
/// SvgPolygon defines a closed shape consisting of a set of connected straight line segments. /// SvgPolygon defines a closed shape consisting of a set of connected straight line segments.
/// </summary> /// </summary>
public class SvgPolygon : SvgGraphicsElement public class SvgPolygon : SvgVisualElement
{ {
protected GraphicsPath _path; protected GraphicsPath _path;
protected SvgUnitCollection _points; protected SvgUnitCollection _points;
......
...@@ -8,7 +8,7 @@ using System.Diagnostics; ...@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace Svg namespace Svg
{ {
/// <summary> /// <summary>
/// SvgPolyline defines a set of connected straight line segments. Typically, SvgPolyline defines open shapes. /// SvgPolyline defines a set of connected straight line segments. Typically, <see cref="SvgPolyline"/> defines open shapes.
/// </summary> /// </summary>
public class SvgPolyline : SvgPolygon public class SvgPolyline : SvgPolygon
{ {
......
...@@ -7,7 +7,7 @@ namespace Svg ...@@ -7,7 +7,7 @@ namespace Svg
/// <summary> /// <summary>
/// Represents and SVG rectangle that could also have reounded edges. /// Represents and SVG rectangle that could also have reounded edges.
/// </summary> /// </summary>
public class SvgRectangle : SvgGraphicsElement public class SvgRectangle : SvgVisualElement
{ {
private SvgUnit _cornerRadiusX; private SvgUnit _cornerRadiusX;
private SvgUnit _cornerRadiusY; private SvgUnit _cornerRadiusY;
......
...@@ -13,7 +13,7 @@ namespace Svg ...@@ -13,7 +13,7 @@ namespace Svg
/// <summary> /// <summary>
/// The class that all SVG elements should derive from when they are to be rendered. /// The class that all SVG elements should derive from when they are to be rendered.
/// </summary> /// </summary>
public abstract partial class SvgGraphicsElement : SvgElement, ISvgStylable, ISvgClipable public abstract partial class SvgVisualElement : SvgElement, ISvgStylable, ISvgClipable
{ {
private bool _dirty; private bool _dirty;
private bool _requiresSmoothRendering; private bool _requiresSmoothRendering;
...@@ -62,7 +62,7 @@ namespace Svg ...@@ -62,7 +62,7 @@ namespace Svg
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SvgGraphicsElement"/> class. /// Initializes a new instance of the <see cref="SvgGraphicsElement"/> class.
/// </summary> /// </summary>
public SvgGraphicsElement() public SvgVisualElement()
{ {
this._dirty = true; this._dirty = true;
this._requiresSmoothRendering = false; this._requiresSmoothRendering = false;
...@@ -130,6 +130,10 @@ namespace Svg ...@@ -130,6 +130,10 @@ namespace Svg
} }
} }
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
protected internal virtual void SetClip(SvgRenderer renderer) protected internal virtual void SetClip(SvgRenderer renderer)
{ {
if (this.ClipPath != null) if (this.ClipPath != null)
...@@ -144,6 +148,10 @@ namespace Svg ...@@ -144,6 +148,10 @@ namespace Svg
} }
} }
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
protected internal virtual void ResetClip(SvgRenderer renderer) protected internal virtual void ResetClip(SvgRenderer renderer)
{ {
if (this.ClipPath != null) if (this.ClipPath != null)
...@@ -153,11 +161,19 @@ namespace Svg ...@@ -153,11 +161,19 @@ namespace Svg
} }
} }
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
void ISvgClipable.SetClip(SvgRenderer renderer) void ISvgClipable.SetClip(SvgRenderer renderer)
{ {
this.SetClip(renderer); this.SetClip(renderer);
} }
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
void ISvgClipable.ResetClip(SvgRenderer renderer) void ISvgClipable.ResetClip(SvgRenderer renderer)
{ {
this.ResetClip(renderer); this.ResetClip(renderer);
......
...@@ -4,7 +4,7 @@ using System.Text; ...@@ -4,7 +4,7 @@ using System.Text;
namespace Svg namespace Svg
{ {
public abstract partial class SvgGraphicsElement public abstract partial class SvgVisualElement
{ {
private static readonly object _mouseOverKey = new object(); private static readonly object _mouseOverKey = new object();
private static readonly object _mouseOutKey = new object(); private static readonly object _mouseOutKey = new object();
......
...@@ -6,7 +6,7 @@ using System.ComponentModel; ...@@ -6,7 +6,7 @@ using System.ComponentModel;
namespace Svg namespace Svg
{ {
public abstract partial class SvgGraphicsElement public abstract partial class SvgVisualElement
{ {
private static float FixOpacityValue(float value) private static float FixOpacityValue(float value)
{ {
......
...@@ -6,13 +6,24 @@ using System.Drawing.Drawing2D; ...@@ -6,13 +6,24 @@ using System.Drawing.Drawing2D;
namespace Svg namespace Svg
{ {
/// <summary>
/// Defines the methods and properties that an <see cref="SvgElement"/> must implement to support clipping.
/// </summary>
public interface ISvgClipable public interface ISvgClipable
{ {
/// <summary> /// <summary>
/// Gets or sets the ID of the associated <see cref="SvgClipPath"/> if one has been specified. /// Gets or sets the ID of the associated <see cref="SvgClipPath"/> if one has been specified.
/// </summary> /// </summary>
Uri ClipPath { get; set; } Uri ClipPath { get; set; }
/// <summary>
/// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
void SetClip(SvgRenderer renderer); void SetClip(SvgRenderer renderer);
/// <summary>
/// Resets the clipping region of the specified <see cref="SvgRenderer"/> back to where it was before the <see cref="SetClip"/> method was called.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region reset.</param>
void ResetClip(SvgRenderer renderer); void ResetClip(SvgRenderer renderer);
} }
} }
\ No newline at end of file
...@@ -61,7 +61,7 @@ namespace Svg ...@@ -61,7 +61,7 @@ namespace Svg
/// <param name="element"></param> /// <param name="element"></param>
private void ComplementRegion(Region region, SvgElement element) private void ComplementRegion(Region region, SvgElement element)
{ {
SvgGraphicsElement graphicsElement = element as SvgGraphicsElement; SvgVisualElement graphicsElement = element as SvgVisualElement;
if (graphicsElement != null && graphicsElement.Path != null) if (graphicsElement != null && graphicsElement.Path != null)
{ {
......
...@@ -41,7 +41,9 @@ namespace Svg ...@@ -41,7 +41,9 @@ namespace Svg
get get
{ {
if (_idManager == null) if (_idManager == null)
{
_idManager = new SvgElementIdManager(this); _idManager = new SvgElementIdManager(this);
}
return _idManager; return _idManager;
} }
...@@ -122,6 +124,11 @@ namespace Svg ...@@ -122,6 +124,11 @@ namespace Svg
/// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns> /// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
public static SvgDocument Open(string path, Dictionary<string, string> entities) public static SvgDocument Open(string path, Dictionary<string, string> entities)
{ {
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException("path");
}
if (!File.Exists(path)) if (!File.Exists(path))
{ {
throw new FileNotFoundException("The specified document cannot be found.", path); throw new FileNotFoundException("The specified document cannot be found.", path);
...@@ -146,6 +153,11 @@ namespace Svg ...@@ -146,6 +153,11 @@ namespace Svg
/// <param name="entities">Custom entity definitions.</param> /// <param name="entities">Custom entity definitions.</param>
public static SvgDocument Open(Stream stream, Dictionary<string, string> entities) public static SvgDocument Open(Stream stream, Dictionary<string, string> entities)
{ {
if (stream == null)
{
throw new ArgumentNullException("stream");
}
Trace.TraceInformation("Begin Read"); Trace.TraceInformation("Begin Read");
using (var reader = new SvgTextReader(stream, entities)) using (var reader = new SvgTextReader(stream, entities))
......
...@@ -9,7 +9,7 @@ namespace Svg ...@@ -9,7 +9,7 @@ namespace Svg
/// <summary> /// <summary>
/// An element used to group SVG shapes. /// An element used to group SVG shapes.
/// </summary> /// </summary>
public class SvgGroup : SvgGraphicsElement public class SvgGroup : SvgVisualElement
{ {
public SvgGroup() public SvgGroup()
{ {
......
...@@ -8,7 +8,7 @@ using System.Drawing.Drawing2D; ...@@ -8,7 +8,7 @@ using System.Drawing.Drawing2D;
namespace Svg namespace Svg
{ {
public class SvgUse : SvgGraphicsElement public class SvgUse : SvgVisualElement
{ {
private Uri _referencedElement; private Uri _referencedElement;
...@@ -48,7 +48,7 @@ namespace Svg ...@@ -48,7 +48,7 @@ namespace Svg
{ {
get get
{ {
SvgGraphicsElement element = (SvgGraphicsElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement); SvgVisualElement element = (SvgVisualElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
return (element != null) ? element.Path : null; return (element != null) ? element.Path : null;
} }
} }
...@@ -73,7 +73,7 @@ namespace Svg ...@@ -73,7 +73,7 @@ namespace Svg
{ {
this.PushTransforms(renderer); this.PushTransforms(renderer);
SvgGraphicsElement element = (SvgGraphicsElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement); SvgVisualElement element = (SvgVisualElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
// For the time of rendering we want the referenced element to inherit // For the time of rendering we want the referenced element to inherit
// this elements transforms // this elements transforms
SvgElement parent = element._parent; SvgElement parent = element._parent;
......
...@@ -24,7 +24,7 @@ namespace Svg ...@@ -24,7 +24,7 @@ namespace Svg
set { this._colour = value; } set { this._colour = value; }
} }
public override Brush GetBrush(SvgGraphicsElement styleOwner, float opacity) public override Brush GetBrush(SvgVisualElement styleOwner, float opacity)
{ {
int alpha = (int)((opacity * (this.Colour.A/255) ) * 255); int alpha = (int)((opacity * (this.Colour.A/255) ) * 255);
Color colour = Color.FromArgb(alpha, this.Colour); Color colour = Color.FromArgb(alpha, this.Colour);
......
...@@ -7,6 +7,9 @@ using System.Drawing.Drawing2D; ...@@ -7,6 +7,9 @@ using System.Drawing.Drawing2D;
namespace Svg namespace Svg
{ {
/// <summary>
/// Provides the base class for all paint servers that wish to render a gradient.
/// </summary>
public abstract class SvgGradientServer : SvgPaintServer public abstract class SvgGradientServer : SvgPaintServer
{ {
private SvgCoordinateUnits _gradientUnits; private SvgCoordinateUnits _gradientUnits;
...@@ -14,6 +17,9 @@ namespace Svg ...@@ -14,6 +17,9 @@ namespace Svg
private SvgGradientServer _inheritGradient; private SvgGradientServer _inheritGradient;
private List<SvgGradientStop> _stops; private List<SvgGradientStop> _stops;
/// <summary>
/// Initializes a new instance of the <see cref="SvgGradientServer"/> class.
/// </summary>
internal SvgGradientServer() internal SvgGradientServer()
{ {
this.GradientUnits = SvgCoordinateUnits.ObjectBoundingBox; this.GradientUnits = SvgCoordinateUnits.ObjectBoundingBox;
...@@ -23,7 +29,10 @@ namespace Svg ...@@ -23,7 +29,10 @@ namespace Svg
protected override void AddElement(SvgElement child, int index) protected override void AddElement(SvgElement child, int index)
{ {
if (child is SvgGradientStop) if (child is SvgGradientStop)
{
this.Stops.Add((SvgGradientStop)child); this.Stops.Add((SvgGradientStop)child);
}
base.AddElement(child, index); base.AddElement(child, index);
} }
...@@ -59,7 +68,7 @@ namespace Svg ...@@ -59,7 +68,7 @@ namespace Svg
set { this._inheritGradient = value; } set { this._inheritGradient = value; }
} }
protected ColorBlend GetColourBlend(SvgGraphicsElement owner, float opacity) protected ColorBlend GetColourBlend(SvgVisualElement owner, float opacity)
{ {
ColorBlend blend = new ColorBlend(); ColorBlend blend = new ColorBlend();
int colourBlends = this.Stops.Count; int colourBlends = this.Stops.Count;
......
...@@ -72,7 +72,7 @@ namespace Svg ...@@ -72,7 +72,7 @@ namespace Svg
get { return new SvgPoint(this.X2, this.Y2); } get { return new SvgPoint(this.X2, this.Y2); }
} }
public override Brush GetBrush(SvgGraphicsElement owner, float opacity) public override Brush GetBrush(SvgVisualElement owner, float opacity)
{ {
// Need at least 2 colours to do the gradient fill // Need at least 2 colours to do the gradient fill
if (this.Stops.Count < 2) if (this.Stops.Count < 2)
......
...@@ -22,7 +22,7 @@ namespace Svg ...@@ -22,7 +22,7 @@ namespace Svg
// Never render paint servers or their children // Never render paint servers or their children
} }
public abstract Brush GetBrush(SvgGraphicsElement styleOwner, float opacity); public abstract Brush GetBrush(SvgVisualElement styleOwner, float opacity);
public override string ToString() public override string ToString()
{ {
......
...@@ -60,7 +60,7 @@ namespace Svg ...@@ -60,7 +60,7 @@ namespace Svg
this._height = new SvgUnit(0.0f); this._height = new SvgUnit(0.0f);
} }
public override Brush GetBrush(SvgGraphicsElement renderingElement, float opacity) public override Brush GetBrush(SvgVisualElement renderingElement, float opacity)
{ {
// If there aren't any children, return null // If there aren't any children, return null
if (this.Children.Count == 0) if (this.Children.Count == 0)
......
...@@ -50,7 +50,7 @@ namespace Svg ...@@ -50,7 +50,7 @@ namespace Svg
{ {
} }
public override Brush GetBrush(SvgGraphicsElement renderingElement, float opacity) public override Brush GetBrush(SvgVisualElement renderingElement, float opacity)
{ {
GraphicsPath path = new GraphicsPath(); GraphicsPath path = new GraphicsPath();
float left = this.CenterX.ToDeviceValue(renderingElement); float left = this.CenterX.ToDeviceValue(renderingElement);
......
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