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
document
SvgDocumentThe SvgDocument containing the SvgElements to manage.
Methods
Add(SvgElement)
Adds the specified SvgElement for ID management.
public virtual void Add(SvgElement element)
Parameters
element
SvgElementThe 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
element
SvgElementThe SvgElement to be managed.
sibling
SvgElementNot used.
autoForceUniqueID
boolPass true here, if you want the ID to be fixed
logElementOldIDNewID
Action<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
id
stringA string containing the ID to validate.
autoForceUniqueID
boolCreates 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
uri
Uri
Returns
OnAdded(SvgElement)
protected void OnAdded(SvgElement element)
Parameters
element
SvgElement
OnRemoved(SvgElement)
protected void OnRemoved(SvgElement element)
Parameters
element
SvgElement
Remove(SvgElement)
Removed the specified SvgElement from ID management.
public virtual void Remove(SvgElement element)
Parameters
element
SvgElementThe SvgElement to be removed from ID management.
Events
ElementAdded
public event EventHandler<SvgElementEventArgs> ElementAdded
Event Type
ElementRemoved
public event EventHandler<SvgElementEventArgs> ElementRemoved