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;
using Microsoft.Phone.Tasks;

namespace WPTombstone2
{
    public partial class Page2 : PhoneApplicationPage
    {
        public Page2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBlock1.Text = textBox1.Text;
        }

        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            this.State.Add("textBlock1.Text", textBlock1.Text);
            this.State.Add("textBox1.Text", textBox1.Text);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (!(App.Current as WPTombstone2.App).IsReactivated)
            {
                if (this.State.ContainsKey("textBlock1.Text"))
                {
                    textBlock1.Text = (string)this.State["textBlock1.Text"];
                    this.State.Remove("textBlock1.Text");
                }
                if (this.State.ContainsKey("textBox1.Text"))
                {
                    textBox1.Text = (string)this.State["textBox1.Text"];
                    this.State.Remove("textBox1.Text");
                }
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            CameraCaptureTask cct = new CameraCaptureTask();
            cct.Show();
        }
    }
}