示例#1
0
 private void Edit_OnClick(object sender, RoutedEventArgs e)
 {
     if (SelectedAnimal != null)
     {
         AnimalWindow window = new AnimalWindow(SelectedAnimal);
         if (window.ShowDialog().HasValue&& window.Animal != null)
         {
             int index = Animals.IndexOf(SelectedAnimal);
             Farm[index] = window.Animal;
             Farm.Animals.Sort((x, y) => DateTime.Compare(x.Birth, y.Birth));
             AnimalsListView.Items.Refresh();
         }
     }
 }
示例#2
0
        private void New_OnClick(object sender, RoutedEventArgs e)
        {
            AnimalWindow window = new AnimalWindow();

            if (window.ShowDialog().HasValue)
            {
                if (window.Animal != null)
                {
                    Farm.Animals.Add(window.Animal);
                }
            }
            Farm.Animals.Sort((x, y) => DateTime.Compare(x.Birth, y.Birth));
            AnimalsListView.Items.Refresh();
        }