Example #1
0
        private void ZonesCollection_ItemEndEdit(System.ComponentModel.IEditableObject sender)
        {
            ZoneViewModel editedZone = sender as ZoneViewModel;
            IEnumerable <ZonesListBox> currentZones = ZonesWrapPanel.ChildrenOfType <ZonesListBox>();

            foreach (ZonesListBox zoneListBox in currentZones)
            {
                ZoneViewModel zone = zoneListBox.DataContext as ZoneViewModel;
                if (zone.Equals(editedZone))
                {
                    return;
                }
            }
            AddZoneToPanel(editedZone);
        }
Example #2
0
 private void PlantsCollectionScenario1_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         foreach (object item in e.OldItems)
         {
             string deletedPlant = item as string;
             IEnumerable <ZonesListBox> currentZones = ZonesWrapPanel.ChildrenOfType <ZonesListBox>();
             foreach (ZonesListBox zoneListBox in currentZones)
             {
                 ZoneViewModel currentZone = zoneListBox.DataContext as ZoneViewModel;
                 if (currentZone.Plants.Contains(deletedPlant))
                 {
                     currentZone.Plants.Remove(deletedPlant);
                 }
             }
         }
     }
 }
Example #3
0
        private void ZonesCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (object item in e.OldItems)
                {
                    ZoneViewModel deletedZone = item as ZoneViewModel;
                    IEnumerable <ZonesListBox> currentZones = ZonesWrapPanel.ChildrenOfType <ZonesListBox>();
                    foreach (ZonesListBox zoneListBox in currentZones)
                    {
                        ZoneViewModel currentZone = zoneListBox.DataContext as ZoneViewModel;
                        if (currentZone.Equals(deletedZone))
                        {
                            ZonesWrapPanel.Children.Remove(zoneListBox);
                        }
                    }

                    ZonesDataAccess.DeleteAllPlantsFromZone(deletedZone.Name);
                }
            }
        }