SlideShare a Scribd company logo
Creating Windows Phone Applications
WinodwsPhoneicons and splashscreens
TopicsThe Windows Phone Start screen and Application ListIcons in Sliverlight and XNACustomising IconsSplash Screens
The Windows Phone UIThe Windows Phone user interface is quite different from any other Microsoft Windows interfaceUsers can “pin” frequently used applications to the Start screenA user can always navigate to the Start screen by pressing the Start button on the phoneFrom the Start screen a user can move to the Application list4
The Start ScreenThe default start screen contains links to built in Windows Phone featuresUsers can add their favourite contacts, media and applications to the screen Each application is represented by a tile5
The Application ListThis is a list of all the applications on the phoneEach application is represented by its icon and the title of the application6
Icons in a Silverlight programWhen you create a Silverlight application Visual Studio creates default versions of the icon filesWe can edit the files to make custom items7
The ApplicationIcon.png imageThe ApplicationIcon.png file holds the icon for the application in the Application List8
The Background.png imageThe Background.png file holds the icon for the application in the Start Screen9
Icons in an XNA programThe icons for an XNA program are differentThe file names are different and there is also an icon for use if a game is deployed to an Xbox 36010
The GameThumbnail.png imageThe GameThumbnail.png file holds the application icon for an XNA game11
The Background.png imageThe Background.png file holds the Start screen image for an XNA game12
Customising IconsIt is important to create good looking icons for your programsThese icons will also be used to brand your program in the Windows Phone MarketplaceThis is probably something worth employing an artist for…13
Splash ScreensA splash screen is an image that is displayed as a program starts runningThey are often used to brand an application and give a user something to watch as a program loads itself into memory14
Silverlight Splash ScreensSilverlight applications are provided with a default splash screen image which just shows a clockYou can replace this with a jpeg image of your ownThe file is called SplashScreenImage.jpg15
Splash screens in XNAXNA projects do not have a splash screen by defaultAn XNA game is expected to load its content and then start drawing the screenThe Windows Phone operating system expects an application to start drawing on the screen within 5 seconds of starting runningIt is quite possible that large amounts of content will take longer than this to load16
XNA Loading StrategiesIf you make a game with a large amount of content you should not load it all in the LoadContent method for the gameInstead the game should load a splash screen and display that while a background thread loads the content into memoryIt is important to manage the content loading process in an XNA game and only load what you need at any point in the game17
SummaryApplications and games on Windows Phone are given icons to identify themThere are images for the application on the Start screen and also in the Application listSilverlight applications also have a splash screen image which is displayed when they start runningXNA developers do not have a splash screen provided but games with lots of content may need to display one
Persisting data in isolatedstorage
TopicsWindows Phone applications and isolated storageUsing isolated storage to store filesStoring name/value pairsAn introduction to the Dictionary collection classStoring settings information in Isolated Storage
Isolated StorageThis storage is called isolated because each application on the phone has its own areaOne application cannot access the storage of anotherThe data is stored in the mass storage of the phoneA program can store very large amounts of data in isolated storage21
Jotpad programThis is the first version of the jotpad programIt displays a textbox for the user to enter textIt also has Load and Save buttons that can be used to load and save the jotted text to isolated storage22
The Save button behaviourprivatevoidsaveButton_Click(object sender, RoutedEventArgs e){saveText("jot.txt", jotTextBox.Text);}When the user presses the Save button the event hander calls a method to save the text from the TextBox into a fileThe saveText method is also given the name of the file to save the text in
The saveText methodprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication())    {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close();        }    }}The method can be used to save data in a file in isolated storage
Using IsolatedStorageprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication())    {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close();        }    }}The method starts by getting a reference to the isolated storage for this application
Creating a fileprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication())    {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close();        }    }}This reference is then used to create a stream connected to the newly created file
Writing to the fileprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication())    {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close();        }    }}The method can now write data to the file and close it
The Load button behaviourprivatevoidloadButton_Click(object sender, RoutedEventArgs e){string text;if ( loadText("jot.txt", out text ) ) {jotTextBox.Text = text;    }else{jotTextBox.Text = "Type your jottings here....";    }}The load behaviour is more complex because a the file might not be availableThe load method displays a default message if loadText fails
Loading from Isolated storagetry{using (IsolatedStorageFileStreamrawStream =isf.OpenFile(filename, System.IO.FileMode.Open))    {StreamReader reader = newStreamReader(rawStream);    result = reader.ReadToEnd();reader.Close();}}catch {returnfalse;}This code reads a file from isolated storageIt uses standard file input/output methods
The Isolated Storage File StoreYour applications can create many files in isolated storageThey can also build up a directory hierarchy within the storageYou can perform stream based input/output with files in the isolated storage30
Demo 1: Jotpad DemoDemo31
Using Settings Isolated storageCreating files in isolated storage is useful, but often a program only wants to store name/value pairsExamples of this:UsernameHome directoryColour and display preferencesThe Isolated storage in Windows Phone also provides setting storage32
Settings and DictionariesThe settings storage works like a Dictionary collectionA Dictionary holds a collection of a particular type which is indexed by key values of another typePrograms can look up items based on the value of the key33
A Dictionary exampleclassPerson{publicstring Name;publicstring Address;publicstring Phone;}The Person class holds information about a given person in our systemThe Person class could contain many more data properties than the ones aboveWe need to store and find Person items
A Dictionary exampleDictionary<string, Person> Personnel = newDictionary<string, Person>();This creates a Dictionary called PersonnelThis holds a collection of Person records that are indexed on a stringGenerics are used to give the types of the index item and the data storedWe could use the name of the person as the index item
Storing in the DictionaryPerson p1 = newPerson { Name = "Rob",                          Address = "His House",                          Phone = "1234"                       };Personnel.Add(p1.Name, p1);This creates a Person value and adds it to the dictionaryThe name value is used as the keyThe dictionary will not allow duplicate keys
Reading from a DictionaryPersonfindPerson = Personnel["Rob"];We can use a string indexer to locate items in the dictionaryThe Personnel dictionary will return Person valuesIf the item cannot be found this statement will throw an exception
Checking for Itemsif (Personnel.ContainsKey("Jim")){// If we get here the dictionary     // contains Jim}A Dictionary also provides a method that can be used to test for the existence of particular keysYour code  should do this rather than throw exceptions
Dictionaries in actionDictionaries are very useful for storing collections that you want to index on a particular key valueThe storing and searching is managed very efficientlyA system can contain multiple dictionaries to index on different key itemsA program can also iterate through the dictionary contents39
Dictionaries and Isolated StorageThe IsolatedStorageSettings class provides a Dictionary based model for storing and retrieving setting informationIt stores any object indexed on a string keyThis makes it very easy to store settings objectsYour application must call the “Save” method on the settings object to complete a save40
Saving using settingsprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This Save method stores a string of text with the supplied name
Getting the isolated storeprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This statement gets a reference to the settings object
Removing an old versionprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This removes an existing item with this nameRemoving does not fail if the item is not there
Saving the dataprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This adds the item and then saves the settings back to the isolated store
Saving itemsYou can save objects other than stringsEach object must have a unique nameYour program must call the Save method to persist the settings information when it has been added to the settings object45
Reading from settings storageReading is the reverse of writingYour program must provide the key of the item it wants to loadNote that the saved item will be returned in the form of an object reference which your program must cast to the required typeThe settings storage does not provide a ContainsKey method46
Loading from the setting storageprivateboolloadText(string filename, outstring result) {IsolatedStorageSettingsisolatedStore = IsolatedStorageSettings.ApplicationSettings;result = "";try {result = (string)isolatedStore[filename];}catch {returnfalse;}returntrue;}
Managing the loading result = "";try {result = (string) isolatedStore[filename];}catch {returnfalse;}Because it is not possible to check if a setting exists the load method must instead catch the exception that is thrown if a key is not foundThe loatText method  returns false to indicate that the load failed48
Isolated StorageA program can create and use as many files as the application requiresIt is also possible to create folders within isolated storage so an application can organise data as requiredThe data will be persisted when the application is not runningIf the application is removed from the phone all its isolated storage is deleted49
Demo 2: Settings JotpadDemo50
SummaryWindows Phone provides “local” storage for applicationsData stored is local to an application and not shared with or visible to othersThere is a local filesystem and a dictionary based setting store which can be used for name/value pairs
Persistingapplicationstate
TopicsThe Windows Phone process modelUnderstanding “tombstoning”Tombstone events in applicationsMaking use of tombstone events to manage application data storage and persistence
Windows Phone Task ManagementThe Windows Phone platform uses a multi-tasking operating systemThis allows phone functions to operate simultaneouslyYou can listen to music and read your emailHowever, this multi-tasking ability is not extended to applications that we write54
Single Tasking ApplicationsIn the present version of Windows Phone it is not possible to run more than one application at the same timeApplications are started and stopped in sequenceIf the user decides to do something different the currently running application will be stopped55
Why Single Task?Removing multi-tasking stops one application from being affected by another as it runsBackground tasks can impact on performance and battery lifeThe limited screen space available to an application makes it hard to manage multiple programs at the same timeThe Windows Phone design does provide for fast task switching by the user56
The Back and Start buttonsThe Back button can be used to exit from one program and return to one being used earlierThe system maintains a stack of applications to allow navigation in and out of tasksPressing Start opens up the Start menu so that a new application can be selectedIt is easy to return to a feature you left by pressing the Start button57
Application SwitchingThis means that an application must be adept at stopping and startingThe aim is to present the appearance that the application was never stopped at allWhen a user returns to an application they were using it should be exactly how they left itThe application must store and retrieve its state to achieve this58
TombstoningTombstoning is the name given to the act of stopping an application so that a user can start anotherIf the user presses the Start button when an application is running that application will be “tombstoned”It is sent an event to signal that it is about to be removed from memory and has a few seconds to save its state and tidy up59
Tombstones and code designThe way that a program responds to tombstone events has an impact on the user experienceIf a user “abandons” an application by pressing Start they might not expect it to retain data they have enteredStart might be used as a quick way of cancelling an activityYou need think about this at design time 60
Jotpad and tombstonesWe are going to make the Jotpad program “tombstone friendly”The program will automatically persist data when the user exits and load on entryIt will also store data when it is tombstonedInitially we will use the isolated storageTo do this we need to add code to the tombstone event methods61
“Tombstone” eventsThere are four “tombstone” eventsLaunching – a new copy of the program has been started by the userClosing- the program is ending normallyDeactivated – the user has pressed Start to run another program (tombstone in progress)Activated – the program is being started as a result of the Back button being used62
Tombstone event methodsEach of the events is mapped onto a method in the App.xaml.cs fileBy adding code into these methods an application can get control when the event occursThe code in the method can load or save program status as appropriate63
Tombstone event methodsprivatevoidApplication_Launching(object sender, LaunchingEventArgse){}privatevoidApplication_Activated(object sender, ActivatedEventArgse){}privatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){}privatevoidApplication_Closing(object sender, ClosingEventArgse){}
Saving on closingprivatevoidApplication_Closing(object sender, ClosingEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.Save();}The closing method gets a reference to the mainPage of the application and calls the Save behaviour on that pageThis removes the need for a Save buttonJotpad now saves the text automatically
MainPage Save methodpublicvoid Save(){saveText("jot.txt", jotTextBox.Text);}This is the Save method in the MainPage for the JotPad applicationIt calls the saveText method to save the text from the textboxIt is now public so it can be used from outside the MainPage class
Saving to memoryThe save methods that we have seen up to now use persistent storage to hold statusThis can be slow and hard to use if you just want to store the current status of the user interfaceWindows Phone provides a way that an application can store status information in memory when it is tombstoned67
Saving on tombstoningprivatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.SaveState();}The deactivated method looks very similar to the closing methodIt calls the SaveState method rather than the save method
Saving on tombstoningprivatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.SaveState();}The deactivated method looks very similar to the closing method which runs when the application closesIt calls the SaveState method rather than the Save method
The SaveStateText methodprivatevoidSaveStateText (string filename, string text){IDictionary<string, object> stateStore = PhoneApplicationService.Current.State;stateStore.Remove(filename);stateStore.Add(filename,text);}The PhoneApplicationService.Current.Stateobject works as a dictionary where a program can store state informationIt is in the Microsoft.Phone.Shell namespace
The loadStateText methodprivateboolloadStateText(string filename, outstring result){IDictionary<string, object> stateStore = PhoneApplicationService.Current.State;result = "";if (!stateStore.ContainsKey(filename)) returnfalse;    result = (string)stateStore[filename];returntrue;}The loadSaveState method fetches the value from the state storage
loadTextvsloadStateTextThe loadStateText method is very similar to the loadState methodThey are both used in exactly the same wayOne saves to isolated storageOne saves to the state objectThey both have exactly the same signature and can be used interchangeablyThis reflects good design72
Reloading data when restartedA program can get Launching or Activated messages when it restartsLaunching means a new copy is startingActivated means that it is restarted after being tombstonedUnfortunately these events occur before any of the Silverlight user interface components have been createdThey can’t be used to actually load data73
Loading data on restartThe JotPad program tries to load from the state memory first and then loads from isolated storage if this failsThis is appropriate behaviour for this applicationIt might not be appropriate for all programs howeverFor some applications the user might want to press Start to abandon their input74
The Load methodpublicvoid Load(){string text;if (loadStateText("jot.txt", out text))  {jotTextBox.Text = text;return;    }if (loadText("jot.txt", out text))  {jotTextBox.Text = text;    }else    {jotTextBox.Text = "Type your jottings here....";    }}
Loading at program startprivatevoidPhoneApplicationPage_Loaded(object sender, RoutedEventArgse){    Load();}The program can call the Load method when the MainPageis loadedIt can then copy all the data content into the user interface elements
Using Visual StudioVisual Studio retains contact with an application when it is tombstonedIf you press the Start button on device or Emulator while debugging a programIf the application is reactivated Visual Studio will continue debuggingThis makes it easy to debug the code that manages tombstoning in your applications77
Demo 1: Jotpad DemoDemo78
SummaryThe Windows Phone operating system uses a single tasking model for applicationsStart and Back buttons are used by the user to quickly switch between applicationsApplications can bind to “tombstone” events so that they can save and load their stateWindows Phone provides state memory that an application can use to retain data if it is stopped
Launchers and choosers
TopicsLaunchers and choosers in contextTombstoning and Launchers and ChoosersUsing a LauncherStarting an application and returning from itUsing a ChooserStarting an application and using the result that is returned
Launchers and ChoosersWindows Phone provides a way for programs to interact with the phone itself:Take photographsPlace phone calls Interact with the address bookSelect mediaNow we are going to find out how to do this82
User InvolvementNote that in all the applications the user is directly involved and has the final say on the actionA program cannot just take a photograph, place a call or send and SMSThe user must confirm these operations before they completeAn application can only initiate the action83
Launchers vs ChoosersApplications call a  Launcher makes use of a phone featurePlace a phone call, send an email or SMSA Chooser is used to select somethingTake a picture and return itSelect an email addressBoth are used in the same way, but a Chooser will generate an event that delivers the result84
Calling a Launcher or ChooserWhen an application calls a Launcher or Chooser the new task gets controlWhen the task is complete the application regains controlIf the user never returns from the Launcher/Chooser the application never gets control backThis when the new task gets control an application may get tombstoned85
LaunchersThese are the Launchers available:PhoneCallTaskEmailComposeTaskSmsComposeTaskSearchTaskWebBrowserTaskMediaPlayerLauncherMarketplaceDetailTaskMarketplaceHubTaskMarketplaceSearchTask86
Using a LauncherAs an example, we could add an email feature to the JotPad applicationThis would allow the user to send a jotting as an emailWhen the Mail button is pressed the EmailComposeTask  is started87
The Mail buttonprivatevoidmailButton_Click(object sender, RoutedEventArgse){sendMail("From JotPad", jotTextBox.Text);}When the user clicks the mail button the event handler calls the sendMail methodThis is given the title and text of the email that is to be sent
The Mail buttonprivatevoidsendMail(string subject, string body){EmailComposeTask email = newEmailComposeTask();email.Body = body;email.Subject = subject;email.Show();}The sendMail method creates an EmailComposeTask instance and then calls Show on that instanceWhen the email has been sent the jotPad program will resume
The Tasks namespaceusingMicrosoft.Phone.Tasks;In order to use the Launcher and Chooser classes by name an application should add the above namespaceOtherwise you will have to use the fully formed version of the class names
Demo 1: Email JotpadDemo91
ChoosersThese are the Choosers available:CameraCaptureTaskEmailAddressChooserTaskPhoneNumberChooserTaskPhotoChooserTaskSaveEmailAddressTaskSavePhoneNumberTask92
ChoosersBefore an application calls a chooser it can bind to an event that the chooser task generatesThis is used to deliver a result object to the application when it regains controlChoosers must be created in the constructor for a page and declared as members of the page class93
Picture display applicationThe picture display application uses the PhotoChooserTask to allow the user to select a picture for displayIt then displays this on the phone screen94
Creating the PhotoChooserTaskPhotoChooserTaskphotoChooser;publicMainPage(){InitializeComponent();photoChooser = newPhotoChooserTask();photoChooser.Completed+= newEventHandler<PhotoResult>(photoChooser_Completed);}The page constructor creates a PhotoChooserTask and binds a method to the Completed event
The Completed event handlervoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK)    {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName));    }}The event handler for the completed event creates a new bitmap image from the filename in the result and displays this
The TaskResult fieldvoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK)    {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName));    }}The TaskResult field in the result is set to TaskResult.OK if the user completed the choose action
The OriginalFileName fieldvoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK)    {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName));    }}The result also contains the filename of the photo that was selectedWe can use this to create a URI to the image
Create a new imagevoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK)    {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName));    }}The program can create a new image from the URI and then set the source of the selected image to this
Load button event handlerprivatevoidloadButton_Click(object sender, RoutedEventArgse){photoChooser.Show();}When the Load button is pressed the event handler just calls the Show method on the chooser that was created in the form constructor
Demo 2: Picture displayDemo101
SummaryLaunchers and Choosers provide a way that applications can use phone featuresLaunchers just start a phone feature running whereas a Chooser can return a result When a Launcher or Chooser is invoked the running application is tombstonedA Chooser will fire an event method in the application when/if it returns

