Windows 8 Store Apps Learning (69) Other: Custom splash screen,

Source: Internet
Author: User
Tags xmlns

Re-imagine Windows 8 Store Apps (69)-Other: Custom splash screen, program run location, keep screen lit, messagedialog, popupmenu

Author: WEBABCD

Introduced

Re-imagine the other Windows 8 Store Apps

Customizing the splash screen

Checks whether the currently rendered application is running locally or on a remote desktop or emulator

Keep the screen lit

Messagedialog-Information dialog box

PopupMenu-context Menu

Example

1. Show how to customize the splash screen

Feature/mysplashscreen.xaml

<page x:class= "XamlDemo.Feature.MySplashScreen" xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentat Ion "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" using:XamlDemo.Feature "xmlns:d=" http ://schemas.microsoft.com/expression/blend/2008 "xmlns:mc=" http://schemas.openxmlformats.org/ markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" #1b4b7c "> <grid.rowde finitions> <rowdefinition/> <rowdefinition height= "180"/> </grid.rowde finitions> <canvas grid.row= "0" > <image x:name= "splashimage" source= "/ASSETS/SPLASHSC"
            Reen.png "/> </Canvas> <stackpanel grid.row=" 1 "horizontalalignment=" Center "> <progressring isactive= "True"/> <textblock name= "lblmsg" I am a custom startup page, 1 seconds to jump to the home page "text=" 14.667 "margin=" 0 0 0 "/> </stackpanel&Gt </Grid> </Page>

Feature/mysplashscreen.xaml.cs

* * Demonstrates how to customize the splash screen * Associated code: override void Onlaunched in App.xaml.cs (Launchactivatedeventargs args) * Application scenario: * 1, AP The starting screen for P is a picture with a background color, it cannot be changed, * 2, but after the boot screen can refer to the boot screen to do a more rich custom boot screen * 3, after the custom splash screen display, you can do some initialization of the program, initialization completed before entering the main program * * * usin
G System.Threading.Tasks;
Using Windows.ApplicationModel.Activation;
Using Windows.foundation;
Using Windows.UI.Xaml;
    
Using Windows.UI.Xaml.Controls; Namespace Xamldemo.feature {public sealed partial class Mysplashscreen:page {* * * splashscree
         N-app's startup Screen object, in application event arguments in several event handlers, you can get the position information of the picture of the splash screen of * Imagelocation-app, return the Rect type Object 
    
        * Dismissed-app The event triggered when the startup screen is closed////App splash screen related information private splashscreen _splashscreen; Public Mysplashscreen () {this.
    
            InitializeComponent ();
        Lblmsg.text = "Customize the app's startup screen to see the demo of this page when you open the app"; }//Launchactivatedeventargs from override Vo in App.xaml.csID onlaunched (Launchactivatedeventargs args) public mysplashscreen (Launchactivatedeventargs args) { This.
    
            InitializeComponent ();
        Implementcustomsplashscreen (args); Private async void Implementcustomsplashscreen (Launchactivatedeventargs args) {//Window dimensions
    
            When a change occurs, readjust the custom boot screen Window.Current.SizeChanged + = current_sizechanged; Get information about the startup screen of the app _splashscreen = args.
    
            SplashScreen;
    
            The event triggered when the app's startup screen closes _splashscreen.dismissed + = splashscreen_dismissed;
            Get the location of the picture of the app startup screen and press this position to adjust the position of the picture of the custom splash screen Rect splashimagerect = _splashscreen.imagelocation;
            Splashimage.setvalue (Canvas.leftproperty, splashimagerect.x);
            Splashimage.setvalue (Canvas.topproperty, SPLASHIMAGERECT.Y);
            Splashimage.height = Splashimagerect.height;
    
       Splashimage.width = Splashimagerect.width;     Await Task.delay (1000);
            Turn off the custom startup screen and jump to the program homepage var rootframe = new Frame ();
            Rootframe.navigate (typeof (MainPage), args);
            Window.Current.Content = Rootframe;
        Window.Current.Activate ();
            } void Current_sizechanged (object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) {
            Get the latest location for the picture of the app startup screen and press this position to adjust the position of the picture for the custom splash screen Rect splashimagerect = _splashscreen.imagelocation;
            Splashimage.setvalue (Canvas.leftproperty, splashimagerect.x);
            Splashimage.setvalue (Canvas.topproperty, SPLASHIMAGERECT.Y);
            Splashimage.height = Splashimagerect.height;
        Splashimage.width = Splashimagerect.width; } void Splashscreen_dismissed (SplashScreen sender, Object args) {}}}

App.xaml.cs

Protected async override void Onlaunched (Launchactivatedeventargs args)
{
    //display a custom splash screen, see feature/ MySplashScreen.xaml.cs
    if (args. Previousexecutionstate!= applicationexecutionstate.running)
    {
        XamlDemo.Feature.MySplashScreen Mysplashscreen = new XamlDemo.Feature.MySplashScreen (args);
        Window.Current.Content = Mysplashscreen;
    }
    
    Make sure the current window is active
    Window.Current.Activate ();
}

2. Demonstrates how to check whether the currently rendered application is running locally or running on a remote desktop or emulator

Feature/checkrunningsource.xaml.cs

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.