Exemple #1
0
        private void lst_Attori_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Attore a = (Attore)lst_Attori.SelectedItem;

            if (a != null)
            {
                lbl_Attore.Content  = a.ToString();
                txt_Oscar.Text      = a.Oscar.ToString();
                txt_Nomination.Text = a.Nomination.ToString();
            }
        }
Exemple #2
0
        private void CaricaDati()
        {
            string    path      = @"Oscar.xml";
            XDocument xmlDoc    = XDocument.Load(path);
            XElement  xmlattori = xmlDoc.Element("attori");
            var       xmlattore = xmlattori.Elements("attore");

            Thread.Sleep(1000);

            foreach (var item in xmlattore)
            {
                XElement xmlFirstName  = item.Element("nome");
                XElement xmlLastName   = item.Element("cognome");
                XElement xmlNascita    = item.Element("data");
                XElement xmlOscar      = item.Element("oscar");
                XElement xmlNomination = item.Element("nomination");

                Attore a = new Attore();
                {
                    a.Nome        = xmlFirstName.Value;
                    a.Cognome     = xmlLastName.Value;
                    a.DataNascita = Convert.ToDateTime(xmlNascita.Value);
                    a.Oscar       = Convert.ToInt32(xmlOscar.Value);
                    a.Nomination  = Convert.ToInt32(xmlNomination.Value);
                }

                Dispatcher.Invoke(() => lst_Attori.Items.Add(a));

                if (ct.Token.IsCancellationRequested)
                {
                    break;
                }

                Thread.Sleep(1000);
            }

            Dispatcher.Invoke(() =>
            {
                btn_Aggiorna.IsEnabled = true;
                btn_Stop.IsEnabled     = false;
                ct = null;
            });
        }
Exemple #3
0
        private void btn_Salva_Click(object sender, RoutedEventArgs e)
        {
            Attore a                  = (Attore)lst_Attori.SelectedItem;
            int    OscarCambiati      = Convert.ToInt32(txt_Oscar.Text);
            int    NominationCambiate = Convert.ToInt32(txt_Nomination.Text);

            if (a.Oscar != OscarCambiati)
            {
                a.Oscar = OscarCambiati;
            }

            if (a.Nomination != NominationCambiate)
            {
                a.Nomination = NominationCambiate;
            }

            Task.Factory.StartNew(Scrivi);

            //string path = @"Oscar.xml";
            //XDocument xmlDoc = XDocument.Load(path);
            //XElement xmlattori = xmlDoc.Element("attori");
            //var xmlattore = xmlattori.Elements("attore");

            //foreach (var item in xmlattore)
            //{
            //    XElement xmlFirstName = item.Element("nome");
            //    XElement xmlLastName = item.Element("cognome");
            //    XElement xmlNascita = item.Element("data");
            //    XElement xmlOscar = item.Element("oscar");
            //    XElement xmlNomination = item.Element("nomination");

            //    if(xmlFirstName.ToString() == a.Nome && xmlLastName.ToString() == a.Cognome)
            //    {
            //        item.SetElementValue("oscar", OscarCambiati);

            //        item.SetElementValue("nomination", NominationCambiate);
            //    }

            //}
            //xmlDoc.Save(@"Oscar.xml");
        }