void AlarmSnooze_Click(object sender, EventArgs e) { AlarmMngr.StopAlarm(this); AlarmMngr.SnoozeMode = true; setSnooze(); Finish(); }
void AlarmOff_Click(object sender, EventArgs e) { AlarmMngr.StopAlarm(this); AlarmMngr.SnoozeMode = false; ActionMngr.StopPlayer(); setNewAlarm(); Finish(); return; }
private void setSnooze() { bool[] days = new bool[7]; for (int i = 0; i < 7; i++) { days [i] = true; } ActionMngr.StopPlayer(); AlarmMngr.StartAlarm(new Alarm(DateTime.Now.AddMinutes(alarm.SnoozeTime).TimeOfDay, true) { Days = days, ActionID = alarm.ActionID }, this); }
public void UpdateAlarmManager() { Alarm newAlarm = alarmService.GetNextEnabledAlarm(); if (newAlarm != null && (pendingAlarm == null || !newAlarm.Equals(pendingAlarm)) && !AlarmMngr.SnoozeMode) { if (pendingAlarm != null) { AlarmMngr.StopAlarm(this); } pendingAlarm = newAlarm; AlarmMngr.StartAlarm(newAlarm, this); } else if (newAlarm == null && pendingAlarm != null) { AlarmMngr.StopAlarm(this); pendingAlarm = null; } Console.WriteLine("AlarmManager updated..."); }
public override void OnReceive(Context context, Intent intent) { try { data = context.GetSharedPreferences("project_alarm", FileCreationMode.Private); if (data != null) { ICollection <string> alarmStrings = data.GetStringSet("alarms", null); alarmService = new AlarmService(); if (alarmStrings != null) { foreach (string a in alarmStrings) { alarmService.Alarms.Add(AlarmFactory.StringToAlarm(a)); } alarmService.Alarms.Sort(); AlarmMngr.StartAlarm(alarmService.GetNextEnabledAlarm(), context); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void setNewAlarm() { try { ISharedPreferences data = GetSharedPreferences("project_alarm", FileCreationMode.Private); if (data != null) { ICollection <string> alarmStrings = data.GetStringSet("alarms", null); AlarmService alarmService = new AlarmService(); if (alarmStrings != null) { foreach (string a in alarmStrings) { string timeString = Regex.Match(a, @"Time=([^(,|\])]*)").Groups [1].Value; string enabledString = Regex.Match(a, @"Enabled=([^(,|\])]*)").Groups [1].Value; char[] daysCharArray = (Regex.Match(a, @"Days=([^(,|\])]*)").Groups [1].Value).ToCharArray(); Console.WriteLine("alarms: " + a + "regexstring: " + timeString + ", " + enabledString.ToLower()); bool[] days = new bool[7]; for (int i = 0; i < 7; i++) { if (daysCharArray[i].Equals('1')) { days [i] = true; } } alarmService.Alarms.Add(new Alarm(TimeSpan.Parse(timeString), Convert.ToBoolean(enabledString)) { Days = days }); } alarmService.Alarms.Sort(); AlarmMngr.StartAlarm(alarmService.GetNextEnabledAlarm(), this); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }