Windows Phone 7 Programming Practice basics-multi-touch example (Silverlight)

Source: Internet
Author: User
Tags response code
Objective: To develop a practical manual for Windows Phone 7
Windows Phone 7 programming practices Article 1 Basics
Chapter 1 opening the door to Innovation
Chapter 2 horizontal and vertical views
Chapter 3 simple touch and multi-touch (multi-touch example)
Chapter 4 sensors and services
Chapter V globalization (examples of globalization)
Article 2 Silverlight
Chapter 1 ApplicationProgramMenu Bar (Application menu bar example)
Chapter 2 page navigation and Exception Handling
Chapter 3 isolate buckets
Chapter 4 push notifications (examples of Dynamic Block push notifications and cloud computing push notifications)
Chapter 5 Bing map controls
Chapter 6 Data Binding
Chapter 7 animation and multimedia (audio and video hub example)
Chapter 8 panorama and pivot (panoramic panorama/pivot examples)
Chapter 9 tasks)
Chapter 10 multi-task implementation of the tombstone mechanism (multi-task example)
Chapter 2 Application of mvvm Design Mode
Chapter 2 xNa Application
Article 3 xNa
Chapter 1 basic game development framework of xNa game studio
Chapter 2 touch and gesture in 2D games
Chapter 3 message sending and tombstone mechanisms in 2D games
Chapter 4 xNa game studio 3D Game Development Basics
References: Programming Windows Phone 7
Msdn library -- Windows Phone development
UI design and interaction guide for Windows Phone 7 V2.0
Designing Web sites for phone browsers
Develop for Windows Phone & Xbox 360 code sample Windows Phone 7 Application certification requirements
In the course of this book, we strive to explain the development technology of Windows Phone in depth and different aspects. As personal abilities and levels need to be improved, the analysis of many problems is still superficial. Please give us your advice and suggestions for improvement. Change is not a bad thing. All changes are for better purpose. The key to changing everything is the perspective. My goal: to use technology to change the world I know. Revision statement: this series is formerly called Programming_windows_phone_7 Reading Notes With the update of cognition and Code With the increase in practice, I want to share more with you the specific code examples, so I will change the name of the entire series Windows Phone 7 programming practices Also, the focus of the entire series is on the specific available examples, rather than the goal that was previously only known. At the same time, this change is also a formal change in my personal research focus. All recent studies are centered around the development of Windows Phone 7, which is also an important change in my career. Silverlight multi-touch
By saying goodbye to simple gesture recognition, the feedback from complicated gestures brings the operator's feelings, rather than driving F1. Practice
Download Code Manipulationproject
Create a Windows Phone project named Visual C # Manipulationproject .

Add the following XAML code to mainpage. XAML.
This Code creates a blue rectangle on the canvas. The application subscribes to the manipulationdelta event and controls the movement rectangle contained in the response code of the event.

<Canvas>
<Rectangle
Name = "rectangle"
Width = "200" Height = "200"
Fill = "blue" stroke = "blue" strokethickness = "1"/>
</Canvas>
In the mainpage class, add the following variables.
Private transformgroup; private translatetransform translation; private scaletransform scale; Add the manipulationdelta event handler canvas_manipulationdelta in mainpage. XAML

Right-click mainpage. XAML and select "properties ". Set the RESPONSE event of manipulationdelta in "Event" Canvas_manipulationdelta.

After the settings are complete, the following code is automatically added in the mainpage class: Private
VoidCanvas_manipulationdelta (ObjectSender,ManipulationdeltaeventargsE)
{
}
Add the following code to the mainpage constructor.
This. Transformgroup =New
Transformgroup();
This. Translation =New
Translatetransform();
This. Scale =New
Scaletransform();
This. Transformgroup. Children. Add (This. Scale );
This. Transformgroup. Children. Add (This. Translation );
This. Rectangle. rendertransform =This. Transformgroup;
In the mainpage class, manipulationdelta event handler Canvas_manipulationdelta Add the following code. When the manipulationdelta event occurs during finger operations, the touch input may change the location multiple times. For example, if the user's finger is dragged to the screen, the manipulationdelta event occurs multiple times as the finger moves. Private
VoidCanvas_manipulationdelta (ObjectSender,ManipulationdeltaeventargsE)
{

// Scale the rectangle.

If(E. deltamanipulation. Scale. x = 0) | (E. deltamanipulation. Scale. Y = 0 ))
{

// Increase scalex and scaley by 5%.

This. Scale. scalex * = 1.05;

This. Scale. scaley * = 1.05;
}

Else
{

This. Scale. scalex * = E. deltamanipulation. Scale. X;

This. Scale. scaley * = E. deltamanipulation. Scale. Y;
}

// Move the rectangle.

This. Translation. x + = E. deltamanipulation. Translation. X;

This. Translation. Y + = E. deltamanipulation. Translation. Y;
}
Compile and run the program
The blue rectangle on the screen is waiting for your touch. Test the application
Try complex gesture changes and try the interactive experience of Windows Phone.
    • Move the rectangle, place your finger on the rectangle, and move your finger on the screen.
    • To adjust the size of a rectangle, place the two fingers on the rectangle to zoom out and stretch (pinch and stretch), for example.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.