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
/// <summary>
/// An SVG element to render circles to the document.
/// </summary>
public class SvgCircle : SvgGraphicsElement
public class SvgCircle : SvgVisualElement
{
private GraphicsPath _path;
......
......@@ -11,7 +11,7 @@ namespace Svg
/// <summary>
/// Represents and SVG ellipse element.
/// </summary>
public class SvgEllipse : SvgGraphicsElement
public class SvgEllipse : SvgVisualElement
{
private SvgUnit _radiusX;
private SvgUnit _radiusY;
......
......@@ -10,7 +10,7 @@ namespace Svg
/// <summary>
/// Represents and SVG line element.
/// </summary>
public class SvgLine : SvgGraphicsElement
public class SvgLine : SvgVisualElement
{
private SvgUnit _startX;
private SvgUnit _startY;
......
......@@ -11,7 +11,7 @@ namespace Svg
/// <summary>
/// SvgPolygon defines a closed shape consisting of a set of connected straight line segments.
/// </summary>
public class SvgPolygon : SvgGraphicsElement
public class SvgPolygon : SvgVisualElement
{
protected GraphicsPath _path;
protected SvgUnitCollection _points;
......
......@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace Svg
{
/// <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>
public class SvgPolyline : SvgPolygon
{
......
......@@ -7,7 +7,7 @@ namespace Svg
/// <summary>
/// Represents and SVG rectangle that could also have reounded edges.
/// </summary>
public class SvgRectangle : SvgGraphicsElement
public class SvgRectangle : SvgVisualElement
{
private SvgUnit _cornerRadiusX;
private SvgUnit _cornerRadiusY;
......
......@@ -13,7 +13,7 @@ namespace Svg
/// <summary>
/// The class that all SVG elements should derive from when they are to be rendered.
/// </summary>
public abstract partial class SvgGraphicsElement : SvgElement, ISvgStylable, ISvgClipable
public abstract partial class SvgVisualElement : SvgElement, ISvgStylable, ISvgClipable
{
private bool _dirty;
private bool _requiresSmoothRendering;
......@@ -62,7 +62,7 @@ namespace Svg
/// <summary>
/// Initializes a new instance of the <see cref="SvgGraphicsElement"/> class.
/// </summary>
public SvgGraphicsElement()
public SvgVisualElement()
{
this._dirty = true;
this._requiresSmoothRendering = false;
......@@ -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)
{
if (this.ClipPath != null)
......@@ -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)
{
if (this.ClipPath != null)
......@@ -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)
{
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)
{
this.ResetClip(renderer);
......
......@@ -4,7 +4,7 @@ using System.Text;
namespace Svg
{
public abstract partial class SvgGraphicsElement
public abstract partial class SvgVisualElement
{
private static readonly object _mouseOverKey = new object();
private static readonly object _mouseOutKey = new object();
......
......@@ -6,7 +6,7 @@ using System.ComponentModel;
namespace Svg
{
public abstract partial class SvgGraphicsElement
public abstract partial class SvgVisualElement
{
private static float FixOpacityValue(float value)
{
......
......@@ -6,13 +6,24 @@ using System.Drawing.Drawing2D;
namespace Svg
{
/// <summary>
/// Defines the methods and properties that an <see cref="SvgElement"/> must implement to support clipping.
/// </summary>
public interface ISvgClipable
{
/// <summary>
/// Gets or sets the ID of the associated <see cref="SvgClipPath"/> if one has been specified.
/// </summary>
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);
/// <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);
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ namespace Svg
/// <param name="element"></param>
private void ComplementRegion(Region region, SvgElement element)
{
SvgGraphicsElement graphicsElement = element as SvgGraphicsElement;
SvgVisualElement graphicsElement = element as SvgVisualElement;
if (graphicsElement != null && graphicsElement.Path != null)
{
......
......@@ -41,7 +41,9 @@ namespace Svg
get
{
if (_idManager == null)
{
_idManager = new SvgElementIdManager(this);
}
return _idManager;
}
......@@ -122,6 +124,11 @@ namespace Svg
/// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
public static SvgDocument Open(string path, Dictionary<string, string> entities)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException("path");
}
if (!File.Exists(path))
{
throw new FileNotFoundException("The specified document cannot be found.", path);
......@@ -146,6 +153,11 @@ namespace Svg
/// <param name="entities">Custom entity definitions.</param>
public static SvgDocument Open(Stream stream, Dictionary<string, string> entities)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
Trace.TraceInformation("Begin Read");
using (var reader = new SvgTextReader(stream, entities))
......
......@@ -9,7 +9,7 @@ namespace Svg
/// <summary>
/// An element used to group SVG shapes.
/// </summary>
public class SvgGroup : SvgGraphicsElement
public class SvgGroup : SvgVisualElement
{
public SvgGroup()
{
......
......@@ -8,7 +8,7 @@ using System.Drawing.Drawing2D;
namespace Svg
{
public class SvgUse : SvgGraphicsElement
public class SvgUse : SvgVisualElement
{
private Uri _referencedElement;
......@@ -48,7 +48,7 @@ namespace Svg
{
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;
}
}
......@@ -73,7 +73,7 @@ namespace Svg
{
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
// this elements transforms
SvgElement parent = element._parent;
......
......@@ -24,7 +24,7 @@ namespace Svg
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);
Color colour = Color.FromArgb(alpha, this.Colour);
......
......@@ -7,6 +7,9 @@ using System.Drawing.Drawing2D;
namespace Svg
{
/// <summary>
/// Provides the base class for all paint servers that wish to render a gradient.
/// </summary>
public abstract class SvgGradientServer : SvgPaintServer
{
private SvgCoordinateUnits _gradientUnits;
......@@ -14,6 +17,9 @@ namespace Svg
private SvgGradientServer _inheritGradient;
private List<SvgGradientStop> _stops;
/// <summary>
/// Initializes a new instance of the <see cref="SvgGradientServer"/> class.
/// </summary>
internal SvgGradientServer()
{
this.GradientUnits = SvgCoordinateUnits.ObjectBoundingBox;
......@@ -23,7 +29,10 @@ namespace Svg
protected override void AddElement(SvgElement child, int index)
{
if (child is SvgGradientStop)
{
this.Stops.Add((SvgGradientStop)child);
}
base.AddElement(child, index);
}
......@@ -59,7 +68,7 @@ namespace Svg
set { this._inheritGradient = value; }
}
protected ColorBlend GetColourBlend(SvgGraphicsElement owner, float opacity)
protected ColorBlend GetColourBlend(SvgVisualElement owner, float opacity)
{
ColorBlend blend = new ColorBlend();
int colourBlends = this.Stops.Count;
......
......@@ -72,7 +72,7 @@ namespace Svg
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
if (this.Stops.Count < 2)
......
......@@ -22,7 +22,7 @@ namespace Svg
// 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()
{
......
......@@ -60,7 +60,7 @@ namespace Svg
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 (this.Children.Count == 0)
......
......@@ -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();
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