Silverlight for Windows Embedded Clock Sample

Windows Embedded Compact 7 developers can download, build, and run the Silverlight for Windows Embedded clock code sample that is based on Silverlight for Windows Embedded.By evaluating the sample code, you can learn how to write your own code for a Silverlight for Windows Embe

C++ (2.2 MB)
 
 
 
 
 
(0)
2,963 times
Add to favorites
9/15/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C++
<UserControl 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="SilverlightClock.MainPage"	
    Width="400" 
    Height="400">

    <Canvas x:Name="LayoutRoot" Width="400" Height="400" Loaded="Canvas_Loaded" Background="White">
        <Canvas.Resources>
            <Storyboard x:Name="clockStoryboard">
                <!-- This animation targets the hour hand transform -->
                <DoubleAnimation x:Name="hourAnimation" Storyboard.TargetName="hourHandTransform" Storyboard.TargetProperty="Angle" Duration="12:0:0" RepeatBehavior="Forever"/>

                <!-- This animation targets the minute hand transform -->
                <DoubleAnimation x:Name="minuteAnimation" Storyboard.TargetName="minuteHandTransform" Storyboard.TargetProperty="Angle" Duration="1:0:0" RepeatBehavior="Forever"/>

                <!-- This animation targets the second hand transform  -->
                <DoubleAnimation x:Name="secondAnimation" Storyboard.TargetName="secondHandTransform" Storyboard.TargetProperty="Angle" Duration="0:1:0" RepeatBehavior="Forever"/>
            </Storyboard>
        </Canvas.Resources>

        <!-- Clock Shadow -->
        <Ellipse Width="330" Height="330" Canvas.Left="40" Canvas.Top="40" Fill="Black" Opacity="0.5"/>

        <!-- Outer rim -->
        <Ellipse Stroke="#FF000000" x:Name="outerCircle" Width="330" Height="330" Canvas.Left="32" Canvas.Top="32">
            <Ellipse.Fill>
                <!--This linear gradient creates a subtle shadow effect on the outer rim. -->
                <LinearGradientBrush EndPoint="0.196,0.127" StartPoint="0.852,0.814">
                    <GradientStop Color="#FFC0C0C0" Offset="0.788"/>
                    <GradientStop Color="#FFE4E5F4" Offset="0.995"/>
                </LinearGradientBrush>
            </Ellipse.Fill>
        </Ellipse>

        <!-- Bevel -->
        <Ellipse Stroke="#FF000000" Width="290" Height="281" Canvas.Left="52" Canvas.Top="57">      
            <Ellipse.Fill>
                <!-- This linear gradient creates a subtle shadow effect on 
                    the outer rim. -->
                <LinearGradientBrush EndPoint="0.867,0.848" StartPoint="0.232,0.126">
                    <GradientStop Color="black" Offset="0.1"/>
                    <GradientStop Color="#FFE4E5F4" Offset="0.995"/>
                </LinearGradientBrush>
            </Ellipse.Fill>
        </Ellipse>

        <!-- Clock Face -->
        <Ellipse Stroke="#FF000000" Width="273" Height="265" Canvas.Left="60" Canvas.Top="65" Fill="#FF000000"/>

        <!-- Central Clock Circle -->
        <Ellipse Fill="#FF000000" Stroke="#FF008000" StrokeThickness="7" Width="32" Height="31" Canvas.Left="180" Canvas.Top="190"/>

        <!-- Minute Hand -->
        <Rectangle Fill="Green" Width="8" Height="80" Canvas.Left="192.5" Canvas.Top="226" RenderTransformOrigin="0.41,-0.26" x:Name="MinutedHand">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="minuteHandTransform"/>
            </Rectangle.RenderTransform>
        </Rectangle>

        <!-- Hour Hand -->
        <Rectangle Fill="Green" Width="10" Height="60" Canvas.Left="192.5" Canvas.Top="226" RenderTransformOrigin="0.35,-0.35" x:Name="HourHand">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="hourHandTransform"/>
            </Rectangle.RenderTransform>
        </Rectangle>

        <!-- Second Hand -->
        <Rectangle Fill="Red" Width="5" Height="80" Canvas.Left="192.5" Canvas.Top="226" RenderTransformOrigin="0.65,-0.26" x:Name="SecondHand">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="secondHandTransform"/>
            </Rectangle.RenderTransform>
        </Rectangle>

    </Canvas>

</UserControl>