abenobashi
16-05-2011, 13:02
Avrei bisogno di capire come disegno delle figure geometriche con il GroupGeometry e come faccio a fare la stessa cosa con le classi. Ho un esempio su come disegnare dei cerchi (vuoti e pieni), ma poi non so come applicare la stessa cosa ad altre figure. Ad esempio triangoli, quadrati, ecc. Se dovreste riuscire a farmi un esempio di disegno come una casa o qualcosa di simile mi fareste un piacere enorme e poi anche la versione con la classe. Questo è l'esempio che ho io che ho anche testato:
<Window x:Class="Capitolo_09.GroupGeometry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="GroupGeometry" Height="300" Width="300">
<Window.Resources>
<GeometryGroup x:Key="Anello" FillRule="EvenOdd">
<EllipseGeometry RadiusX="50" RadiusY="50"
Center="70 70" />
<EllipseGeometry RadiusX="30" RadiusY="30"
Center="70 70" />
</GeometryGroup>
<!--EvenOdd: figura unica; NonZero: 2 figure separate-->
<GeometryGroup x:Key="Ruota" FillRule="Nonzero">
<EllipseGeometry RadiusX="50" RadiusY="50"
Center="70 70" />
<EllipseGeometry RadiusX="30" RadiusY="30"
Center="70 70" />
</GeometryGroup>
</Window.Resources>
<Grid x:Name="GridGame" Background="White" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Fill="LightGray" Stroke="Blue" StrokeThickness="2" Grid.Row="0" Grid.Column="0"
Data="{StaticResource Ruota}">
</Path>
<Path Fill="Red" Stroke="Orange" StrokeThickness="2" Grid.Row="1" Grid.Column="0"
Data="{StaticResource Ruota}">
</Path>
<Path Fill="Aqua" Stroke="Blue" StrokeThickness="2" Grid.Row="0" Grid.Column="1"
Data="{StaticResource Anello}">
</Path>
<Path Fill="Blue" Stroke="Red" StrokeThickness="2" Grid.Row="1" Grid.Column="1"
Data="{StaticResource Anello}">
</Path>
</Grid>
</Window>
Grazie anticipatamente. Mi fareste un favore enorme se dovreste riuscire a spiegarmi come fare oppure a trovarmi anche qualche guida ben fatta sull'argomento.
<Window x:Class="Capitolo_09.GroupGeometry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="GroupGeometry" Height="300" Width="300">
<Window.Resources>
<GeometryGroup x:Key="Anello" FillRule="EvenOdd">
<EllipseGeometry RadiusX="50" RadiusY="50"
Center="70 70" />
<EllipseGeometry RadiusX="30" RadiusY="30"
Center="70 70" />
</GeometryGroup>
<!--EvenOdd: figura unica; NonZero: 2 figure separate-->
<GeometryGroup x:Key="Ruota" FillRule="Nonzero">
<EllipseGeometry RadiusX="50" RadiusY="50"
Center="70 70" />
<EllipseGeometry RadiusX="30" RadiusY="30"
Center="70 70" />
</GeometryGroup>
</Window.Resources>
<Grid x:Name="GridGame" Background="White" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Fill="LightGray" Stroke="Blue" StrokeThickness="2" Grid.Row="0" Grid.Column="0"
Data="{StaticResource Ruota}">
</Path>
<Path Fill="Red" Stroke="Orange" StrokeThickness="2" Grid.Row="1" Grid.Column="0"
Data="{StaticResource Ruota}">
</Path>
<Path Fill="Aqua" Stroke="Blue" StrokeThickness="2" Grid.Row="0" Grid.Column="1"
Data="{StaticResource Anello}">
</Path>
<Path Fill="Blue" Stroke="Red" StrokeThickness="2" Grid.Row="1" Grid.Column="1"
Data="{StaticResource Anello}">
</Path>
</Grid>
</Window>
Grazie anticipatamente. Mi fareste un favore enorme se dovreste riuscire a spiegarmi come fare oppure a trovarmi anche qualche guida ben fatta sull'argomento.