public void LoadData() { _alarm = NavigationHelper.Parameter as AlarmModel; if (_alarm != null) { RepeatDaysOfWeek = _alarm.RepeatDaysOfWeek; } }
public void DeleteAlarm(AlarmModel alarm) { if (alarm == null) return; var alarms = GetAllAlarms(); AlarmModel alarmTemp = GetAlarmByID(alarm.ID); if (alarmTemp != null) { alarms.Remove(alarm); IsolatedStorageSettings.ApplicationSettings[ALARMSKEY] = alarms; IsolatedStorageSettings.ApplicationSettings.Save(); ClearRegisterAlarm(alarm); } }
public void LoadData() { _alarm = NavigationHelper.Parameter as AlarmModel; }
public void SaveAlarm(AlarmModel alarm) { if (alarm == null) return; var alarms = GetAllAlarms(); AlarmModel alarmTemp = GetAlarmByID(alarm.ID); if (alarmTemp == null) { alarms.Add(alarm); } else { alarms[alarms.IndexOf(alarmTemp)] = alarm; } IsolatedStorageSettings.ApplicationSettings[ALARMSKEY] = alarms; IsolatedStorageSettings.ApplicationSettings.Save(); if (alarm.Enable) { RegisterAlarm(alarm); } else { ClearRegisterAlarm(alarm); } }
private void ClearRegisterAlarm(AlarmModel alarmModel) { ClearRegisterAlarm(alarmModel.ID.ToString()); ClearRegisterAlarm(alarmModel.ID.ToString() + Monday); ClearRegisterAlarm(alarmModel.ID.ToString() + Tuesday); ClearRegisterAlarm(alarmModel.ID.ToString() + Wednesday); ClearRegisterAlarm(alarmModel.ID.ToString() + Thursday); ClearRegisterAlarm(alarmModel.ID.ToString() + Friday); ClearRegisterAlarm(alarmModel.ID.ToString() + Saturday); ClearRegisterAlarm(alarmModel.ID.ToString() + Sunday); }
private void RegisterAlarm(AlarmModel alarmModel, string alarmID, DateTime beginTime, RecurrenceInterval recurrenceInterval = RecurrenceInterval.Weekly) { bool haveFound; Alarm alarm = ScheduledActionService.Find(alarmID) as Alarm; if (alarm == null) { haveFound = false; alarm = new Alarm(alarmID); } else { haveFound = true; } alarm.Content = alarmModel.Name; alarm.Sound = alarmModel.Sound.Uri; alarm.RecurrenceType = recurrenceInterval; if (beginTime < DateTime.Now && recurrenceInterval== RecurrenceInterval.None) { alarm.BeginTime = beginTime.Add(new TimeSpan(1, 0, 0, 0)); } else { alarm.BeginTime = beginTime; } if (haveFound) { ScheduledActionService.Replace(alarm); } else { ScheduledActionService.Add(alarm); } }
private void RegisterAlarm(AlarmModel alarmModel) { ClearRegisterAlarm(alarmModel); RepeatDaysOfWeek repeatDaysOfWeek = alarmModel.RepeatDaysOfWeek; if (repeatDaysOfWeek != null) { bool onlyOnce=true; if (repeatDaysOfWeek.Monday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Monday); RegisterAlarm(alarmModel, alarmModel.ID + Monday, beiginTime); } if (repeatDaysOfWeek.Tuesday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Tuesday); RegisterAlarm(alarmModel, alarmModel.ID + Tuesday, beiginTime); } if (repeatDaysOfWeek.Wednesday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Wednesday); RegisterAlarm(alarmModel, alarmModel.ID + Wednesday, beiginTime); } if (repeatDaysOfWeek.Thursday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Thursday); RegisterAlarm(alarmModel, alarmModel.ID + Thursday, beiginTime); } if (repeatDaysOfWeek.Friday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Friday); RegisterAlarm(alarmModel, alarmModel.ID + Friday, beiginTime); } if (repeatDaysOfWeek.Saturday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Saturday); RegisterAlarm(alarmModel, alarmModel.ID + Saturday, beiginTime); } if (repeatDaysOfWeek.Sunday) { onlyOnce=false; DateTime beiginTime = GetAlarmBeiginDateTime(alarmModel.WakeTime, DayOfWeek.Sunday); RegisterAlarm(alarmModel, alarmModel.ID + Sunday, beiginTime); } if(onlyOnce) RegisterAlarm(alarmModel, alarmModel.ID.ToString(), alarmModel.WakeTime, RecurrenceInterval.None); } else { RegisterAlarm(alarmModel, alarmModel.ID.ToString(), alarmModel.WakeTime, RecurrenceInterval.None); } }