Ab2d.ReaderWmf是一個類庫,它可以被用于在運行時讀取Windows圖元文件(wmf)以及增強型圖元文件(emf)和導出它的元素到WPF的Viewbox中。
Ab2d.ReaderWmf is a class library that can be used to read Windows metafiles (wmf) and also Enhanced Metafiles (emf) in runtime and import its elements into WPF's Viewbox.
請注意的是Ab2d.ReaderWmf不能在Silverlight應用程序中使用— 但是能在XBAP Web Browser應用程序中使用。對于Sileverlight使用Paste2Xaml,我們可以在導出選項中選擇導出作為Silverlight xaml選項。
該庫的使用時通過Paste2Xaml應用程序。它也能夠被用在任何其他的使用圖元文件的剪切部分的應用程序中。有了ReaderWmf庫,就不需要轉換它們為xaml—圖元文件能夠在運行時需要時被簡單地導入。
讀取Windows圖元文件(wmf)或增強型圖元文件(emf)到XAML中:
-
在項目中添加Ab2d.ReaderWmf應用
-
在xaml根元素中添加命名空間的定義(例如Window):
xmlns:ab2d="clr-namespace:Ab2d.Controls;assembly=Ab2d.ReaderWmf"
-
使用Ab2d.Controls.WmfViewbox讀取圖元文件為形狀— 設置Source屬性為圖元文件的位置。
-
使用Ab2d.Controls.WmfDrawing讀取一個圖元文件為繪圖— 設置Source屬性為圖元文件的位置。
Source屬性僅能被用作圖像控件的Source。根據圖元文件的位置和使用下列模式的構建行為來載入文件。以下示例顯示從各種資源中怎樣讀取圖元文件(作為Shapes)。
Note that Ab2d.ReaderWmf cannot be used in Silverlight applications - but can be used in XBAP Web Browser application. For Silverlight use Paste2Xaml and select export as Silverlight xaml in the export options.
The library is used by Paste2Xaml application. It can also be used in any other application which is using metafile cliparts. With ReaderWmf library there is no need to convert them into xaml - metafiles can be simple imported at runtime when needed.
Read Windows metafiles (wmf) or Enhanced Metafiles (emf) file in XAML:
-
In project add reference to Ab2d.ReaderWmf
-
Add namespace definition into root xaml element (for example Window):
xmlns:ab2d="clr-namespace:Ab2d.Controls;assembly=Ab2d.ReaderWmf"
-
Use Ab2d.Controls.WmfViewbox to read a metafile file as Shapes - set Source property to metafile location.
-
Use Ab2d.Controls.WmfDrawing to read a metafile file as Drawings - set Source property to metafile location.
Source property can be uses just as Source of the Image control. Depending on the location and metafile build action use of the following patterns to load the file. The following examples show how to read matafile (as Shapes) from various resources.