public DatasetEventFilterDialogViewModel(EventViewFilter filter, List <ResidentViewModel> residents, List <ActivityViewModel> activities)
        {
            _filter = filter;
            List <string> sensorStatusStrings = new List <string> {
                "ON", "OFF", "PRESENT", "ABSENT", "OPEN", "CLOSE"
            };

            foreach (string sensorStatus in sensorStatusStrings)
            {
                SensorStatusFilter.Add(new SensorStatusFilterViewModel {
                    SensorStatus = sensorStatus, IsHidden = filter.SensorStatus.Contains(sensorStatus)
                });
                if (filter.SensorStatus.Contains(sensorStatus))
                {
                    IsSensorStatusFilterEnabled = true;
                }
            }
            // Populate sensor type filter
            foreach (SensorCategory sensorCategory in SensorType.SensorCategoryCollection)
            {
                SensorCategoryFilter.Add(new SensorCategoryFilterViewModel {
                    SensorCategory = sensorCategory, IsHidden = filter.SensorCategories.Contains(sensorCategory.Name)
                });
                if (filter.SensorCategories.Contains(sensorCategory.Name))
                {
                    IsSensorCategoryFilterEnabled = true;
                }
            }
            // Populate activity filter
            foreach (ActivityViewModel activity in activities)
            {
                ActivityFilter.Add(new ActivityFilterViewModel {
                    Activity = activity, IsHidden = filter.Activities.Contains(activity.Name)
                });
                if (filter.Activities.Contains(activity.Name))
                {
                    IsActivityFilterEnabled = true;
                }
            }
            // Populate resident filter
            foreach (ResidentViewModel resident in residents)
            {
                ResidentFilter.Add(new ResidentFilterViewModel {
                    Resident = resident, IsHidden = filter.Residents.Contains(resident.Name)
                });
                if (filter.Residents.Contains(resident.Name))
                {
                    IsResidentFilterEnabled = true;
                }
            }
            // For events without activity tag or resident tag
            IsNullActivityVisible   = !filter.HideEventsWithoutActivity;
            IsNullResidentVisible   = !filter.HideEventsWithoutResident;
            IsActivityFilterEnabled = IsActivityFilterEnabled || filter.HideEventsWithoutActivity;
            IsResidentFilterEnabled = IsResidentFilterEnabled || filter.HideEventsWithoutResident;
        }
 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;
 }