Paste2Xaml - convert clipboard and metafiles into xaml

Paste2Xaml is a WPF application that can read Windows metafiles (wmf), Enhanced Metafiles (emf) or get matafile objects from clipboard and can convert it into xaml. Embedded images (non-vector part of the metafile) are can also be exported. It is also possible to export xaml for WPF or Silverlight applications.

It is using the Ab2d.ReaderWmf library that imports metafiles at runtime. For example the following XAML reads myClipart.emf (see Ab2d.ReaderWmf for more):
<ab2d:WmfViewbox Source="samples/myClipart.emf"/>


Paste2Xaml Screenshots:
Main Paste2Xaml window
Main Paste2Xaml window - a graph from Microsoft Excel 2003 has been pasted to the application (the application is already showing a WPF representation of the graph)


Export Dialog
Export Dialog - showing the xaml text and all the export options for a metafile. It is possible to export xaml for WPF and Silverlight applications. It is also possible to export to Enhanced Metafiles (emf) - useful for saving clipboard data that can be later opened with Ab2d.ReaderWmf.
The objects from metafile can be exported as Shapes or as Drawings. The Drawings can be further optimited for better performance and lower memory usage.

The graph from Microsoft Excel 2003 shown in XamlPad
The graph from Microsoft Excel 2003 shown in XamlPad.

Paste2Xaml is also used in the Silverlight Excel tutorial.

Notes:
You will found out that many applications export gradient fill areas as bitmap images. The Paste2Xaml cannot convert such bitmap images into vector gradient brushes. I would recommend that you check what images were exported for the matafile and if the images were only gradient brushes, I would recommend that you replace them with WPF's gradients.


Screenshots of metafiles converted to xaml and show in IE (click on image to see it in full size):


Word art from Microsoft Word 2003

Formated cells from Microsoft Excel 2007
   

Calendar created in Microsoft Visio 2003

Database schema created in Microsoft Visio 2003
   

Meeting Room schema created in Microsoft Visio 2003

Electrical equipment schema created in Microsoft Visio 2003
   

Brainstorm diagram created in Microsoft Visio 2003

Sample from Microsoft Office free Clip Arts
   

Sample from Microsoft Office free Clip Arts

Sample from Microsoft Office free Clip Arts
   

Sample from Microsoft Office free Clip Arts

Sample from Microsoft Office free Clip Arts

Note: For creating xaml from Microsoft Office I recommend using its 2003 family. The Office 2007 does not use vector elements to create graphs and other drawings but instead uses an internal rendering that creates bitmaps. For the Office users the end effect looks nicer as in Office 2003, but for exporting to xaml the bitmaps are not so good as vectors.



With Ab2d.ReaderWmf library it is possible to build ResourceDictionares from metafiles. This means all metafiles are converted into xaml which makes them much more efficient and easier to use.

To make building ResourceDictionares there is a ResourceDictionaryWriter sample application that is available with full source code so it can be fully customized. The following screenshot shows ResourceDictionaryWriter application with three metafiles added to the ResourceDictionary (xaml of ResourceDictionary can be seen on the right):

ResourceDictionaryWriter screenshot


New in version 2.2

  • Removed used of BitmapEffect for showing the selected object. Now rectangle is shown over the selected element.
  • Fixed problems when exporting to xaml.

New in version 2.1

  • Added automatic error reporting - when an exception occurs in Paste2Xaml or Ab2d.ReaderWmf, user can now submit error information to help resolve the problems.

New in version 2.0

  • Added support for Drawings and geometry optimization (added with Ab2d.ReaderWmf v3.0)
  • Using Ab2d.Controls.ZoomPanel control for zooming and panning the read metefile.

New in version 1.3

  • Added support for Silverlight 1.0 and 2.0.
  • Added objects tree view with rename option - possible to export elements with name (so thay can be manupulated later from the code).
  • Added object selection with mouse.
  • Rename objects with double clicking on them
  • Show the whole image when opened / pasted (before the left lower part of the image was hidden by the Paste2Xaml buttons)

New in version 1.2

  • Added Zoom toolbox.

 

Note: Subscribe to RSS feed or submit your email on downloads section to be informed about new content on the site.

|  Home  |  Blog  |  Users Forum  |  Contact Us  |  Terms and Conditions  |  Privacy Policy |
Copyright © 2006-2010 Andrej Benedik s.p. All Rights Reserved.