Click or drag to resize
WmfDrawing Class
WmfDrawing is an Image control that enables showing Windows Metafile (wmf) and Enhanced Metafiles (emf) images as drawing objects in WPF and can be used in Extensible Application Markup Language (XAML). Set its Source propety to source of wmf or wmf file - use pack Uri specifications. Set OptimizationPercent to optimize the read drawing objects (0 - no optimization, 100 - full optimization).
Inheritance Hierarchy

Namespace: Ab2d.Controls
Assembly: Ab2d.ReaderWmf (in Ab2d.ReaderWmf.dll) Version: 7.1.5512.1040
Syntax
C#
public class WmfDrawing : FrameworkElement, IUriContext, 
	ISupportInitialize

The WmfDrawing type exposes the following members.

Constructors
  NameDescription
Public methodWmfDrawing
Constructor
Top
Properties
  NameDescription
Public propertyInnerImage
Gets the Image returned by last read with ReaderWmf.
Public propertyInnerReaderWmf
Gets the ReaderWmf that is used to read the metafile.
Public propertyOptimizationPercent
Gets or sets the geometry optimization percent. 0 means no optimization, 100 means full optimization.
Public propertySource
Gets or sets the Source of the metafile image
Public propertyStretch
Gets or sets the WmfDrawing.Windows.Media.Stretch mode, which determines how content fits into the available space.
Public propertyStretchDirection
Gets or sets the System.Windows.Controls.StretchDirection, which determines how scaling is applied to the contents of a WmfDrawing.
Top
Events
  NameDescription
Public eventMetafileLoaded
Occurs when the reading of metafile is completed.
Public eventMetafileLoading
Occurs before the reading of metafile is started.
Top
Fields
  NameDescription
Public fieldStatic memberOptimizationPercentProperty
OptimizationPercentProperty
Public fieldStatic memberSourceProperty
SourceProperty
Public fieldStatic memberStretchDirectionProperty
StretchDirectionProperty
Public fieldStatic memberStretchProperty
StretchProperty
Top
Remarks

The difference between WmfDrawing and WmfViewbox is that WmfViewbox gets objects as Shapes (Canvas, Path, Polyline, etc) and WmfDrawing produces Drawings (DrawingGeometry, StreamGeometry, etc). Drawings have better performance and lower memory consumption, but Shapes support more funtionality - layout, focus, mouse events, etc.

For more information about reading geometres see ReadGeometry(String, GeometrySettings).

For more information about setting the optimization percent see FromOptimizationPercentage(Int32).

WmfViewbox can be used in xaml. If you would like to read metafile in code and need some more advanced features and options please use ReaderWmf

Examples
The following example shows myMetafile.wmf metafile inside a Grid (the matafile's BuildAction is set to Resource). The meafile is read as Drawing that is fully optimized for better performance (if animated).
<Window x:Class="Ab2d.ReaderWmfSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ab2d="clr-namespace:Ab2d.Controls;assembly=Ab2d.ReaderWmf"
        Title="Window1" Height="500" Width="500"/>
     <Grid>
         <ab2d:WmfDrawing Name="myWmfDrawing" Source="myMetafile.wmf"
                          OptimizationPercent="100" Stretch="Uniform"/>  
     </Grid>
</Window>
See Also