Class SvgElement
- Namespace
- Svg
- Assembly
- Svg.dll
The base class of which all SVG elements are derived from.
public abstract class SvgElement : ISvgTransformable, ICloneable, ISvgNode
- Inheritance
-
SvgElement
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
SvgElement()
Initializes a new instance of the SvgElement class.
public SvgElement()
Fields
AutoPublishEvents
public bool AutoPublishEvents
Field Value
Properties
Attributes
Gets a collection of element attributes.
protected virtual SvgAttributeCollection Attributes { get; }
Property Value
BaselineShift
Specifies dominant-baseline positioning of text.
public virtual string BaselineShift { get; set; }
Property Value
Children
Gets a collection of all child SvgElement objects.
public virtual SvgElementCollection Children { get; }
Property Value
Color
Gets or sets the color SvgPaintServer of this element which drives the currentColor property.
public virtual SvgPaintServer Color { get; set; }
Property Value
ColorInterpolation
Gets or sets the color space for gradient interpolations, color animations and alpha compositing.
public SvgColourInterpolation ColorInterpolation { get; set; }
Property Value
ColorInterpolationFilters
Gets or sets the color space for imaging operations performed via filter effects. NOT currently mapped through to bitmap
public SvgColourInterpolation ColorInterpolationFilters { get; set; }
Property Value
Content
public virtual string Content { get; set; }
Property Value
CustomAttributes
Gets a collection of custom attributes
public SvgCustomAttributeCollection CustomAttributes { get; }
Property Value
Display
Gets or sets a value to determine whether the element will be rendered. Needed to support SVG attribute display="none"
public virtual string Display { get; set; }
Property Value
ElementName
Gets the name of the element.
protected string ElementName { get; }
Property Value
ElementNamespace
Gets the elements namespace as a string.
protected string ElementNamespace { get; set; }
Property Value
Events
Gets an EventHandlerList of all events belonging to the element.
protected virtual EventHandlerList Events { get; }
Property Value
Fill
Gets or sets the fill SvgPaintServer of this element.
public virtual SvgPaintServer Fill { get; set; }
Property Value
FillOpacity
Gets or sets the opacity of this element's Fill.
public virtual float FillOpacity { get; set; }
Property Value
FillRule
public virtual SvgFillRule FillRule { get; set; }
Property Value
Font
Set all font information.
public virtual string Font { get; set; }
Property Value
FontFamily
Indicates which font family is to be used to render the text.
public virtual string FontFamily { get; set; }
Property Value
FontSize
Refers to the size of the font from baseline to baseline when multiple lines of text are set solid in a multiline layout environment.
public virtual SvgUnit FontSize { get; set; }
Property Value
FontStretch
Indicates the desired amount of condensing or expansion in the glyphs used to render the text.
public virtual SvgFontStretch FontStretch { get; set; }
Property Value
FontStyle
Refers to the style of the font.
public virtual SvgFontStyle FontStyle { get; set; }
Property Value
FontVariant
Refers to the varient of the font.
public virtual SvgFontVariant FontVariant { get; set; }
Property Value
FontWeight
Refers to the boldness of the font.
public virtual SvgFontWeight FontWeight { get; set; }
Property Value
HttpClient
protected static HttpClient HttpClient { get; }
Property Value
ID
Gets or sets the ID of the element.
public string ID { get; set; }
Property Value
Exceptions
- SvgException
The ID is already used within the SvgDocument.
IsPathDirty
Gets or sets a value indicating whether this element's 'Path' is dirty.
protected virtual bool IsPathDirty { get; set; }
Property Value
- bool
true
if the path is dirty; otherwise,false
.
Namespaces
Gets the namespaces that element has.
public Dictionary<string, string> Namespaces { get; }
Property Value
- Dictionary<string, string>
Key is prefix and value is namespace.
Nodes
public IList<ISvgNode> Nodes { get; }
Property Value
Opacity
Gets or sets the opacity of the element. 1.0 is fully opaque; 0.0 is transparent.
public virtual float Opacity { get; set; }
Property Value
OwnerDocument
Gets the owner SvgDocument.
public virtual SvgDocument OwnerDocument { get; }
Property Value
Parent
Gets the parent SvgElement.
public virtual SvgElement Parent { get; }
Property Value
- SvgElement
An SvgElement if one exists; otherwise null.
Parents
public IEnumerable<SvgElement> Parents { get; }
Property Value
ParentsAndSelf
public IEnumerable<SvgElement> ParentsAndSelf { get; }
Property Value
ShapeRendering
Refers to the AnitAlias rendering of shapes.
public virtual SvgShapeRendering ShapeRendering { get; set; }
Property Value
SpaceHandling
Gets or sets the space handling.
[SvgAttribute("space", "http://www.w3.org/XML/1998/namespace")]
public virtual XmlSpaceHandling SpaceHandling { get; set; }
Property Value
- XmlSpaceHandling
The space handling.
Stroke
Gets or sets the SvgPaintServer to be used when rendering a stroke around this element.
public virtual SvgPaintServer Stroke { get; set; }
Property Value
StrokeDashArray
[TypeConverter(typeof(SvgStrokeDashArrayConverter))]
public virtual SvgUnitCollection StrokeDashArray { get; set; }
Property Value
StrokeDashOffset
public virtual SvgUnit StrokeDashOffset { get; set; }
Property Value
StrokeLineCap
public virtual SvgStrokeLineCap StrokeLineCap { get; set; }
Property Value
StrokeLineJoin
public virtual SvgStrokeLineJoin StrokeLineJoin { get; set; }
Property Value
StrokeMiterLimit
public virtual float StrokeMiterLimit { get; set; }
Property Value
StrokeOpacity
Gets or sets the opacity of the stroke, if the Stroke property has been specified. 1.0 is fully opaque; 0.0 is transparent.
public virtual float StrokeOpacity { get; set; }
Property Value
StrokeWidth
Gets or sets the width of the stroke (if the Stroke property has a valid value specified.
public virtual SvgUnit StrokeWidth { get; set; }
Property Value
TextAnchor
Gets or sets the text anchor.
public virtual SvgTextAnchor TextAnchor { get; set; }
Property Value
TextDecoration
Refers to the boldness of the font.
public virtual SvgTextDecoration TextDecoration { get; set; }
Property Value
TextTransformation
Refers to the text transformation.
public virtual SvgTextTransformation TextTransformation { get; set; }
Property Value
Transforms
Gets or sets the element transforms.
public SvgTransformCollection Transforms { get; set; }
Property Value
- SvgTransformCollection
The transforms.
Visibility
Gets or sets a value to determine whether the element will be rendered.
public virtual string Visibility { get; set; }
Property Value
Writing
protected bool Writing { get; set; }
Property Value
Methods
AddElement(SvgElement, int)
Called by the underlying SvgElement when an element has been added to the Children collection.
protected virtual void AddElement(SvgElement child, int index)
Parameters
child
SvgElementThe SvgElement that has been added.
index
intAn int representing the index where the element was added to the collection.
AddPaths(SvgElement, GraphicsPath)
Recursive method to add up the paths of all children
protected void AddPaths(SvgElement elem, GraphicsPath path)
Parameters
elem
SvgElementpath
GraphicsPath
AddStyle(string, string, int)
Add style.
public void AddStyle(string name, string value, int specificity)
Parameters
Clone()
Creates a new object that is a copy of the current instance.
public virtual object Clone()
Returns
- object
A new object that is a copy of this instance.
ContainsAttribute(string)
public bool ContainsAttribute(string name)
Parameters
name
string
Returns
CreateMouseEventAction(Action<object, MouseArg>)
protected Action<float, float, int, int, bool, bool, bool, string> CreateMouseEventAction(Action<object, MouseArg> eventRaiser)
Parameters
Returns
DeepCopy()
public abstract SvgElement DeepCopy()
Returns
DeepCopy<T>()
public virtual SvgElement DeepCopy<T>() where T : SvgElement, new()
Returns
Type Parameters
T
Descendants()
public IEnumerable<SvgElement> Descendants()
Returns
FixOpacityValue(float)
protected static float FixOpacityValue(float value)
Parameters
value
float
Returns
FlushStyles(bool)
Flush styles.
public void FlushStyles(bool children = false)
Parameters
children
boolIf true, flush styles to the children.
GetAttribute<TAttributeType>(string, bool, TAttributeType)
protected TAttributeType GetAttribute<TAttributeType>(string attributeName, bool inherited, TAttributeType defaultValue = default)
Parameters
Returns
- TAttributeType
Type Parameters
TAttributeType
GetPaths(SvgElement, ISvgRenderer)
Recursive method to add up the paths of all children
protected GraphicsPath GetPaths(SvgElement elem, ISvgRenderer renderer)
Parameters
elem
SvgElementrenderer
ISvgRenderer
Returns
HasChildren()
Gets a value to determine whether the element has children.
public virtual bool HasChildren()
Returns
InitialiseFromXML(XmlReader, SvgDocument)
public virtual void InitialiseFromXML(XmlReader reader, SvgDocument document)
Parameters
reader
XmlReaderdocument
SvgDocument
InvalidateChildPaths()
Force recreation of the paths for the element and it's children.
public void InvalidateChildPaths()
OnAttributeChanged(AttributeEventArgs)
protected void OnAttributeChanged(AttributeEventArgs args)
Parameters
args
AttributeEventArgs
OnContentChanged(ContentEventArgs)
protected void OnContentChanged(ContentEventArgs args)
Parameters
args
ContentEventArgs
OnMouseScroll(int, bool, bool, bool, string)
protected void OnMouseScroll(int scroll, bool ctrlKey, bool shiftKey, bool altKey, string sessionID)
Parameters
PopTransforms(ISvgRenderer)
Removes any previously applied transforms from the specified ISvgRenderer.
protected virtual void PopTransforms(ISvgRenderer renderer)
Parameters
renderer
ISvgRendererThe ISvgRenderer that should have transforms removed.
PushTransforms(ISvgRenderer)
Applies the required transforms to ISvgRenderer.
protected virtual bool PushTransforms(ISvgRenderer renderer)
Parameters
renderer
ISvgRendererThe ISvgRenderer to be transformed.
Returns
RaiseMouseClick(object, MouseArg)
protected void RaiseMouseClick(object sender, MouseArg e)
Parameters
RaiseMouseDown(object, MouseArg)
protected void RaiseMouseDown(object sender, MouseArg e)
Parameters
RaiseMouseMove(object, MouseArg)
protected void RaiseMouseMove(object sender, MouseArg e)
Parameters
RaiseMouseOut(object, MouseArg)
protected void RaiseMouseOut(object sender, MouseArg args)
Parameters
RaiseMouseOver(object, MouseArg)
protected void RaiseMouseOver(object sender, MouseArg args)
Parameters
RaiseMouseScroll(object, MouseScrollArg)
protected void RaiseMouseScroll(object sender, MouseScrollArg e)
Parameters
sender
objecte
MouseScrollArg
RaiseMouseUp(object, MouseArg)
protected void RaiseMouseUp(object sender, MouseArg e)
Parameters
RegisterEvents(ISvgEventCaller)
Use this method to provide your implementation ISvgEventCaller which can register Actions and call them if one of the events occurs. Make sure, that your SvgElement has a unique ID. The SvgTextElement overwrites this and registers the Change event tor its text content.
public virtual void RegisterEvents(ISvgEventCaller caller)
Parameters
caller
ISvgEventCaller
RemoveElement(SvgElement)
Called by the underlying SvgElement when an element has been removed from the Children collection.
protected virtual void RemoveElement(SvgElement child)
Parameters
child
SvgElementThe SvgElement that has been removed.
Render(ISvgRenderer)
Renders the SvgElement and contents to the specified ISvgRenderer object.
protected virtual void Render(ISvgRenderer renderer)
Parameters
renderer
ISvgRendererThe ISvgRenderer object to render to.
RenderChildren(ISvgRenderer)
Renders the children of this SvgElement.
protected virtual void RenderChildren(ISvgRenderer renderer)
Parameters
renderer
ISvgRendererThe ISvgRenderer to render the child SvgElements to.
RenderElement(ISvgRenderer)
Renders this element to the ISvgRenderer.
public void RenderElement(ISvgRenderer renderer)
Parameters
renderer
ISvgRendererThe ISvgRenderer that the element should use to render itself.
SetAndForceUniqueID(string, bool, Action<SvgElement, string, string>)
public void SetAndForceUniqueID(string value, bool autoForceUniqueID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
Parameters
ShouldWriteElement()
Derived classes may decide that the element should not be written. For example, the text element shouldn't be written if it's empty.
public virtual bool ShouldWriteElement()
Returns
TransformedBounds(RectangleF)
Transforms the given rectangle with the set transformation, if any. Can be applied to bounds calculated without considering the element transformation.
protected RectangleF TransformedBounds(RectangleF bounds)
Parameters
bounds
RectangleFThe rectangle to be transformed.
Returns
- RectangleF
The transformed rectangle, or the original rectangle if no transformation exists.
TryGetAttribute(string, out string)
public bool TryGetAttribute(string name, out string value)
Parameters
Returns
UnregisterEvents(ISvgEventCaller)
Use this method to provide your implementation ISvgEventCaller to unregister Actions
public virtual void UnregisterEvents(ISvgEventCaller caller)
Parameters
caller
ISvgEventCaller
ValidateFontFamily(string, SvgDocument, SvgFontManager)
public static object ValidateFontFamily(string fontFamilyList, SvgDocument doc, SvgFontManager fontManager)
Parameters
fontFamilyList
stringdoc
SvgDocumentfontManager
SvgFontManager
Returns
Write(XmlWriter)
Write this SvgElement out using a given XmlWriter.
public virtual void Write(XmlWriter writer)
Parameters
writer
XmlWriterThe XmlWriter to use.
Remarks
Recommendation is to create an XmlWriter by calling a factory method,
e.g. Create(Stream),
as per Microsoft documentation.
However, unlike an XmlTextWriter created via 'new XmlTextWriter()',
a factory-constructed XmlWriter will not flush output until it is closed
(normally via a using statement), or unless the client explicitly calls Flush().
WriteAttributes(XmlWriter)
protected virtual void WriteAttributes(XmlWriter writer)
Parameters
writer
XmlWriter
WriteChildren(XmlWriter)
protected virtual void WriteChildren(XmlWriter writer)
Parameters
writer
XmlWriter
WriteEndElement(XmlWriter)
protected virtual void WriteEndElement(XmlWriter writer)
Parameters
writer
XmlWriter
WriteStartElement(XmlWriter)
protected virtual void WriteStartElement(XmlWriter writer)
Parameters
writer
XmlWriter
Events
AttributeChanged
Fired when an Attribute of this Element has changed
public event EventHandler<AttributeEventArgs> AttributeChanged
Event Type
ChildAdded
Fired when an Element was added to the children of this Element
public event EventHandler<ChildAddedEventArgs> ChildAdded
Event Type
Click
public event EventHandler<MouseArg> Click
Event Type
ContentChanged
Fired when an Attribute of this Element has changed
public event EventHandler<ContentEventArgs> ContentChanged
Event Type
Load
Occurs when the element is loaded.
public event EventHandler Load
Event Type
MouseDown
public event EventHandler<MouseArg> MouseDown
Event Type
MouseMove
public event EventHandler<MouseArg> MouseMove
Event Type
MouseOut
public event EventHandler<MouseArg> MouseOut
Event Type
MouseOver
public event EventHandler<MouseArg> MouseOver
Event Type
MouseScroll
public event EventHandler<MouseScrollArg> MouseScroll
Event Type
MouseUp
public event EventHandler<MouseArg> MouseUp