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 WPSaveEmailAddressTask
{
    public partial class MainPage : PhoneApplicationPage
    {
        Microsoft.Phone.Tasks.SaveEmailAddressTask g_mySaveEmailTask = new Microsoft.Phone.Tasks.SaveEmailAddressTask();
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            g_mySaveEmailTask.Completed += new EventHandler<Microsoft.Phone.Tasks.TaskEventArgs>(g_mySaveEmailTask_Completed);
        }

        void g_mySaveEmailTask_Completed(object sender, Microsoft.Phone.Tasks.TaskEventArgs e)
        {
            if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK)
                MessageBox.Show("Emailadresse 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_mySaveEmailTask.Email = "user@domain.topleveldomain";
            g_mySaveEmailTask.Show();
        }
    }
}
