using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace WP7Toolkit
{
	public partial class MainPage : PhoneApplicationPage
	{
		double _currentScale;
		double _currentRotation;

		// Constructor
		public MainPage()
		{
			InitializeComponent();
		}

		private void OnTap(object sender, GestureEventArgs e)
		{
			transform.TranslateX = transform.TranslateY = 0;
		}

		private void OnDoubleTap(object sender, GestureEventArgs e)
		{
			transform.ScaleX = transform.ScaleY = 1;
		}

		private void OnDragDelta(object sender, DragDeltaGestureEventArgs e)
		{
			transform.TranslateX += e.HorizontalChange;
			transform.TranslateY += e.VerticalChange;
		}

		private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
		{
			_currentScale = transform.ScaleX;
			_currentRotation = transform.Rotation;
		}

		private void OnPinchDelta(object sender, PinchGestureEventArgs e)
		{
			transform.ScaleX = transform.ScaleY = _currentScale * e.DistanceRatio;
			transform.Rotation = _currentRotation + e.TotalAngleDelta;
		}

		private void OnFlick(object sender, FlickGestureEventArgs e)
		{
			flickData.Text = string.Format("{0} Flick: Angle {1} Velocity {2},{3}", e.Direction, Math.Round(e.Angle), e.HorizontalVelocity, e.VerticalVelocity);
		}
	}
}