Class SvgElementIdManager
- Namespace
- Svg
- Assembly
- Svg.dll
Provides methods to ensure element ID's are valid and unique.
public class SvgElementIdManager
- Inheritance
-
SvgElementIdManager
- Inherited Members
Constructors
SvgElementIdManager(SvgDocument)
Initialises a new instance of an SvgElementIdManager.
public SvgElementIdManager(SvgDocument document)
Parameters
documentSvgDocumentThe SvgDocument containing the SvgElements to manage.
Methods
Add(SvgElement)
Adds the specified SvgElement for ID management.
public virtual void Add(SvgElement element)
Parameters
elementSvgElementThe SvgElement to be managed.
AddAndForceUniqueID(SvgElement, SvgElement, bool, Action<SvgElement, string, string>)
Adds the specified SvgElement for ID management. And can auto fix the ID if it already exists or it starts with a number.
public virtual bool AddAndForceUniqueID(SvgElement element, SvgElement sibling, bool autoForceUniqueID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
Parameters
elementSvgElementThe SvgElement to be managed.
siblingSvgElementNot used.
autoForceUniqueIDboolPass true here, if you want the ID to be fixed
logElementOldIDNewIDAction<SvgElement, string, string>If not null, the action is called before the id is fixed
Returns
- bool
true, if ID was altered
EnsureValidId(string, bool)
Ensures that the specified ID is unique within the containing SvgDocument.
public string EnsureValidId(string id, bool autoForceUniqueID = false)
Parameters
idstringA string containing the ID to validate.
autoForceUniqueIDboolCreates a new unique id string.
Returns
Exceptions
- SvgException
An element with the same ID already exists within the containing SvgDocument.
GetElementById(string)
Retrieves the SvgElement with the specified ID.
public virtual SvgElement GetElementById(string id)
Parameters
Returns
- SvgElement
An SvgElement of one exists with the specified ID; otherwise false.
GetElementById(Uri)
public virtual SvgElement GetElementById(Uri uri)
Parameters
uriUri
Returns
OnAdded(SvgElement)
protected void OnAdded(SvgElement element)
Parameters
elementSvgElement
OnRemoved(SvgElement)
protected void OnRemoved(SvgElement element)
Parameters
elementSvgElement
Remove(SvgElement)
Removed the specified SvgElement from ID management.
public virtual void Remove(SvgElement element)
Parameters
elementSvgElementThe SvgElement to be removed from ID management.
Events
ElementAdded
public event EventHandler<SvgElementEventArgs> ElementAdded
Event Type
ElementRemoved
public event EventHandler<SvgElementEventArgs> ElementRemoved