Windows 8 default Protocol

Source: Internet
Author: User
Windows default Protocol push example: how to start your default application Program File type or protocol. You can also learn how to make your application use the default application file type or Protocol

 

Public Sealed Partial Class Launchiliinput: Page
{
// A pointer back to the main page which is used to gain access to the input and output frames and their content.
Rootpage = Null ;
String Uritolaunch = @" Http://www.bing.com " ;

Public launchiliinput ()
{< br> initializecomponent ();
}

# region template-related code-do not remove
protected override void onnavigatedto (navigationeventargs e)
{< br> /// get a pointer to our main page
rootpage = E. parameter as rootpage;
}

protected override void onnavigatedfrom (navigationeventargs E)
{< BR >}< br> # endregion

// launch a URI.
private async void launchilibutton_click ( Object sender, routedeventargs e)
{< br> /// Create the URI to launch from a string.
var uri = New uri (uritolaunch);

// Launch the URI.
Bool Success = await windows. system. launcher. launchiliasync (URI );
If (SUCCESS)
{
Rootpage. policyuser (" Uri launched: " + URI. absoluteuri, policytype. statusmessage );
}
Else
{
Rootpage. policyuser ( " Uri launch failed. " , Policytype. errormessage );
}
}

// Launch a URI. Show a warning prompt.
Private Async Void Launchiliwithwarningbutton_click ( Object Sender, routedeventargs E)
{
// Create the URI to launch from a string.
VaR Uri = New Uri (uritolaunch );

//Configure the warning prompt.
VaROptions =NewWindows. system. launcheroptions ();
Options. treatasuntrusted =True;

// Launch the URI.
Bool Success = await windows. system. launcher. launchiliasync (Uri, options );
If (SUCCESS)
{
Rootpage. policyuser ( " Uri launched: " + URI. absoluteuri, policytype. statusmessage );
}
Else
{
Rootpage. policyuser ( " Uri launch failed. " , Policytype. errormessage );
}

}
// Launch a URI. show an open with dialog that lets the user chose the handler to use.
Private Async Void Launchiliopenwithbutton_click ( Object Sender, routedeventargs E)
{
// Create the URI to launch from a string.
VaR Uri = New Uri (uritolaunch );

// calulcate the position for the open with dialog.
// an alternative to using the point is to set the rect of the UI element that triggered the launch.
point openwithposition = getopenwithposition (launchiliopenwithbutton);

// next, configure the open with dialog.
var Options = New Windows. system. launcheroptions ();
options. displayapplicationpicker = true ;
options. UI. invocationpoint = openwithposition;
options. UI. preferredplacement = windows. UI. popups. placement. below;

// Launch the URI.
Bool Success = await windows. system. launcher. launchiliasync (Uri, options );
If (SUCCESS)
{
Rootpage. policyuser (" Uri launched: " + URI. absoluteuri, policytype. statusmessage );
}
Else
{
Rootpage. policyuser ( " Uri launch failed. " , Policytype. errormessage );
}
}

// the open with dialog shocould be displayed just under the element that triggered it.
private Windows. foundation. point getopenwithposition (frameworkelement element)
{< br> Windows. UI. XAML. media. generaltransform buttontransform = element. transformtovisual ( null );

Point desiredlocation = buttontransform. transformpoint (NewPoint ());
Desiredlocation. x = desiredlocation. x + element. actualwidth/2;
Desiredlocation. Y = desiredlocation. Y + element. actualheight;

ReturnDesiredlocation;
}

}

Complete example/files/risk/windows8/Alibaba Cloud sample. rar

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.