using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace WPSavePhoneNumberTask
{
    public partial class MainPage : PhoneApplicationPage
    {
        Microsoft.Phone.Tasks.SavePhoneNumberTask g_mySavePhoneNumberTask = new Microsoft.Phone.Tasks.SavePhoneNumberTask();
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            g_mySavePhoneNumberTask.Completed += new EventHandler<Microsoft.Phone.Tasks.TaskEventArgs>(g_mySavePhoneNumberTask_Completed);
        }

        void g_mySavePhoneNumberTask_Completed(object sender, Microsoft.Phone.Tasks.TaskEventArgs e)
        {
            if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK)
                MessageBox.Show("Nummer gespeichert!");
            else if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.Cancel)
                MessageBox.Show("Benutzerabbruch");
            else
                MessageBox.Show("Fehler: " + e.Error.Message);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            g_mySavePhoneNumberTask.PhoneNumber = "1234";
            g_mySavePhoneNumberTask.Show();
        }
    }
}
