|
Zdravím potrebujem poradiť aký správny formát má mať event resp. eventy keď chcem ovládať wpf aplikáciu je to aplikácia pre pohyb kocky. Udalosti ako napr. zmena farby pozadia, zmena farby kocky, spustenie trigeru pre spustenie pohybu ... som vo WPF začitočník a neviem ako to správne napísať, už som skúšal všeličo ale nikde to neôžem nájsť
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
}
..wpf..
<Window.Resources>
<Storyboard x:Key="RotateStoryboard">
<DoubleAnimation BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="rot1" Storyboard.TargetProperty="Angle"
Duration="0:0:6" From="0" To="360" />
<DoubleAnimation RepeatBehavior="Forever" Storyboard.TargetName="rot2" Storyboard.TargetProperty="Angle"
Duration="0:0:8" From="0" To="360"/>
<DoubleAnimation RepeatBehavior="Forever" AutoReverse="True" Storyboard.TargetName="rot3" Storyboard.TargetProperty="OffsetY"
Duration="0:0:12" From="0" To="5"/>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource RotateStoryboard}"/>
</EventTrigger>
</Window.Triggers>
<Grid Background="SeaShell">
<Viewport3D Margin="20,10" Grid.Row="0" Grid.Column="0" RenderTransformOrigin="20.47,0.596"> <!--Rozmery funkčnej plochy -->
<Viewport3D.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="0"/>
<TranslateTransform/>
</TransformGroup>
</Viewport3D.RenderTransform>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="CubeModel">
<!-- Svetlá-->
<AmbientLight Color="DarkBlue" />
<DirectionalLight Color="Gray" Direction="1,0,-2" />
<DirectionalLight Color="Gray" Direction="-1,2,1" />
<GeometryModel3D>
<GeometryModel3D.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="rot1" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<RotateTransform3D CenterZ="5">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="rot2" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D x:Name="rot3"/>
</Transform3DGroup>
</GeometryModel3D.Transform>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
0 1 2 2 3 0
4 5 6 6 7 4
8 9 10 10 11 8
12 13 14 14 15 12
16 17 18 18 19 16
20 21 22 22 23 20
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="FloralWhite" />
</GeometryModel3D.Material>
</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<Viewport3D.Camera>
<PerspectiveCamera
Position = "5.5, 9, 15"
LookDirection = "-1.5, -2, -3"
UpDirection = "0, 1,0 "
FieldOfView = "55"/>
</Viewport3D.Camera>
</Viewport3D>
</Grid>
</Window>
Ďakujem za pomoc
|