XAML "Game" Written at Bond University


As promised here is the code I wrote at the Gold Coast User Group:


This code displays the score on the button, launches the timeline below that is the XAML which contains the definitions for the two buttons, the timeline and the triggers for the timelines and the bezier i used as the obstacles.



 



Imports System


Imports System.IO


Imports System.Net


Imports System.Windows


Imports System.Windows.Controls


Imports System.Windows.Data


Imports System.Windows.Media.Animation


Imports System.Windows.Navigation


Namespace UntitledProject3


Partial Public Class Scene1


Public Sub New()


MyBase.New()


End Sub


Dim x As Boolean


Dim y As Integer


Private Sub ButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles Button1.Click


If x Then


Button1.Background = Windows.Media.Brushes.Aquamarine


Else


Button1.Background = Windows.Media.Brushes.Red


End If


x = Not x


y = y + 1


Button2.Content = y.ToString


End Sub


End Class


End Namespace


Below is the XAML


 


 




<Grid


xmlns=http://schemas.microsoft.com/winfx/avalon/2005


xmlns:x=http://schemas.microsoft.com/winfx/xaml/2005


xmlns:c=http://schemas.microsoft.com/winfx/markup-compatibility/2005


xmlns:d=http://schemas.microsoft.com/expression/interactivedesigner/2005


c:Ignorable=d


Background=#FFFFFFFF


x:Name=DocumentRoot


Width=849 Height=862 x:Class=UntitledProject3.Scene1>


<Grid.Resources>


<ResourceDictionary>


<Storyboard x:Key=OnLoaded FillBehavior=HoldEnd BeginTime={x:Null} />


<Storyboard x:Key=Button2click FillBehavior=HoldEnd BeginTime={x:Null} d:StoryboardName=Button2click>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button1 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[5].(TranslateTransform.X) RepeatBehavior=Forever>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=21 KeyTime=00:00:00/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=122 KeyTime=00:00:00.7500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=128 KeyTime=00:00:01.5420000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=128 KeyTime=00:00:02.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=165.98286570796282 KeyTime=00:00:03.4170000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=104.58528120507239 KeyTime=00:00:04.0830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=104.58528120507239 KeyTime=00:00:05.2500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=113.59753935992463 KeyTime=00:00:06.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=113.59753935992463 KeyTime=00:00:07.8750000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=317.59753935992461 KeyTime=00:00:08.7920000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=504.59753935992461 KeyTime=00:00:09.8750000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=608.59753935992455 KeyTime=00:00:10.5830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=701.59753935992455 KeyTime=00:00:11.6670000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=714.59753935992467 KeyTime=00:00:12.6670000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=673.59753935992467 KeyTime=00:00:13.4580000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=823.59753935992467 KeyTime=00:00:14.7080000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=868.59753935992467 KeyTime=00:00:14.9580000/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button1 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[5].(TranslateTransform.Y) RepeatBehavior=Forever>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=57 KeyTime=00:00:00/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=99 KeyTime=00:00:00.7500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=136 KeyTime=00:00:01.5420000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=136 KeyTime=00:00:02.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=145.9160400833168 KeyTime=00:00:03.4170000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=198.95925424657682 KeyTime=00:00:04.0830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=198.95925424657682 KeyTime=00:00:05.2500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=268.54964698215025 KeyTime=00:00:06.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=268.54964698215025 KeyTime=00:00:07.8750000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=320.54964698215031 KeyTime=00:00:08.7920000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=340.54964698215031 KeyTime=00:00:09.8750000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=224.54964698215034 KeyTime=00:00:10.5830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=223.54964698215042 KeyTime=00:00:11.6670000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=346.54964698215053 KeyTime=00:00:12.6670000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=473.54964698215065 KeyTime=00:00:13.4580000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=454.54964698215082 KeyTime=00:00:14.7080000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=436.54964698215088 KeyTime=00:00:14.9580000/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button1 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleX) RepeatBehavior=Forever>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=1 KeyTime=00:00:00.7500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=1.16 KeyTime=00:00:01.5420000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=1.16 KeyTime=00:00:03.4170000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-0.99782763292875332 KeyTime=00:00:04.0830000/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button1 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleY) RepeatBehavior=Forever>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=1 KeyTime=00:00:00.7500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-2.2173913043478262 KeyTime=00:00:01.5420000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-2.2173913043478262 KeyTime=00:00:02.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=2.4502582827843176 KeyTime=00:00:03.4170000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=2.9678975742623432 KeyTime=00:00:04.0830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=2.9678975742623432 KeyTime=00:00:05.2500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-3.1339745597485726 KeyTime=00:00:06.3330000/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button1 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[3].(RotateTransform.Angle) RepeatBehavior=Forever>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=0 KeyTime=00:00:01.5420000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=143.38272276813433 KeyTime=00:00:02.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=143.38272276813433 KeyTime=00:00:04.0830000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-7.3789833268271821 KeyTime=00:00:05.2500000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=-7.3789833268271821 KeyTime=00:00:06.3330000/>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=213.76004588934336 KeyTime=00:00:07.8750000/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button2 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleX) Duration=00:00:00.0010000>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=3.8 KeyTime=00:00:00/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


