ReaderSvgGetCustomProperties Method (Object) |
Namespace: Ab2d
public Dictionary<string, Object> GetCustomProperties( Object objectWithCustomProperties )
Every shape that is defined in Microsoft Visio can contain custom properties. When saving the drawing into svg, the custom properties are preserved and can be get with GetCustomProperties(String), GetCustomProperties(Object), GetObjectsWithCustomProperties or GetCustomPropertiesDataTable.
Every custom property has its associated object, key as string and a value. The value is not always of type string. The following types are supported: string, double, Boolean, DateTime, TimeSpan, decimal (for Currency).
GetCustomProperties method can be called with object or with string representing an object name. The method returns a Dictionary<string, object>.
Ab2d.ReaderSvg has some methods that are specialized to read additional data from svg files that were created with Microsoft Visio.
To get all objects that have custom properties defined use GetObjectsWithCustomProperties method.
To get all custom properties in a DataTable use GetCustomPropertiesDataTable method.
Ab2d.ReaderSvg also supports layers defined in Microsoft Visio. To get information about the layers use GetLayerNames or GetElementsForLayerName(String).
The following example shows how to display all the custom properties to the Output window.
Ab2d.ReaderSvg myReaderSvg; myReaderSvg = new Ab2d.ReaderSvg(); Viewbox myDiagram = myReaderSvg.Read(@"c:\myDiagram.svg"); // NOTE: // When SvgViewbox or SvgDrawing is used in XAML to read the svg file, // use its InnerReaderSvg property to get the ReaderSvg object. // To get all custom properties as a DataTable use GetCustomPropertiesDataTable method: // DataTable svgData = myReaderSvg.GetCustomPropertiesDataTable(); // Get all objects that have custom properties defined List<object> objectsList = myReaderSvg.GetObjectsWithCustomProperties(); foreach (object oneObject in objectsList) { string objectName; // First display the object name if (oneObject is FrameworkElement) objectName = ((FrameworkElement)oneObject).Name; else objectName = "Unknown"; System.Diagnostics.Debug.WriteLine("Object name: " + objectName); // Get custom properties dictionary for current object Dictionary<string, object> customProperties; customProperties = myReaderSvg.GetCustomProperties(oneObject); // Display its keys and values foreach (KeyValuePair<string,object> oneProperty in customProperties) System.Diagnostics.Debug.WriteLine(string.Format(" {0}: {1}", oneProperty.Key, oneProperty.Value)); System.Diagnostics.Debug.WriteLine(""); }