Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geometry drawing in WPF

I'm kinda new to all this geometry part, but I can see it gives me the ability to draw basically whatever I want. I can't find a good manual that teaches how to create whatever image I have in my head. I really hoped to find some kinda painter that extracts the data of the geometry for me but no luck so far.

For example, I found this online:

<Geometry x:Key="MagnifierIconGeometry">M44,12 C32,12 22,22 22,34 22,46 32,56 44,56 56,56 66,46 66,34 66,22 56,12 44,12z M44,0 C63,0 78,15 78,34 78,53 63,68 44,68 40,68 36.5,67.5 33,66 L32.5,66 14,90 0,79.5 18,55.5 17,55 C13,49 10,42 10,34 10,15 25,0 44,0z</Geometry>

You can tell by the name what it draws, but I would like to know how to do it myself?

If anyone could point me to a manual/any kind of program that would be fantastic!

Thanks.

like image 333
user1531186 Avatar asked Mar 23 '14 10:03

user1531186


1 Answers

To display vector graphics, in this case you can use the Path like this:

<Window.Resources>
    <Geometry x:Key="MagnifierIconGeometry">M44,12 C32,12 22,22 22,34 22,46 32,56 44,56 56,56 66,46 66,34 66,22 56,12 44,12z M44,0 C63,0 78,15 78,34 78,53 63,68 44,68 40,68 36.5,67.5 33,66 L32.5,66 14,90 0,79.5 18,55.5 17,55 C13,49 10,42 10,34 10,15 25,0 44,0z</Geometry>
</Window.Resources>

<Grid>
    <Path Data="{StaticResource MagnifierIconGeometry}" 
          Width="30" 
          Height="30" 
          Fill="Aqua"
          Stretch="Fill" />
</Grid>

Output

enter image description here

More info

For more information you can see this:

MSDN: Shapes and Basic Drawing in WPF Overview

Charles Petzold: Vector Graphics and the WPF Shape Class

Graphics in WPF

Source of vector images

The www.modernuiicons.com contains a huge amount of vector images that you can use in your applications.

Program for working with vector images

To work with vector graphics you can use Microsoft Expression Blend:

MSDN: Drawing overview

Convert SVG to XAML and use it in Silverlight or WPF

like image 154
Anatoliy Nikolaev Avatar answered Oct 07 '22 23:10

Anatoliy Nikolaev