Original: Using WPF technology to simulate the phone interface
1. Preface
WPF (Windows Presentation Foundation), the "Windows Rendering Foundation", is very clear that it is used to "display" the data to the user (which is plainly used to make the UI). The next step is to introduce a small project that uses WPF to realize the design of the analog phone interface.
2. Functions implemented
This project simulates the mobile interface and realizes several functions as follows:
- Sliding unlock
- Top status Bar display
- View system time
- interface and switch with background and app icon
- Click the calendar icon to jump to the screen that displays the calendar
- Click on the Lock screen icon to enter the sliding unlock state
3. Effect display
-
swipe to unlock, top status bar display, view system time
implementation situation:
1. Realize the sliding unlocking effect of imitation apple phone, while sliding the text on the Unlock module has animation effect. When the sliding unlock arrow is less than half the length of the progress bar, the arrow goes back to the starting point, and more than half the unlock succeeds.
2. Display the status bar at the top of the screen, display the system time function in the lock screen interface, can display the system time in real time.
-
interface and switch with background and app icon
implementation situation:
1. Each page must be set up with a background image, each icon must have its own image.
2. Click the left and right arrows at the bottom of the page to switch between the two interfaces, and click the Home button in the middle to return to the main interface. When the interface switch, with the imitation of the Apple phone page turn effect (fade animation effect), at the same time can be at the bottom of the dot color to determine the current interface.
-
simulate an event response for icon
implementation situation:
1. Some app icon Click event, can jump to the specified interface. Click the calendar to display the calendar. Click on the Lock Screen app icon to enter the state of sliding unlock.
4. Partial Function Code Analysis
-
App.xaml
Program start place, in fact, in the program's App.xaml file: startupuri= "Window1.xaml" This is the program's entry point, after running the program, we will Window1 displayed on the display.
-
Window1.xaml
Page is our real UI, and NavigationWindow just provides us with a framework that page is attached to. Because VS2010 cannot directly create NavigationWindow and page related items, we have to modify them ourselves. First, create a WPF application and change the inherited window class to the NavigationWindow class in the background. Then in XAML the same will be the < window ... tag to NavigationWindow. You cannot have any controls on NavigationWindow ... including grids etc... Remember now our UI is page. Create a new page and draw on it. Then set the Navigationwindow.source as the default page. It is OK to set the Source property of NavigationWindow in the XAML of the main form to the name of the page. In addition, the switch between page is very simple and convenient. Navigationservice.navigate (Newuri ("Xxxxx.xaml", urikind.relative)); XXXXX is the name of the page.
-
Window1.xaml.cs
Add a fade-out (Fade) effect to the page:
Window1 inherit from the NavigationWindow, then obviously seize the navigating event not put, do the following actions:
Cancels the current navigate request if there is a current page under the premise.
Fades out the current page if there is a current page under the premise.
Navigate to the target page after the fade out process is complete.
Fades into the target page.
-
Slide.xaml
Used to display a background picture.
-
Slide.xaml.cs
The sliding unlock function is completed.
Complete the ability to display system time.
- Slide.xaml
- RepeatBehavior: Gets or sets the recurrence behavior of this timeline. Forever Looping Animations
- DoubleAnimation: It continues the animation from the specified starting value to the specified target value within the specified duration.
-
From,to: Value of animation start to end change
-
Slide.xaml.cs
It realizes the function of sliding unlocking to the main interface successfully.
-
Index.xaml
Enables page transitions and the dots at the bottom of the page to display the page toggle state.
5. Download link
http://download.csdn.net/download/qq_22408539/10185109
Simulating the phone interface using WPF technology