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 PhoneApp3
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("You clicked on this button");
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            // F = C * 9 / 5 + 32
            if (celTextBox.Text != "")
            {
                double cel = double.Parse(celTextBox.Text);
                double fah = cel * 9 / 5 + 32;
                fahTextBox.Text = fah.ToString();

                // using web service to retrieve the result -- only use this when your cloud service is running
                //var client = new WebClient();
                //client.DownloadStringCompleted += (_, args) => fahTextBox.Text = args.Result;
                //client.DownloadStringAsync(new Uri("http://127.0.0.1:81/home/CeltoFah/" + celTextBox.Text));
            }
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on Minus Button");
        }

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on Plus Button");
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/MapPage.xaml", UriKind.Relative));
        }

        private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on Menu Item 1");
        }

        private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on Menu Item 2");
        }
    }
}