Windows Phone 7 starter and Selector

Source: Internet
Author: User

Unlike Android, WP7 does not allow you to call the functions of the local machine to complete some work in combination with your own programs. To use these functions, you can only call the interfaces encapsulated by the system. These interfaces enable system functions, basically, they all have interfaces, so they cannot be embedded in the logic. They can only interrupt the current logic and give the operation permission to the system. If it is the initiator, the program logic ends here. If it is a selector, wait for the user to complete the operation, get the returned result, and continue the following logic. So how can we distinguish between the initiator and the selector? The only difference is that there is a selector with the returned result. If no returned result is returned, the starter is used to start the system. The initiator and Selector are encapsulated in the Microsoft. Phone. Tasks namespace. Below is a list of all the starters and Selector classes.

Addresschoosertask

Allow the application to start the "Contact" application. Use this method to obtain the physical address of the selected contact.

Bingmapsdirectionstask

Allow the application to start the Bing map application, specify the start or end position of the route to be displayed, or specify both.

Bingmapstask

Allow the application to start the Bing map application and locate the location specified by the center attribute or the current location of the user. If searchterm is set, the location that matches the search term is marked on the map.

Cameracapturetask

Allow the application to start the camera application. This method allows users to take photos through your application.

Connectionsettingstask

Allow applications to start a "Settings" dialog box that allows users to change the network connection settings of devices.

Emailaddresschoosertask

Allow the application to start the "Contact" application. Use this method to obtain the email address of the selected contact.

Emailcomposetask

Allow the application to start the "email" application through the displayed new mail. This method allows users to send emails through your application.

Gameinvitetask

Allows applications to display a game invitation screen that allows users to invite gamers to join multi-player game sessions.

Marketplacedetailtask

Allows the application to start the Windows Phone mall client application and display the details page of the specified product.

Marketplacehubtask

Allows applications to start Windows Phone mall client applications.

Marketplacereviewtask

Allows the application to start the Windows Phone mall client application and display the comment page of the specified product.

Marketplacesearchtask

Allows the application to start the Windows Phone mall client application and display the search results for the specified search term.

Mediaplayerlauncher

Allows an application to start a media player.

Phonecalltask

Allow the application to start the "Mobile Phone" application. This method allows you to call your application.

Phonenumberchoosertask

Allow the application to start the "Contact" application. You can use this method to obtain the phone number of the selected contact.

Photochoosertask

Allows the application to start the "Photo selector" application. You can use this method to select a photo.

Savecontacttask

Provides methods and events for starting the Contact application and enabling the user to save the contact.

Saveemailaddresstask

Allow the application to start the "Contact" application. This method allows users to save email addresses in applications to new or existing contacts.

Savephonenumbertask

Allow the application to start the "Contact" application. This method allows users to save phone numbers in the application to new or existing contacts.

Saveringtonetask

Enable the application to start the ringtone application. Using saveringtonetask allows users to save ringtones in the application to the system ringtone list.

Searchtask

Allows applications to start the Web search application.

Sharelinktask

Allow an application to start a dialog box that allows users to share links on their selected social networks.

Sharestatustask

Allow an application to start a dialog box that allows users to share status information on the selected social network.

Smscomposetask

Start the "SMS" application through the displayed new SMS.

Webbrowsertask

Allow the application to start the web browser application.

The class names and simple families of various starters and selectors are few. I will list a few simple examples here. These are simple calls without any complicated programs, at the beginning of the WP7 design, we had decided that we could not make a big difference here. I have no need to demonstrate it all over again.

First write two selector instances

Phonecalltask

PhoneCallTask task = new PhoneCallTask();
task.PhoneNumber = "15000001245";
task.DisplayName = "dhc";
task.Show();

The running interface is as follows:


Webbrowsertask

WebBrowserTask task = new WebBrowserTask();
task.URL = "http://www.baidu.com";
task.Show();

Running result


Marketplacehubtask

MarketplaceHubTask task = new MarketplaceHubTask();
task.ContentType = MarketplaceContentType.Applications;
task.Show();

The running interface is as follows:


Example of two selectors

Phonenumberchoosertask

The following is the code used by the phonenumberchoosertask selector in combination with the smscomposetask initiator. Select a phone number, enable the text message function, and write "this text message" content by default.

PhoneNumberChooserTask contactsTask = new PhoneNumberChooserTask ();
             contactsTask.Completed + = (s, evt) =>
             {
                 if (evt.Error == null && evt.TaskResult == TaskResult.OK)
                 {
                     SmsComposeTask smsTask = new SmsComposeTask ();
                     smsTask.Body = "This is a text message.";
                     smsTask.To = evt.PhoneNumber;
                     smsTask.Show ();
                 }
             };
             contactsTask.Show ();

Run the code and select a phone number. The result is as follows:


Cameracapturetask

CameraCaptureTask task = new CameraCaptureTask();
            task.Completed += (s, evt) => { if (evt.Error == null && evt.TaskResult == TaskResult.OK)
                {
                    BitmapImage bmpImage = new BitmapImage();
                    bmpImage.SetSource(evt.ChosenPhoto);
                    image.Source = bmpImage;
                }
            };
            task.Show();

The real machine is inconvenient. The camera starters in the simulator run as follows:

 



Photochoosertask

PhotoChooserTask task = new PhotoChooserTask();;        
            task.Completed += new EventHandler<PhotoResult>(pc_Completed);
            task.Show(); void pc_Completed(object sender, PhotoResult e) 
        { if (e.TaskResult == TaskResult.OK) 
            { 
                BitmapImage bmpSource = new BitmapImage(); 
                bmpSource.SetSource(e.ChosenPhoto); 
                image.Source = bmpSource; 
            } else { 
                image.Source = null; 
            } 
        }

The running structure is as follows:




Well, let's introduce it so much. You can try it for the rest of us. It's a fake form. It's all in this form.

I didn't plan to introduce WP7 stuff so early, but I was afraid that others would say that I am a mix of people. I wrote this article in advance, and the next article will return to more important basic knowledge, don't worry for beginners. It will satisfy you. Don't worry about experienced children's shoes. You will write things you are interested in.

Related Article

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.