Click or drag to resize
ResourceDictionaryWriter Class
ResourceDictionaryWriter class is a helper class that can be used to build ResourceDictionaries from multiple input files.
Inheritance Hierarchy
SystemObject
  Ab2d.Utility.ReaderWmfResourceDictionaryWriter

Namespace: Ab2d.Utility.ReaderWmf
Assembly: Ab2d.ReaderWmf (in Ab2d.ReaderWmf.dll) Version: 7.1.5512.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 metafiles as geometries.
Public propertyUsedReaderWmf
Ab2d.ReaderWmf instance that is used to read metafiles.
Public propertyXamlWriterSettings
BaseXamlWriterSettings that is used for GetXaml method.
Top
Methods
  NameDescription
Public methodAddFile
Adds a metafile to the ResourceDictionary as WPF Shapes.
Public methodAddGeometryFile
Adds a metafile file to the ResourceDictionary as Geometry.
Public methodAddGeometryStream
Adds a metafile from stream to the ResourceDictionary as Geometry.
Public methodAddStream
Adds a metafile from stream to the ResourceDictionary as WPF Shapes.
Public methodGetXaml
Gets the xaml string of the ResourceDictionary with all added metafile objects as resources.
Public methodReset
Resets the collected metafiles so a new ResourceDictionary can be created.
Top
Remarks
Read more about how to use Resource Dictionaries on: http://msdn.microsoft.com/en-us/library/cc903952(VS.95).aspx
Examples
The following code shows how to add three metafiles to ResourceDictionary with basic optimization settings and get the xaml for the ResourceDictionary.
GeometrySettings settings = GeometrySettings.BasicOptimization;

ResourceDictionaryWriter resourceWriter = new ResourceDictionaryWriter();

resourceWriter.AddGeometryFile("matafile1.wmf", settings);
resourceWriter.AddGeometryFile("matafile2.wmf", settings);
resourceWriter.AddGeometryFile("matafile3.wmf", 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.ReaderWmf.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