More Related Content

PPS
Using Rational Publishing Engine to generate documents from Rational Rhapsody
TXT
Change logon screen
PDF
Sq lite manager
PPT
RPE - Template formating, style and stylesheet usage
PPTX
09 data storage, backup and roaming
PPT
Synapseindia android apps introduction hello world
DOCX
Android resources in android-chapter9
PPT
Data Storage In Android
Using Rational Publishing Engine to generate documents from Rational Rhapsody
Change logon screen
Sq lite manager
RPE - Template formating, style and stylesheet usage
09 data storage, backup and roaming
Synapseindia android apps introduction hello world
Android resources in android-chapter9
Data Storage In Android

Similar to WP7 HUB_Creando aplicaciones de Windows Phone (20)

PPT
Unit 2 in environment science and technology
DOCX
Android Tutorial For Beginners Part-1
PDF
Programming Without Coding Technology (PWCT) Environment
PPTX
this is PPT for mobail application development
PPT
Android application structure
PPTX
Android Development project
PPT
Lec005 android start_program
PDF
Android App Development 08 : Support Multiple Devices
PPTX
Android development session
PPTX
Assets, files, and data parsing
DOCX
Android-data storage in android-chapter21
PPT
Industrial Training in Android Application
PDF
Application fundamentals
PPT
I/O Streams as an Introduction to Objects and Classesppt
PPTX
Introduction to Android using PhoneGap
PPTX
Android Training (Storing & Shared Preferences)
PPT
Chapter 11
PPT
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
PPT
Savitch ch 06
PDF
mad-unit-3.pdfjsjsjhshehdjsjsjjdjdjsjsikwjsjkks
Unit 2 in environment science and technology
Android Tutorial For Beginners Part-1
Programming Without Coding Technology (PWCT) Environment
this is PPT for mobail application development
Android application structure
Android Development project
Lec005 android start_program
Android App Development 08 : Support Multiple Devices
Android development session
Assets, files, and data parsing
Android-data storage in android-chapter21
Industrial Training in Android Application
Application fundamentals
I/O Streams as an Introduction to Objects and Classesppt
Introduction to Android using PhoneGap
Android Training (Storing & Shared Preferences)
Chapter 11
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Savitch ch 06
mad-unit-3.pdfjsjsjhshehdjsjsjjdjdjsjsikwjsjkks
Ad

