using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace MujAdresar
{
    public class Adresar : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        //kontruktor
        public Adresar()
        {
            kontakty = new ObservableCollection<Kontakt>();
        }
        
        //nas seznam kontaktu
        private ObservableCollection<Kontakt> kontakty;
        public ObservableCollection<Kontakt> Kontakty
        {
            get { return kontakty; }
            set { kontakty = value; NotifyPropertyChanged("kontakty"); }
        }

        //Odposlouchavac (listener)
        private void NotifyPropertyChanged(string promertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(promertyName));
            }
        }

        //pridani nove kontaktu do adresare
        public void PridejKontakt(
            string nove_jmeno,
            string nove_prijmeni,
            string novy_email,
            string nova_prezdivka,
            string nova_adresa,
            bool cinnost_studuje,
            bool cinnost_pracuje,
            bool cinnost_plave,
            DateTime nove_narozeni)
        {
            Kontakt novy_kontakt = new Kontakt(
                nove_jmeno,
                nove_prijmeni,
                novy_email,
                nova_prezdivka,
                nova_adresa,
                cinnost_studuje,
                cinnost_pracuje,
                cinnost_plave,
                nove_narozeni);

            kontakty.Add(novy_kontakt);
        }

        //vymazani kontaktu ze seznamu
        public void SmazKontakt(int poradiKontaktu)
        {
            kontakty.RemoveAt(poradiKontaktu);
        }
    }
}
