ViewerSvg是一個(gè)WPF和Sileverlight的svg到xaml的轉(zhuǎn)換器。
ViewerSvg is a svg to xaml converter for WPF and Silverlight.

Svg是一種最常用的存儲2D矢量圖像的文件格式。幾乎所有的矢量繪圖程序都能夠保存它的繪圖為svg文件—例如:Adobe® Illustrator®, CorelDRAW®, Inkscape, Microsoft Visio等。
這就意味著設(shè)計(jì)者們能夠使用它們喜愛的設(shè)計(jì)工具來為WPF和Silverlight應(yīng)用程序來創(chuàng)建矢量圖形。還有在Microsoft Visio或者其他應(yīng)用程序中創(chuàng)建的靜態(tài)圖表能夠在WPF或Silverlight中被簡單地轉(zhuǎn)換為動(dòng)態(tài)圖表。
使用ViewerSvg創(chuàng)建的svg文件能夠被轉(zhuǎn)換為XAML文件。因?yàn)閷ο蟮拿旨捌渌鼈兯械膶傩允潜槐4嬷模瑧?yīng)用程序開發(fā)人員對操縱的繪圖具有完全的控制能力。它可以使得WPF或Silverlight平臺添加鼠標(biāo)事件,更改顏色,動(dòng)畫的元素和做其它所有的更改。
在svg文件中的元素能夠被轉(zhuǎn)換成形狀或幾何對象(僅在WPF中)。這些形狀(畫布,橢圓,路徑等)是非常不錯(cuò)的,因?yàn)樗鼈兛梢院唵蔚乇恍薷暮蜑樗麄兎峙涫髽?biāo)事件。幾何對象(GeometryDrawing, PathGeometry等)是形狀的一個(gè)輕量級的版本,它們具有更好的性能和更低的內(nèi)存使用率,但操縱它們變得更困難。因此,圖形對象對復(fù)雜的繪圖是一個(gè)主意。并且更多的讀取幾何對象能夠為更好的性能被更高的優(yōu)化。
ViewerSvg使用Ab2d.ReaderSvg庫在運(yùn)行時(shí)從svg文件導(dǎo)入對象到svgz文件中。使用該庫使得它可以使用svg文件就像jpg,png或其他文件一樣。Ab2d.ReaderSvg還擁有許多先進(jìn)的選項(xiàng)和其它的當(dāng)在使用一個(gè)轉(zhuǎn)換的xaml文件時(shí)時(shí)不可能的可能選項(xiàng)。
特點(diǎn):
為WPF和Silverlight轉(zhuǎn)換svg和svgz文件為xaml。
從id屬性或標(biāo)題元素讀取元素名稱。
讀取高級的svg元素,如patterns, markers和gradients。
重命名導(dǎo)入的對象。
導(dǎo)出嵌入的圖像到圖像文件中。
轉(zhuǎn)換對象為形狀或幾何圖形對象。
附加的幾何圖形對象的優(yōu)化。
文本轉(zhuǎn)換成PathGeometry。
多個(gè)文件批量轉(zhuǎn)換。
自動(dòng)調(diào)整svg文件內(nèi)容的大小。
調(diào)整讀取的畫布大小。
導(dǎo)出選定的元素為位圖圖像。
通過制定的小數(shù)的個(gè)數(shù)來控制XAML的大小。
導(dǎo)出自定義屬性刀xml序列化的DataTable。

Svg is one of the most commonly used file format for storing 2D vector images. Almost all vector drawing programs can save its drawings into svg file - for example: Adobe® Illustrator®, CorelDRAW®, Inkscape, Microsoft Visio, etc.
This means that designers can use their favourite design tool to create vector graphics for WPF or Silverlight applications. Also static diagrams that were created in Microsoft Visio or some other application can be simply turned into dynamic diagrams in WPF or Silverlight.
With ViewerSvg the created svg files can be converted into XAML. Because the names of the objects and all their properties are preserved, the application developers have full control to manipulate the drawing. It is possible to add mouse events, change colors, animate the elements and do all other changes that WPF or Silverlight platform enables.
The elements in svg file can be converted into shapes or geometry objects (WPF only). The shapes (Canvas, Ellipse, Path, etc.) are great because they can be simply modified and mouse events can be assigned to them. Geometry objects (GeometryDrawing, PathGeometry, etc.) are a lightweight version of shapes that have much better performance and lower memory usage but are harder to manipulate. Thereforeg graphics objects are ideal for complex drawings. And what is more the read geometry can be furher optimized for even better performance.
ViewerSvg is using the Ab2d.ReaderSvg library that imports objects from svg and svgz files at runtime. With the library it is possible to use svg files just as jpg, png or other files. Ab2d.ReaderSvg also has many advanced options and other possiblities that are not possible when using a converted xaml file.
Features:
- Convert svg and svgz files into xaml for WPF and Silverlight.
- Read element names from id attribute or title element.
- Read advanced svg elements such as patterns, markers and gradients.
- Rename imported objects.
- Export embedded images into image files.
- Convert objects into Shapes or Geometry objects.
- Additional optimization of Geometry objects.
- Convert texts into PathGeometry
- Batch convertion of multile files.
- Auto size of svg file content.
- Resize read canvas.
- Export selected elements as bitmap image.
- Control the size of XAML with specifing number of decimals.
- Export custom properties into xml serialized DataTable.