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'
mc:Ignorable='d'
d:DesignWidth='640'
d:DesignHeight='480'>
//File: Page.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightApplication3
{
public partial class MainPage : UserControl
{
private ScaleTransform scaleTransform = new ScaleTransform();
private RotateTransform rotateTransform = new RotateTransform();
public MainPage()
{
InitializeComponent();
InitializeScaleTransform();
InitializeRotateTransform();
InitializeTransformGroup();
}
private void InitializeScaleTransform()
{
scaleTransform.ScaleX = 1.0;
scaleTransform.ScaleY = 1.0;
scaleTransform.CenterX = 50.0;
scaleTransform.CenterY = 50.0;
}
private void InitializeRotateTransform()
{
rotateTransform.Angle = 0.0;
rotateTransform.CenterX = 150.0;
rotateTransform.CenterY = 50.0;
}
private void InitializeTransformGroup()
{
TransformGroup transformGroup = new TransformGroup();
transformGroup.Children.Add(rotateTransform);
transformGroup.Children.Add(scaleTransform);
myEllipse.RenderTransform = transformGroup;
}
private void UserControl_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.A) // A-Key (Left)
rotateTransform.Angle -= 3.0;
else if (e.Key == Key.D) // D-Key (Right)
rotateTransform.Angle += 3.0;
else if (e.Key == Key.S) // S-Key (Down)
{
scaleTransform.ScaleX *= .97;
scaleTransform.ScaleY *= .97;
}
else if (e.Key == Key.W) // W-Key (Up)
{
scaleTransform.ScaleY *= 1.03;
scaleTransform.ScaleX *= 1.03;
}
else if (e.Key == Key.R) // R-Key (Reset)
{
InitializeScaleTransform();
InitializeRotateTransform();
}
}
}
}