private void CaricaDati()
        {
            string    path           = @"Allenamenti.xml";
            XDocument xmlDoc         = XDocument.Load(path);
            XElement  xmlallenamenti = xmlDoc.Element("allenamenti");
            var       xmlallenamento = xmlallenamenti.Elements("allenamento");

            foreach (var item in xmlallenamento)
            {
                XElement    xmlTipoAllenamento   = item.Element("tipo");
                XElement    xmlDurataAllenamento = item.Element("durata");
                XElement    xmlCalorieConsumate  = item.Element("calorie");
                Allenamneto a = new Allenamneto();
                a.Tipo    = xmlTipoAllenamento.Value;
                a.Durata  = Convert.ToDouble(xmlDurataAllenamento.Value);
                a.Calorie = Convert.ToInt32(xmlCalorieConsumate.Value);
                Dispatcher.Invoke(() => Lst_allenamenti.Items.Add(a));
                Thread.Sleep(1000);

                if (fermo.IsCancellationRequested)
                {
                    break;
                }
            }
        }
示例#2
0
        private void Lst_allenamenti_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Allenamneto a = (Allenamneto)Lst_allenamenti.SelectedItem;

            if (a != null)
            {
                Lbl_Durata.Content = a.Durata.ToString();
                Txt_Tipo.Text      = a.Tipo.ToString();
            }
        }
示例#3
0
        private void Btn_aggiorna_Click_1(object sender, RoutedEventArgs e)
        {
            Allenamneto a      = (Allenamneto)Lst_allenamenti.SelectedItem;
            string      valore = Convert.ToString(Txt_Tipo.Text);

            if (a.Tipo != valore)
            {
                a.Tipo = valore;
                MessageBox.Show("Aggiornato");
            }
            Task.Factory.StartNew(scrivi);
        }