Пример #1
0
 internal ResidentViewModel GetResidentByName(string name, bool AddIfNotFound = false)
 {
     if (name == "")
     {
         return(ResidentViewModel.NullResident);
     }
     if (!_residentViewModelDict.TryGetValue(name, out ResidentViewModel residentViewModel))
     {
         if (AddIfNotFound)
         {
             appLog.Warn(GetType().ToString(),
                         string.Format("Resident {0} not found. Add temporarily to dataset.", name));
             residentViewModel = new ResidentViewModel(new Resident()
             {
                 Name  = name,
                 Color = Colors.Gray.ToString()
             });
             _residentViewModelDict.Add(name, residentViewModel);
         }
         else
         {
             appLog.Warn(GetType().ToString(),
                         string.Format("Resident {0} not found. Return Null Resident.", name));
             residentViewModel = ResidentViewModel.NullResident;
         }
     }
     return(residentViewModel);
 }
Пример #2
0
 public void RemoveResident(ResidentViewModel residentViewModel)
 {
     foreach (ResidentViewModel resident in _residentCollection)
     {
         if (resident.id > residentViewModel.id)
         {
             resident.id -= 1;
         }
     }
     _residentCollection.Remove(residentViewModel);
     _Dataset.RemoveResident(residentViewModel.resident);
 }
Пример #3
0
 public DatasetEventsViewModel(Dataset dataset)
 {
     Dataset             = dataset;
     EventViewFilter     = new EventViewFilter();
     EventsInView        = new AdvancedCollectionView(_allEventsInView);
     EventsInView.Filter = x => !FilterEvent((SensorEventViewModel)x);
     // Populate Sensor, Resident and Activity Lookup Dictionary
     foreach (Sensor sensor in dataset.Site.Sensors)
     {
         SensorViewModel sensorViewModel = new SensorViewModel(sensor);
         _sensorViewModelDict.Add(sensor.Name, sensorViewModel);
         if (sensorViewModel.SensorCategories.Intersect(activeSensorCategories).Count() > 0)
         {
             _activeSensors.Add(sensorViewModel);
         }
     }
     foreach (Activity activity in dataset.Activities)
     {
         ActivityViewModel activityViewModel = new ActivityViewModel(activity);
         _activityViewModelDict.Add(activity.Name, activityViewModel);
         Activities.Add(activityViewModel);
     }
     Activities.Sort(delegate(ActivityViewModel x, ActivityViewModel y)
     {
         return(x.Name.CompareTo(y.Name));
     });
     foreach (Resident resident in dataset.Residents)
     {
         ResidentViewModel residentViewModel = new ResidentViewModel(resident);
         _residentViewModelDict.Add(resident.Name, residentViewModel);
         Residents.Add(residentViewModel);
     }
     Residents.Sort(delegate(ResidentViewModel x, ResidentViewModel y)
     {
         return(x.Name.CompareTo(y.Name));
     });
     dispatcher = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().CoreWindow.Dispatcher;
 }
Пример #4
0
 internal async Task AddNewResidentAsync(ResidentViewModel residentViewModel)
 {
     ResidentCollectionView.Add(residentViewModel);
     This.Residents.Add(residentViewModel);
     await This.WriteMetadataToFolderAsync();
 }
Пример #5
0
 public void AddResident(ResidentViewModel residentViewModel)
 {
     _residentCollection.Add(residentViewModel);
     _Dataset.AddResident(residentViewModel.resident);
 }