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;

namespace MujAdresar
{
    public partial class Page : UserControl
    {
        private Adresar mujAdresar;
        
        public Page()
        {
            InitializeComponent();
            //inisializace adresare
            mujAdresar = new Adresar();
            //prirazeni zdroje pro Data Binding
            LayoutRoot.DataContext = mujAdresar;
        }

        //pridani kontaktu a vymazani formulare uzivateli
        private void tlacitko_uloz_Click(object sender, RoutedEventArgs e)
        {
            mujAdresar.PridejKontakt(
                textbox_jmeno.Text,
                textbox_prijmeni.Text,
                textbox_email.Text,
                textbox_prezdivka.Text,
                textbox_adresa.Text,
                checkbox_studuje.IsChecked.Value,
                checkbox_pracuje.IsChecked.Value,
                checkbox_plave.IsChecked.Value,
                datepicker_narozeniny.SelectedDate.Value);

            //vymazani formularu
            textbox_jmeno.Text = textbox_prijmeni.Text = textbox_email.Text =
                textbox_prezdivka.Text = textbox_adresa.Text = "";

            checkbox_studuje.IsChecked = checkbox_pracuje.IsChecked =
                checkbox_plave.IsChecked = false;

            datepicker_narozeniny.SelectedDate = null;

        }

        //smaz kontakt
        private void tlacitko_smazat_Click(object sender, RoutedEventArgs e)
        {
            mujAdresar.SmazKontakt(MujDataGrid.SelectedIndex);
        }
    }
}
