internal SensorViewModel GetSensorByName(string name)
 {
     if (!_sensorViewModelDict.TryGetValue(name, out SensorViewModel sensorViewModel))
     {
         appLog.Warn(GetType().ToString(),
                     string.Format("Sensor {0} not found. Add temporarily to site.", name));
         Sensor sensor = new Sensor()
         {
             Name  = name,
             LocX  = 0.0,
             LocY  = 0.0,
             SizeX = 0.003,
             SizeY = 0.001,
             Types = new List <string>()
         };
         sensor.Types.Add(SensorType.GuessSensorTypeFromName(name).Name);
         sensorViewModel = new SensorViewModel(sensor);
         _sensorViewModelDict.Add(name, sensorViewModel);
     }
     if (!_activeSensors.Contains(sensorViewModel))
     {
         _activeSensors.Add(sensorViewModel);
     }
     return(sensorViewModel);
 }
示例#2
0
 public void RemoveSensor(SensorViewModel sensorViewModel)
 {
     if (SensorSelected == sensorViewModel)
     {
         SensorSelected = null;
     }
     This.Sensors.Remove(sensorViewModel);
     SensorList.Remove(sensorViewModel);
     IsSiteChanged = true;
 }
示例#3
0
 private bool FilterSensorByCategory(SensorViewModel x)
 {
     if (SensorCategorySelected != null)
     {
         return(x.SensorCategories.Contains(SensorCategorySelected.Name));
     }
     else
     {
         return(true);
     }
 }
 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;
 }