1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
<Window x:Class="WpRotateUIElementImage.WinViewport2DVisual3D"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Use Viewport2DVisual3D" Height="300" Width="300">
<Window.Resources>
<!--visuabrush-->
<ScrollViewer
x:Key="vb"
Height="50"
Width="50"
VerticalScrollBarVisibility="Auto" >
<StackPanel
Background="Aquamarine">
<TextBlock
x:Name="textblock1"
Margin="10,10,0,13"
Background="Azure"
FontSize="20"
TextWrapping="Wrap"
FontStyle="Italic"
Height="auto"
Width="auto"
Foreground="Red"
Text="rot90 2012">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<SkewTransform/>
<RotateTransform
Angle="180"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</StackPanel >
</ScrollViewer>
<!-- geometry:plane flat sheet . -->
<MeshGeometry3D
x:Key="MyGeometryMesh"
Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0"
TriangleIndices="0 1 2 0 2 3"
TextureCoordinates="0,0 0,1 1,1 1,0" >
</MeshGeometry3D>
<!--Storyboard-->
<Storyboard
x:Key="UIRotation"
RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetName="MyRotation"
Storyboard.TargetProperty="Angle"
From="-60" To="60"
RepeatBehavior="Forever"
AutoReverse="True"
Duration="00:00:5"
/>
</Storyboard>
</Window.Resources>
<DockPanel
Background="White" >
<!--animation-->
<DockPanel.Triggers>
<EventTrigger
RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard
Storyboard="{StaticResource UIRotation}"/>
</EventTrigger>
</DockPanel.Triggers>
<Viewport3D >
<!--camera. -->
<Viewport3D.Camera>
<PerspectiveCamera
Position="0,0,4"
FieldOfView="50">
</PerspectiveCamera>
</Viewport3D.Camera>
<!--Viewport2DVisual3D: UIElement clicquable,bindable.... -->
<Viewport2DVisual3D
Geometry="{StaticResource MyGeometryMesh}"
Visual="{StaticResource vb}">
<!--materiel-->
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" />
</Viewport2DVisual3D.Material>
<!--transform3D-->
<Viewport2DVisual3D.Transform>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D
x:Name="MyRotation"
Angle="40"
Axis="0,1,0">
</AxisAngleRotation3D>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Viewport2DVisual3D.Transform>
<!--visual en resources-->
</Viewport2DVisual3D>
<!--Lights-->
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</DockPanel >
</Window> |
Partager