More from MICTT Palma (20)

PPTX
Active directory ds ws2008 r2
PPTX
Office 365
PPTX
Ad ds ws2008 r2
PPTX
Sharepoint 2010. Novedades y Mejoras.
PPTX
¿Qué es la nube?
PPTX
Introduction to wcf solutions
PPTX
Introducción a web matrix
PPTX
Ie9 + html5
PPTX
WP7 HUB_XNA overview
PPTX
WP7 HUB_Consuming Data Services
PPTX
WP7 HUB_Introducción a Visual Studio
PPTX
WP7 HUB_Diseño del interfaz con Silverlight
PPTX
WP7 HUB_Platform overview
PPTX
WP7 HUB_Introducción a Silverlight
PPTX
WP7 HUB_Overview and application platform
PPTX
WP7 HUB_Marketplace
PPTX
WP7 HUB_XNA
PPTX
WP7 HUB_Launch event WP7
PPTX
WP7 HUB_Launch event Windows Azure
PPTX
WP7 HUB_Launch event introduction
Active directory ds ws2008 r2
Office 365
Ad ds ws2008 r2
Sharepoint 2010. Novedades y Mejoras.
¿Qué es la nube?
Introduction to wcf solutions
Introducción a web matrix
Ie9 + html5
WP7 HUB_XNA overview
WP7 HUB_Consuming Data Services
WP7 HUB_Introducción a Visual Studio
WP7 HUB_Diseño del interfaz con Silverlight
WP7 HUB_Platform overview
WP7 HUB_Introducción a Silverlight
WP7 HUB_Overview and application platform
WP7 HUB_Marketplace
WP7 HUB_XNA
WP7 HUB_Launch event WP7
WP7 HUB_Launch event Windows Azure
WP7 HUB_Launch event introduction
Ad

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
master seminar digital applications in india
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Structure & Organelles in detailed.
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Supply Chain Operations Speaking Notes -ICLT Program
Pharma ospi slides which help in ospi learning
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
master seminar digital applications in india
Computing-Curriculum for Schools in Ghana
Cell Structure & Organelles in detailed.
Insiders guide to clinical Medicine.pdf
Institutional Correction lecture only . . .
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025

