jeudi 26 mars 2009

Out of browser experience




Many times, when using a silverlight application, i thinked about how cool could be to detach the application from the browser and use it directly from my desktop. Some silverlight applications are really lightweighted and can easily used on many platforms without to have to install it in the computer ; the only thing needed is the silverlight runtime.
This scenario i've described in a few words may open the way to a new big set of applications.

out of browser experience and silverlight3
The biggest feature of the new silverlight3.0 , called out of browser experience, OOB for the friends, let you start creating application that can easily detached and used from a simple host without the need of a browser instance. The action of detaching the application is really simple, very fast and do not need any kind of installer . You have simply to right click the running application and if it is configured correctly you'll find an "Install...into the computer..." item.
The only question you need to answer is where you want silverlight to let to create the icon, on the desktop or in the start menu (or both) and then your OOB will be started and ready to be used.
The use of this kind of experience need open some problems we will analyze in the next paragraph.

configurating the out of Browser Experience
The first problem we have to address after we have completed our developement , is how to configure it to let the user detach the application to be able to run it online and offline without the browser, this is q auit simple task.In the silverlight project you will find the AppMqnifest.xml file under the Propreties folder und uncomment a special section .Obviously you may customize some propreties:

Deployment.ApplicationIdentity
ApplicationIdentity ShortName= 'ToDoList'
Title='Silverlight ToDoList'
ApplicationIdentity .Blurb

manage offline your tasks
/ApplicationIdentity.Blurb
/ApplicationIdentity
/Deployment.ApplicationIdentity



The properties you can customize are the ShortName that will appear on the menu item,the title and the description (Blurb) that will be displayed in the installation window.You may also add an optional section. This let you add some icons in png format to be displayed on the desktop or start menu.
The installation window let you decide how to install the application you are detaching.You may choose to add some icons; one on the desktop and one on the start menu.
This is the only action you need to perform. If you click yes the files required to run the application will be copied into a folder in AppData and the icons will be created as shortcut to the sllaucher.exe into the silverlight3 install location.
The folder where the application files will be copied is:c:\User\...\AppData\LocalLow\Microsoft\Silverlight\Offline.
After installing the OOB application you may run it again double clicking on the running instance and selection'Remove this application...' from the context menu .
The installation process may be triggered programmatically using the detach () method of the Application class .It's to the developer to add a button that indicate to the user that the application may be detached.The Application.RunningOffline property let the developer know if the application is already detached.Using this property we may show the installation instructions when the application is inthe browser and remote them when installed.
If you want to have a detach button , you can write this code:
this.detach.Visibility=
Application.Current.RunningOffline?Visibility.Collapset:Visibility.Visible;
this.detach.click+=(sender,e)=>Application.Current.Detach();
We may get information about the installation (detaching) or desinstallation of the application handling the event ExecutionState property in the Application.Current instance.
from mr. Andrea Boschin article


Aucun commentaire:

Enregistrer un commentaire