Wednesday, June 15, 2011

Using HTML App Host Tasks from the ECMA Script Context

Using the task framework (http://htmlappwp7.codeplex.com/ and the taskprocessor are pretty easy. Basically it needs to look like this:

window.external.notify("Email:pieseczek@hotmail.com:Email from JavaScriptFWP7");

the format for calls are:

window.external.notify(" Task Name : Paramter1 : Parameter2 : etc ");

the current supported tasks include:

Email : To Email : Subject
SystemTray : Boolean Value
EnableFrameRateCounter : Boolean Value
alert : message value : message box title
play : sound uri path
vibrate : hours : minutes : seconds
MarketplaceSearchTask : app id
Analytics : Parmeters * n
MarketplaceDetailTask : app id
WebBrowserTask : URL String

There is also a custom event on the AppHostShell called ScriptNotify that allows you to extend what you can do with tasks for example in the code base the sample app does this extension from the custom event:


private void webBrowser1_ScriptNotify(object sender, NotifyEventArgs e)
{
switch (e.Value.ToString())
{
case "task1":
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "pieseczek@hotmail.com";
emailComposeTask.Body = "";
emailComposeTask.Subject = "Email from JSWP7";
emailComposeTask.Show();
break;
case "task2":
NavigationService.Navigate(new Uri("/About.xaml", UriKind.Relative));
break;
}

}

this gets around a limition with calling the navigation service that I'm currently working on.

No comments:

Post a Comment