ReaderWmfGetXaml Method |
Name | Description | |
---|---|---|
GetXaml |
Gets xaml of the last read metafile with the default setting for WPF.
| |
GetXaml(BaseXamlWriterSettings) |
Gets xaml of the last read metafile.
|
Read or ReadGeometry must be called before using GetXaml.
To specify detailed options for xaml or to get xaml for Silverlight use GetXaml method.
string xaml; Viewbox sampleViewbox; sampleViewbox = myReader.Read(@"c:\mySample.wmf"); xaml = myReader.GetXaml(); System.IO.File.WriteAllText(@"c:\mySample.xaml", xaml);
string xaml; Viewbox sampleViewbox; sampleViewbox = myReader.Read(@"c:\mySample.wmf"); xaml = myReader.GetXaml(new Ab2d.Common.ReaderWmf.SilverlightXamlWriterSettings()); System.IO.File.WriteAllText(@"c:\mySample_for_Silverlight.xaml", xaml);
The GetXaml method by default writes image uri-s as "image_0", "image_1", and so on. With ResolveImagePathDelegate it is possible to control the image uri of each of the used images. The following code reads the metafile, saves the images to disk and creates xaml text with image uri-s that point to saved images.
// Use the code with: // string xamlText = GetXamlWithImages("images_test.emf", @"c:\temp\image_{0}.{1}"); private string GetXamlWithImages(string metaFileName, string imageFormatString) { string xamlText; int imagesCount; Ab2d.ReaderWmf myReaderWmf; Ab2d.Common.ReaderWmf.WpfXamlWriterSettings xamlSettings; // Read the svg file myReaderWmf = new Ab2d.ReaderWmf(); myReaderWmf.Read(metaFileName); if (myReaderWmf.EmbeddedBitmapImages != null) { imagesCount = myReaderWmf.EmbeddedBitmapImages.Count; for (int i = 0; i < imagesCount; i++) { string oneFileName; EmbeddedImageData oneImageData; oneImageData = myReaderWmf.EmbeddedImagesData[i]; oneFileName = string.Format(imageFormatString, i, oneImageData.ImageFileExtention); System.IO.File.WriteAllBytes(oneFileName, oneImageData.Data); } } xamlSettings = new Ab2d.Common.ReaderWmf.WpfXamlWriterSettings(); xamlSettings.DefaultImageUriFormatString = imageFormatString; xamlText = myReaderWmf.GetXaml(xamlSettings); return xamlText; }