Class SvgElementIdManager
Provides methods to ensure element ID's are valid and unique.
Inherited Members
Namespace: Svg
Assembly: Svg.dll
Syntax
public class SvgElementIdManager
Constructors
| Improve this Doc View SourceSvgElementIdManager(SvgDocument)
Initialises a new instance of an SvgElementIdManager.
Declaration
public SvgElementIdManager(SvgDocument document)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgDocument | document | The SvgDocument containing the SvgElements to manage. |
Methods
| Improve this Doc View SourceAdd(SvgElement)
Adds the specified SvgElement for ID management.
Declaration
public virtual void Add(SvgElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgElement | element | The SvgElement to be managed. |
AddAndForceUniqueID(SvgElement, SvgElement, Boolean, 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.
Declaration
public virtual bool AddAndForceUniqueID(SvgElement element, SvgElement sibling, bool autoForceUniqueID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgElement | element | The SvgElement to be managed. |
| SvgElement | sibling | Not used. |
| Boolean | autoForceUniqueID | Pass true here, if you want the ID to be fixed |
| System.Action<SvgElement, System.String, System.String> | logElementOldIDNewID | If not null, the action is called before the id is fixed |
Returns
| Type | Description |
|---|---|
| Boolean | true, if ID was altered |
EnsureValidId(String, Boolean)
Ensures that the specified ID is unique within the containing SvgDocument.
Declaration
public string EnsureValidId(string id, bool autoForceUniqueID = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | A System.String containing the ID to validate. |
| Boolean | autoForceUniqueID | Creates a new unique id System.String. |
Returns
| Type | Description |
|---|---|
| System.String |
Exceptions
| Type | Condition |
|---|---|
| SvgException | An element with the same ID already exists within the containing SvgDocument. |
GetElementById(String)
Retrieves the SvgElement with the specified ID.
Declaration
public virtual SvgElement GetElementById(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | A System.String containing the ID of the element to find. |
Returns
| Type | Description |
|---|---|
| SvgElement | An SvgElement of one exists with the specified ID; otherwise false. |
GetElementById(Uri)
Declaration
public virtual SvgElement GetElementById(Uri uri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri |
Returns
| Type | Description |
|---|---|
| SvgElement |
OnAdded(SvgElement)
Declaration
protected void OnAdded(SvgElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgElement | element |
OnRemoved(SvgElement)
Declaration
protected void OnRemoved(SvgElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgElement | element |
Remove(SvgElement)
Removed the specified SvgElement from ID management.
Declaration
public virtual void Remove(SvgElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| SvgElement | element | The SvgElement to be removed from ID management. |
Events
| Improve this Doc View SourceElementAdded
Declaration
public event EventHandler<SvgElementEventArgs> ElementAdded
Event Type
| Type | Description |
|---|---|
| System.EventHandler<SvgElementEventArgs> |
ElementRemoved
Declaration
public event EventHandler<SvgElementEventArgs> ElementRemoved
Event Type
| Type | Description |
|---|---|
| System.EventHandler<SvgElementEventArgs> |