WP7 HUB_Creando aplicaciones de Windows Phone

  • 3. TopicsThe Windows Phone Start screen and Application ListIcons in Sliverlight and XNACustomising IconsSplash Screens
  • 4. The Windows Phone UIThe Windows Phone user interface is quite different from any other Microsoft Windows interfaceUsers can “pin” frequently used applications to the Start screenA user can always navigate to the Start screen by pressing the Start button on the phoneFrom the Start screen a user can move to the Application list4
  • 5. The Start ScreenThe default start screen contains links to built in Windows Phone featuresUsers can add their favourite contacts, media and applications to the screen Each application is represented by a tile5
  • 6. The Application ListThis is a list of all the applications on the phoneEach application is represented by its icon and the title of the application6
  • 7. Icons in a Silverlight programWhen you create a Silverlight application Visual Studio creates default versions of the icon filesWe can edit the files to make custom items7
  • 8. The ApplicationIcon.png imageThe ApplicationIcon.png file holds the icon for the application in the Application List8
  • 9. The Background.png imageThe Background.png file holds the icon for the application in the Start Screen9
  • 10. Icons in an XNA programThe icons for an XNA program are differentThe file names are different and there is also an icon for use if a game is deployed to an Xbox 36010
  • 11. The GameThumbnail.png imageThe GameThumbnail.png file holds the application icon for an XNA game11
  • 12. The Background.png imageThe Background.png file holds the Start screen image for an XNA game12
  • 13. Customising IconsIt is important to create good looking icons for your programsThese icons will also be used to brand your program in the Windows Phone MarketplaceThis is probably something worth employing an artist for…13
  • 14. Splash ScreensA splash screen is an image that is displayed as a program starts runningThey are often used to brand an application and give a user something to watch as a program loads itself into memory14
  • 15. Silverlight Splash ScreensSilverlight applications are provided with a default splash screen image which just shows a clockYou can replace this with a jpeg image of your ownThe file is called SplashScreenImage.jpg15
  • 16. Splash screens in XNAXNA projects do not have a splash screen by defaultAn XNA game is expected to load its content and then start drawing the screenThe Windows Phone operating system expects an application to start drawing on the screen within 5 seconds of starting runningIt is quite possible that large amounts of content will take longer than this to load16
  • 17. XNA Loading StrategiesIf you make a game with a large amount of content you should not load it all in the LoadContent method for the gameInstead the game should load a splash screen and display that while a background thread loads the content into memoryIt is important to manage the content loading process in an XNA game and only load what you need at any point in the game17
  • 18. SummaryApplications and games on Windows Phone are given icons to identify themThere are images for the application on the Start screen and also in the Application listSilverlight applications also have a splash screen image which is displayed when they start runningXNA developers do not have a splash screen provided but games with lots of content may need to display one
  • 19. Persisting data in isolatedstorage
  • 20. TopicsWindows Phone applications and isolated storageUsing isolated storage to store filesStoring name/value pairsAn introduction to the Dictionary collection classStoring settings information in Isolated Storage
  • 21. Isolated StorageThis storage is called isolated because each application on the phone has its own areaOne application cannot access the storage of anotherThe data is stored in the mass storage of the phoneA program can store very large amounts of data in isolated storage21
  • 22. Jotpad programThis is the first version of the jotpad programIt displays a textbox for the user to enter textIt also has Load and Save buttons that can be used to load and save the jotted text to isolated storage22
  • 23. The Save button behaviourprivatevoidsaveButton_Click(object sender, RoutedEventArgs e){saveText("jot.txt", jotTextBox.Text);}When the user presses the Save button the event hander calls a method to save the text from the TextBox into a fileThe saveText method is also given the name of the file to save the text in
  • 24. The saveText methodprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication()) {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close(); } }}The method can be used to save data in a file in isolated storage
  • 25. Using IsolatedStorageprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication()) {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close(); } }}The method starts by getting a reference to the isolated storage for this application
  • 26. Creating a fileprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication()) {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close(); } }}This reference is then used to create a stream connected to the newly created file
  • 27. Writing to the fileprivatevoidsaveText(string filename, string text){using (IsolatedStorageFileisf =IsolatedStorageFile.GetUserStoreForApplication()) {using (IsolatedStorageFileStreamrawStream =isf.CreateFile(filename)) {StreamWriter writer = newStreamWriter(rawStream);writer.Write(text);writer.Close(); } }}The method can now write data to the file and close it
  • 28. The Load button behaviourprivatevoidloadButton_Click(object sender, RoutedEventArgs e){string text;if ( loadText("jot.txt", out text ) ) {jotTextBox.Text = text; }else{jotTextBox.Text = "Type your jottings here...."; }}The load behaviour is more complex because a the file might not be availableThe load method displays a default message if loadText fails
  • 29. Loading from Isolated storagetry{using (IsolatedStorageFileStreamrawStream =isf.OpenFile(filename, System.IO.FileMode.Open)) {StreamReader reader = newStreamReader(rawStream); result = reader.ReadToEnd();reader.Close();}}catch {returnfalse;}This code reads a file from isolated storageIt uses standard file input/output methods
  • 30. The Isolated Storage File StoreYour applications can create many files in isolated storageThey can also build up a directory hierarchy within the storageYou can perform stream based input/output with files in the isolated storage30
  • 31. Demo 1: Jotpad DemoDemo31
  • 32. Using Settings Isolated storageCreating files in isolated storage is useful, but often a program only wants to store name/value pairsExamples of this:UsernameHome directoryColour and display preferencesThe Isolated storage in Windows Phone also provides setting storage32
  • 33. Settings and DictionariesThe settings storage works like a Dictionary collectionA Dictionary holds a collection of a particular type which is indexed by key values of another typePrograms can look up items based on the value of the key33
  • 34. A Dictionary exampleclassPerson{publicstring Name;publicstring Address;publicstring Phone;}The Person class holds information about a given person in our systemThe Person class could contain many more data properties than the ones aboveWe need to store and find Person items
  • 35. A Dictionary exampleDictionary<string, Person> Personnel = newDictionary<string, Person>();This creates a Dictionary called PersonnelThis holds a collection of Person records that are indexed on a stringGenerics are used to give the types of the index item and the data storedWe could use the name of the person as the index item
  • 36. Storing in the DictionaryPerson p1 = newPerson { Name = "Rob", Address = "His House", Phone = "1234" };Personnel.Add(p1.Name, p1);This creates a Person value and adds it to the dictionaryThe name value is used as the keyThe dictionary will not allow duplicate keys
  • 37. Reading from a DictionaryPersonfindPerson = Personnel["Rob"];We can use a string indexer to locate items in the dictionaryThe Personnel dictionary will return Person valuesIf the item cannot be found this statement will throw an exception
  • 38. Checking for Itemsif (Personnel.ContainsKey("Jim")){// If we get here the dictionary // contains Jim}A Dictionary also provides a method that can be used to test for the existence of particular keysYour code should do this rather than throw exceptions
  • 39. Dictionaries in actionDictionaries are very useful for storing collections that you want to index on a particular key valueThe storing and searching is managed very efficientlyA system can contain multiple dictionaries to index on different key itemsA program can also iterate through the dictionary contents39
  • 40. Dictionaries and Isolated StorageThe IsolatedStorageSettings class provides a Dictionary based model for storing and retrieving setting informationIt stores any object indexed on a string keyThis makes it very easy to store settings objectsYour application must call the “Save” method on the settings object to complete a save40
  • 41. Saving using settingsprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This Save method stores a string of text with the supplied name
  • 42. Getting the isolated storeprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This statement gets a reference to the settings object
  • 43. Removing an old versionprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This removes an existing item with this nameRemoving does not fail if the item is not there
  • 44. Saving the dataprivatevoidsaveText(string filename, stringtext){IsolatedStorageSettingsisolatedStore =IsolatedStorageSettings.ApplicationSettings;isolatedStore.Remove(filename);isolatedStore.Add(filename, text);isolatedStore.Save();}This adds the item and then saves the settings back to the isolated store
  • 45. Saving itemsYou can save objects other than stringsEach object must have a unique nameYour program must call the Save method to persist the settings information when it has been added to the settings object45
  • 46. Reading from settings storageReading is the reverse of writingYour program must provide the key of the item it wants to loadNote that the saved item will be returned in the form of an object reference which your program must cast to the required typeThe settings storage does not provide a ContainsKey method46
  • 47. Loading from the setting storageprivateboolloadText(string filename, outstring result) {IsolatedStorageSettingsisolatedStore = IsolatedStorageSettings.ApplicationSettings;result = "";try {result = (string)isolatedStore[filename];}catch {returnfalse;}returntrue;}
  • 48. Managing the loading result = "";try {result = (string) isolatedStore[filename];}catch {returnfalse;}Because it is not possible to check if a setting exists the load method must instead catch the exception that is thrown if a key is not foundThe loatText method returns false to indicate that the load failed48
  • 49. Isolated StorageA program can create and use as many files as the application requiresIt is also possible to create folders within isolated storage so an application can organise data as requiredThe data will be persisted when the application is not runningIf the application is removed from the phone all its isolated storage is deleted49
  • 50. Demo 2: Settings JotpadDemo50
  • 51. SummaryWindows Phone provides “local” storage for applicationsData stored is local to an application and not shared with or visible to othersThere is a local filesystem and a dictionary based setting store which can be used for name/value pairs
  • 53. TopicsThe Windows Phone process modelUnderstanding “tombstoning”Tombstone events in applicationsMaking use of tombstone events to manage application data storage and persistence
  • 54. Windows Phone Task ManagementThe Windows Phone platform uses a multi-tasking operating systemThis allows phone functions to operate simultaneouslyYou can listen to music and read your emailHowever, this multi-tasking ability is not extended to applications that we write54
  • 55. Single Tasking ApplicationsIn the present version of Windows Phone it is not possible to run more than one application at the same timeApplications are started and stopped in sequenceIf the user decides to do something different the currently running application will be stopped55
  • 56. Why Single Task?Removing multi-tasking stops one application from being affected by another as it runsBackground tasks can impact on performance and battery lifeThe limited screen space available to an application makes it hard to manage multiple programs at the same timeThe Windows Phone design does provide for fast task switching by the user56
  • 57. The Back and Start buttonsThe Back button can be used to exit from one program and return to one being used earlierThe system maintains a stack of applications to allow navigation in and out of tasksPressing Start opens up the Start menu so that a new application can be selectedIt is easy to return to a feature you left by pressing the Start button57
  • 58. Application SwitchingThis means that an application must be adept at stopping and startingThe aim is to present the appearance that the application was never stopped at allWhen a user returns to an application they were using it should be exactly how they left itThe application must store and retrieve its state to achieve this58
  • 59. TombstoningTombstoning is the name given to the act of stopping an application so that a user can start anotherIf the user presses the Start button when an application is running that application will be “tombstoned”It is sent an event to signal that it is about to be removed from memory and has a few seconds to save its state and tidy up59
  • 60. Tombstones and code designThe way that a program responds to tombstone events has an impact on the user experienceIf a user “abandons” an application by pressing Start they might not expect it to retain data they have enteredStart might be used as a quick way of cancelling an activityYou need think about this at design time 60
  • 61. Jotpad and tombstonesWe are going to make the Jotpad program “tombstone friendly”The program will automatically persist data when the user exits and load on entryIt will also store data when it is tombstonedInitially we will use the isolated storageTo do this we need to add code to the tombstone event methods61
  • 62. “Tombstone” eventsThere are four “tombstone” eventsLaunching – a new copy of the program has been started by the userClosing- the program is ending normallyDeactivated – the user has pressed Start to run another program (tombstone in progress)Activated – the program is being started as a result of the Back button being used62
  • 63. Tombstone event methodsEach of the events is mapped onto a method in the App.xaml.cs fileBy adding code into these methods an application can get control when the event occursThe code in the method can load or save program status as appropriate63
  • 64. Tombstone event methodsprivatevoidApplication_Launching(object sender, LaunchingEventArgse){}privatevoidApplication_Activated(object sender, ActivatedEventArgse){}privatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){}privatevoidApplication_Closing(object sender, ClosingEventArgse){}
  • 65. Saving on closingprivatevoidApplication_Closing(object sender, ClosingEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.Save();}The closing method gets a reference to the mainPage of the application and calls the Save behaviour on that pageThis removes the need for a Save buttonJotpad now saves the text automatically
  • 66. MainPage Save methodpublicvoid Save(){saveText("jot.txt", jotTextBox.Text);}This is the Save method in the MainPage for the JotPad applicationIt calls the saveText method to save the text from the textboxIt is now public so it can be used from outside the MainPage class
  • 67. Saving to memoryThe save methods that we have seen up to now use persistent storage to hold statusThis can be slow and hard to use if you just want to store the current status of the user interfaceWindows Phone provides a way that an application can store status information in memory when it is tombstoned67
  • 68. Saving on tombstoningprivatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.SaveState();}The deactivated method looks very similar to the closing methodIt calls the SaveState method rather than the save method
  • 69. Saving on tombstoningprivatevoidApplication_Deactivated(object sender, DeactivatedEventArgse){MainPagejotPadPage = (MainPage)RootFrame.Content;jotPadPage.SaveState();}The deactivated method looks very similar to the closing method which runs when the application closesIt calls the SaveState method rather than the Save method
  • 70. The SaveStateText methodprivatevoidSaveStateText (string filename, string text){IDictionary<string, object> stateStore = PhoneApplicationService.Current.State;stateStore.Remove(filename);stateStore.Add(filename,text);}The PhoneApplicationService.Current.Stateobject works as a dictionary where a program can store state informationIt is in the Microsoft.Phone.Shell namespace
  • 71. The loadStateText methodprivateboolloadStateText(string filename, outstring result){IDictionary<string, object> stateStore = PhoneApplicationService.Current.State;result = "";if (!stateStore.ContainsKey(filename)) returnfalse; result = (string)stateStore[filename];returntrue;}The loadSaveState method fetches the value from the state storage
  • 72. loadTextvsloadStateTextThe loadStateText method is very similar to the loadState methodThey are both used in exactly the same wayOne saves to isolated storageOne saves to the state objectThey both have exactly the same signature and can be used interchangeablyThis reflects good design72
  • 73. Reloading data when restartedA program can get Launching or Activated messages when it restartsLaunching means a new copy is startingActivated means that it is restarted after being tombstonedUnfortunately these events occur before any of the Silverlight user interface components have been createdThey can’t be used to actually load data73
  • 74. Loading data on restartThe JotPad program tries to load from the state memory first and then loads from isolated storage if this failsThis is appropriate behaviour for this applicationIt might not be appropriate for all programs howeverFor some applications the user might want to press Start to abandon their input74
  • 75. The Load methodpublicvoid Load(){string text;if (loadStateText("jot.txt", out text)) {jotTextBox.Text = text;return; }if (loadText("jot.txt", out text)) {jotTextBox.Text = text; }else {jotTextBox.Text = "Type your jottings here...."; }}
  • 76. Loading at program startprivatevoidPhoneApplicationPage_Loaded(object sender, RoutedEventArgse){ Load();}The program can call the Load method when the MainPageis loadedIt can then copy all the data content into the user interface elements
  • 77. Using Visual StudioVisual Studio retains contact with an application when it is tombstonedIf you press the Start button on device or Emulator while debugging a programIf the application is reactivated Visual Studio will continue debuggingThis makes it easy to debug the code that manages tombstoning in your applications77
  • 78. Demo 1: Jotpad DemoDemo78
  • 79. SummaryThe Windows Phone operating system uses a single tasking model for applicationsStart and Back buttons are used by the user to quickly switch between applicationsApplications can bind to “tombstone” events so that they can save and load their stateWindows Phone provides state memory that an application can use to retain data if it is stopped
  • 81. TopicsLaunchers and choosers in contextTombstoning and Launchers and ChoosersUsing a LauncherStarting an application and returning from itUsing a ChooserStarting an application and using the result that is returned
  • 82. Launchers and ChoosersWindows Phone provides a way for programs to interact with the phone itself:Take photographsPlace phone calls Interact with the address bookSelect mediaNow we are going to find out how to do this82
  • 83. User InvolvementNote that in all the applications the user is directly involved and has the final say on the actionA program cannot just take a photograph, place a call or send and SMSThe user must confirm these operations before they completeAn application can only initiate the action83
  • 84. Launchers vs ChoosersApplications call a Launcher makes use of a phone featurePlace a phone call, send an email or SMSA Chooser is used to select somethingTake a picture and return itSelect an email addressBoth are used in the same way, but a Chooser will generate an event that delivers the result84
  • 85. Calling a Launcher or ChooserWhen an application calls a Launcher or Chooser the new task gets controlWhen the task is complete the application regains controlIf the user never returns from the Launcher/Chooser the application never gets control backThis when the new task gets control an application may get tombstoned85
  • 86. LaunchersThese are the Launchers available:PhoneCallTaskEmailComposeTaskSmsComposeTaskSearchTaskWebBrowserTaskMediaPlayerLauncherMarketplaceDetailTaskMarketplaceHubTaskMarketplaceSearchTask86
  • 87. Using a LauncherAs an example, we could add an email feature to the JotPad applicationThis would allow the user to send a jotting as an emailWhen the Mail button is pressed the EmailComposeTask is started87
  • 88. The Mail buttonprivatevoidmailButton_Click(object sender, RoutedEventArgse){sendMail("From JotPad", jotTextBox.Text);}When the user clicks the mail button the event handler calls the sendMail methodThis is given the title and text of the email that is to be sent
  • 89. The Mail buttonprivatevoidsendMail(string subject, string body){EmailComposeTask email = newEmailComposeTask();email.Body = body;email.Subject = subject;email.Show();}The sendMail method creates an EmailComposeTask instance and then calls Show on that instanceWhen the email has been sent the jotPad program will resume
  • 90. The Tasks namespaceusingMicrosoft.Phone.Tasks;In order to use the Launcher and Chooser classes by name an application should add the above namespaceOtherwise you will have to use the fully formed version of the class names
  • 91. Demo 1: Email JotpadDemo91
  • 92. ChoosersThese are the Choosers available:CameraCaptureTaskEmailAddressChooserTaskPhoneNumberChooserTaskPhotoChooserTaskSaveEmailAddressTaskSavePhoneNumberTask92
  • 93. ChoosersBefore an application calls a chooser it can bind to an event that the chooser task generatesThis is used to deliver a result object to the application when it regains controlChoosers must be created in the constructor for a page and declared as members of the page class93
  • 94. Picture display applicationThe picture display application uses the PhotoChooserTask to allow the user to select a picture for displayIt then displays this on the phone screen94
  • 95. Creating the PhotoChooserTaskPhotoChooserTaskphotoChooser;publicMainPage(){InitializeComponent();photoChooser = newPhotoChooserTask();photoChooser.Completed+= newEventHandler<PhotoResult>(photoChooser_Completed);}The page constructor creates a PhotoChooserTask and binds a method to the Completed event
  • 96. The Completed event handlervoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK) {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName)); }}The event handler for the completed event creates a new bitmap image from the filename in the result and displays this
  • 97. The TaskResult fieldvoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK) {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName)); }}The TaskResult field in the result is set to TaskResult.OK if the user completed the choose action
  • 98. The OriginalFileName fieldvoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK) {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName)); }}The result also contains the filename of the photo that was selectedWe can use this to create a URI to the image
  • 99. Create a new imagevoidphotoChooser_Completed(object sender, PhotoResult e){if (e.TaskResult == TaskResult.OK) {selectedImage.Source = newBitmapImage(newUri(e.OriginalFileName)); }}The program can create a new image from the URI and then set the source of the selected image to this
  • 100. Load button event handlerprivatevoidloadButton_Click(object sender, RoutedEventArgse){photoChooser.Show();}When the Load button is pressed the event handler just calls the Show method on the chooser that was created in the form constructor
  • 101. Demo 2: Picture displayDemo101
  • 102. SummaryLaunchers and Choosers provide a way that applications can use phone featuresLaunchers just start a phone feature running whereas a Chooser can return a result When a Launcher or Chooser is invoked the running application is tombstonedA Chooser will fire an event method in the application when/if it returns