Click here to Skip to main content
15,884,472 members
Articles / Programming Languages / C#

Cards Game Library

Rate me:
Please Sign up or sign in to vote.
4.40/5 (20 votes)
29 Aug 2008CPOL2 min read 112K   9K   66  
A library for creating a cards games with Silverlight, with two sample Solitaire games.
<UserControl
	xmlns="http://schemas.microsoft.com/client/2007"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	x:Class="Cards.Silverlight.CardShape"
	Width="730" Height="588">
	<UserControl.Resources>
		<Storyboard x:Name="aniFlipStart">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" BeginTime="00:00:00">
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" BeginTime="00:00:00">
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.3"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="35.339"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-12.657"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Name="aniFlipEnd">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" BeginTime="00:00:00">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" BeginTime="00:00:00">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="36"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Name="animRotate" RepeatBehavior="Forever">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetName="imgCard" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" BeginTime="00:00:00">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
				<SplineDoubleKeyFrame KeyTime="00:00:03" Value="360"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</UserControl.Resources>

	<Canvas x:Name="LayoutRoot">
		<Image HorizontalAlignment="Left" Source="Resources/Cards.PNG" Stretch="None" VerticalAlignment="Top" RenderTransformOrigin="0.05,0.08" x:Name="imgCard" MouseEnter="imgCard_MouseEnter" MouseLeave="imgCard_MouseLeave" MouseLeftButtonDown="imgCard_MouseLeftButtonDown" MouseLeftButtonUp="imgCard_MouseLeftButtonUp" MouseMove="imgCard_MouseMove">
			<Image.RenderTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</Image.RenderTransform>
			<Image.Clip>
				<RectangleGeometry Rect="0,0,72,97" RadiusX="5" RadiusY="5" />
			</Image.Clip>
		</Image>
		<Rectangle Height="103" Width="78" Stroke="#FFFFF500" RadiusX="5" RadiusY="5" Visibility="Visible" StrokeThickness="5" x:Name="rectBorder" Canvas.Left="-3" Canvas.Top="-3" Opacity="0.7"/>
	</Canvas>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Link Development
Egypt Egypt
IF YOU WANT TO IMPROVE YOUR SOFTWARE, DON'T TEST MORE; DEVELOP BETTER.

http://bishoylabib.blogspot.com

Comments and Discussions