Пример #1
0
		public void Update(List<Alarm> alarms)
		{
			foreach (var alarmGroup in AlarmGroups)
			{
				var alarmViewModels = new List<AlarmViewModel>();
				foreach (var alarm in alarms)
				{
					if (alarm.AlarmType == alarmGroup.AlarmType)
					{
						var alarmViewModel = new AlarmViewModel(alarm);
						alarmViewModels.Add(alarmViewModel);
					}
				}

				alarmGroup.Alarms = alarmViewModels;
				alarmGroup.Update();
			}
			OnPropertyChanged(() => CanReset);
			OnPropertyChanged(() => Count);
		}
Пример #2
0
		void UpdateAlarms()
		{
			Alarm oldAlarm = null;
			if (SelectedAlarm != null)
			{
				oldAlarm = SelectedAlarm.Alarm.Clone();
			}
			Alarms.Clear();
			foreach (var alarm in alarms)
			{
				if (!sortingAlarmType.HasValue || sortingAlarmType.Value == alarm.AlarmType)
				{
					var alarmViewModel = new AlarmViewModel(alarm);
					Alarms.Add(alarmViewModel);
				}
			}
			if (oldAlarm != null)
			{
				SelectedAlarm = Alarms.FirstOrDefault(x => x.Alarm.IsEqualTo(oldAlarm));
			}
		}
Пример #3
0
		void RefreshAlarms(IEnumerable<Alarm> alarms)
		{
			int counter = 0;
			foreach (var alarm in alarms)
			{
				var alarmViewModel = Alarms.FirstOrDefault(x => x.Alarm.IsEqualTo(alarm));
				if (alarmViewModel == null)
				{
					var newAlarmViewModel = new AlarmViewModel(alarm);
					Alarms.Insert(counter, newAlarmViewModel);
				}
				else
				{
					alarmViewModel.OnPropertyChanged(() => alarmViewModel.ObjectStateClass);
				}
				counter++;
			}
			for (int i = 0; i < Alarms.Count; i++)
			{
				var alarm = alarms.FirstOrDefault(x => x.IsEqualTo(Alarms[i].Alarm));
				if (alarm == null)
				{
					Alarms.RemoveAt(i);
					i--;
				}
			}
		}
Пример #4
0
		void UpdateAlarms()
		{
			Alarm oldAlarm = null;
			if (SelectedAlarm != null)
			{
				oldAlarm = SelectedAlarm.Alarm.Clone();
			}

			if (sortingAlarmType.HasValue)
			{
				RefreshAlarms(alarms.Where(x => x.AlarmType == sortingAlarmType.Value));
			}
			else
			{
				RefreshAlarms(alarms);
			}

			if (oldAlarm != null)
			{
				SelectedAlarm = Alarms.FirstOrDefault(x => x.Alarm.IsEqualTo(oldAlarm));
			}
		}