<DoubleAnimationUsingKeyFrames FillBehavior=HoldEnd BeginTime=00:00:00 Storyboard.TargetName=Button2 Storyboard.TargetProperty=(UIElement.RenderTransform).(TransformGroup.Children)[5].(TranslateTransform.X) Duration=00:00:00.0010000>


<DoubleAnimationUsingKeyFrames.KeyFrames>


<DoubleKeyFrameCollection>


<SplineDoubleKeyFrame d:KeyEase=Linear;Linear;0.5;0.5;0.5;0.5 KeySpline=0.5,0.5,0.5,0.5 Value=105 KeyTime=00:00:00/>


</DoubleKeyFrameCollection>


</DoubleAnimationUsingKeyFrames.KeyFrames>


</DoubleAnimationUsingKeyFrames>


</Storyboard>


</ResourceDictionary>


</Grid.Resources>


<Grid.Triggers>


<EventTrigger RoutedEvent=FrameworkElement.Loaded>


<EventTrigger.Actions>


<BeginStoryboard x:Name=OnLoaded_BeginStoryboard Storyboard={DynamicResource OnLoaded}/>


</EventTrigger.Actions>


</EventTrigger>


<EventTrigger RoutedEvent=ButtonBase.Click SourceName=Button2>


<EventTrigger.Actions>


<BeginStoryboard Storyboard={StaticResource Button2click} x:Name=Button2click_BeginStoryboard/>


</EventTrigger.Actions>


</EventTrigger>


</Grid.Triggers>



<ColumnDefinition/>


<RowDefinition/>


<Button x:Name=Button1 Content=Button1 HorizontalAlignment=Left VerticalAlignment=Top RenderTransformOrigin=0.5,0.5>


<Button.RenderTransform>


<TransformGroup>


<TranslateTransform X=0 Y=0/>


<ScaleTransform ScaleX=1 ScaleY=1/>


<SkewTransform AngleX=0 AngleY=0/>


<RotateTransform Angle=0/>


<TranslateTransform X=0 Y=0/>


<TranslateTransform X=0 Y=0/>


</TransformGroup>


</Button.RenderTransform>


</Button>


<Button x:Name=Button2 Content=Button2 HorizontalAlignment=Left VerticalAlignment=Top RenderTransformOrigin=0.5,0.5 Margin=81,1,0,0 Width=75 Height=23>


<Button.RenderTransform>


<TransformGroup>


<TranslateTransform X=0 Y=0/>


<ScaleTransform ScaleX=1 ScaleY=1/>


<SkewTransform AngleX=0 AngleY=0/>


<RotateTransform Angle=0/>


<TranslateTransform X=0 Y=0/>


<TranslateTransform X=0 Y=0/>


</TransformGroup>


</Button.RenderTransform>


</Button>


<Path Stroke=#FF000000 Fill=#FFFFFFFF StrokeMiterLimit=2 StrokeEndLineCap=Square StrokeStartLineCap=Square StrokeLineJoin=Bevel RenderTransformOrigin=0.5,0.5 Stretch=Fill x:Name=Path1 Margin=-83.3144496679306,62.0955771133304,-184.133188188076,196.832889802754 HorizontalAlignment=Stretch VerticalAlignment=Stretch Width=Auto Height=Auto d:LastTangent=0,0>


<Path.Data>


<PathGeometry>


<PathFigure StartPoint=538,63>


<BezierSegment d:IsTangentConstrained=True Point1=179,179 Point2=-100,183 Point3=179,185 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=458,187 Point2=559.999999644874,65 Point3=475.000001016952,185 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=390.00000238903,305 Point2=158.064759306968,326.999983493791 Point3=390.06475869256,304.999984869308 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=622.064758078152,282.999986244825 Point2=672.129513057497,154.99999204165 Point3=622.129513189913,282.999986110712 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=572.129513322328,410.999980179774 Point2=384.194286021227,485.00001947119 Point3=574.1942957019,413.00001616943 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=764.194305382573,341.00001286767 Point2=1432.19432637935,331.000021727158 Point3=685.194294597812,421.000029003576 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=-61.805737183726,511.000036279993 Point2=163.194275338171,344.064779199216 Point3=152.194274364338,511.064792701013 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=141.194273390506,678.06480620281 Point2=-384.805780756476,685.129555347018 Point3=167.194270463645,644.129552549064 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=719.194321683767,603.129549751111 Point2=811.755229869726,637.742626235046 Point3=719.194359080033,603.210208553598 IsStroked=True/>


<BezierSegment d:IsTangentConstrained=True Point1=100.194276015152,372.274941513864 Point2=100.194282035222,371.339697812301 Point3=100.194282035222,371.339697812301 IsStroked=True/>


</PathFigure>


</PathGeometry>


</Path.Data>


</Path>


</Grid>


Comments (0)