Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C#

An Introduction to the Silverlight samples in the All-In-One Framework

Rate me:
Please Sign up or sign in to vote.
5.00/5 (26 votes)
12 Dec 2009Ms-PL5 min read 55.2K   2.2K   56  
This article introduces several Silverlight samples in the All-In-One Framework.
<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    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" x:Class="CSSL3WriteableBitmap.Screenshot"
    mc:Ignorable="d" d:DesignWidth="479" d:DesignHeight="375" Loaded="UserControl_Loaded">
	<UserControl.Resources>
		<Storyboard x:Name="sb" RepeatBehavior="Forever">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Duration="00:00:00.0010000">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
				<EasingDoubleKeyFrame KeyTime="00:00:05" Value="360"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<EasingDoubleKeyFrame KeyTime="00:00:05" Value="0.5"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<EasingDoubleKeyFrame KeyTime="00:00:05" Value="0.5"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</UserControl.Resources>
	<StackPanel x:Name="LayoutRoot" Background="White">
		<TextBlock Text="WriteableBitmap is also capable of creating screenshots from non-bitmap images. However, there're some limitations. In the following sample, the above rectangle is a vector graphic (in a Canvas). The below one is a screenshot created rapidly using the Canvas. As you can see, the ScaleTransform and ShaderEffect are respected, but the Projection is lost." TextWrapping="Wrap"/>
		<Canvas x:Name="uiElementSource" Height="300" Width="300" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5">
			<Canvas.Projection>
				<PlaneProjection/>
			</Canvas.Projection>
			<Canvas.RenderTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform/>
				</TransformGroup>
			</Canvas.RenderTransform>
			<Rectangle Fill="Red" Height="200" Width="200" Canvas.Left="50" Canvas.Top="50">
				<Rectangle.Effect>
					<DropShadowEffect Color="#FF0095FF"/>
				</Rectangle.Effect>
			</Rectangle>
		</Canvas>
		<Image x:Name="img" Height="300" Width="300" Stretch="None"/>
		<TextBlock Text="Save the screenshot to a bmp file. Note the Projection is lost, and all empty pixels are rendered in black (000000), due to the limitation of WriteableBitmap." TextWrapping="Wrap"/>
		<Button x:Name="SaveFileButton" Content="Save" Click="SaveFileButton_Click"/>
	</StackPanel>
</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 Microsoft Public License (Ms-PL)


Written By
China China
Microsoft All-In-One Code Framework delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++). Each sample is elaborately selected, composed, and documented to demonstrate one frequently-asked, tested or used coding scenario based on our support experience in MSDN newsgroups and forums. If you are a software developer, you can fill the skeleton with blood, muscle and soul. If you are a software tester or a support engineer like us, you may extend the sample codes a little to fit your specific test scenario or refer your customer to this project if the customer's question coincides with what we collected.
http://cfx.codeplex.com/

Comments and Discussions