Click or drag to resize
AB4D logo

ResourceDictionaryWriter Class

ResourceDictionaryWriter class is a helper class that can be used to build ResourceDictionaries from multiple input files.
Inheritance Hierarchy
SystemObject
  Ab2d.Utility.ReaderSvgResourceDictionaryWriter

Namespace:  Ab2d.Utility.ReaderSvg
Assembly:  Ab2d.ReaderSvg (in Ab2d.ReaderSvg.dll) Version: 7.1.7295.1040
Syntax
C#
public class ResourceDictionaryWriter

The ResourceDictionaryWriter type exposes the following members.

Constructors
  NameDescription
Public methodResourceDictionaryWriter
Constructor.
Top
Properties
  NameDescription
Public propertyGeometrySettings
GeometrySettings that are used to read svg file as geometries.
Public propertyUsedSvgReader
Ab2d.ReaderSvg instance that is used to read svg files.
Public propertyXamlWriterSettings
BaseXamlWriterSettings that is used for GetXaml method.
Top
Methods
  NameDescription
Public methodAddFile
Adds a svg or svgz file to the ResourceDictionary as WPF Shapes.
Public methodAddGeometryFile
Adds a svg or svgz file to the ResourceDictionary as Geometry.
Public methodAddGeometryStream
Adds a svg or svgz from stream to the ResourceDictionary as Geometry.
Public methodAddStream
Adds a svg or svgz from stream to the ResourceDictionary as WPF Shapes.
Protected methodCreateReaderSvg
Creates a new instance of Ab2d.ReaderSvg class. Can be overridden to specify some special properties to created ReaderSvg.
Protected methodCode exampleCreateXamlWriterSettings
Creates a BaseXamlWriterSettings. It can be overriden to provide different Xaml settings or use SilverlightXamlWriterSettings.
Protected methodGetRootResourceKey
GetRootResourceKey gets the name of the resource object that added by any Read method on ResourceDictionaryWriter.
Public methodGetXaml
Gets the xaml string of the ResourceDictionary with all added svg objects as resources.
Protected methodReadSvgFile
Reads svg file as shapes.
Protected methodReadSvgStream
Reads svg stream as shapes.
Public methodReset
Resets the collected svg files so a new ResourceDictionary can be created.
Protected methodResolveResourceKeyCallback
ResolveResourceKeyCallback is used to change the recommendedKey that is used for resources
Top
Remarks

ResourceDictionaryWriter class is a helper class that can be used to build ResourceDictionaries from multiple input files.

Read more about how to use Resource Dictionaries on: http://msdn.microsoft.com/en-us/library/cc903952(VS.95).aspx

To customize the behaviour of ResourceDictionaryWriter it is possible to derive a custom class form ResourceDictionaryWriter and change protected fields or override its virtual methods.

Examples

The following code shows how to add three svg files to ResourceDictionary with basic optimization settings and get the xaml for the ResourceDictionary.

GeometrySettings settings = GeometrySettings.BasicOptimization;

ResourceDictionaryWriter resourceWriter = new ResourceDictionaryWriter();

resourceWriter.AddGeometryFile("button1.svg", settings);
resourceWriter.AddGeometryFile("button2.svg", settings);
resourceWriter.AddGeometryFile("button3.svg", settings);

string xaml = resourceWriter.GetXaml();

The following code shows how to derive a class from ResourceDictionaryWriter to create a Silverlight ResourceDictionaryWriter with custom NumberFormatString.

public class SilverlightResourceDictionaryWriter : Ab2d.Utility.ReaderSvg.ResourceDictionaryWriter
{
    protected override BaseXamlWriterSettings CreateXamlWriterSettings()
    {
        SilverlightXamlWriterSettings newSilverlightXamlWriterSettings;

        newSilverlightXamlWriterSettings = new SilverlightXamlWriterSettings();

        // format decimal numbers to show only one decimal
        newSilverlightXamlWriterSettings.NumberFormatString = "0.#";

        return newSilverlightXamlWriterSettings;
    }
}
See Also