/// <summary> /// Ractivate AlarmRecord /// </summary> /// <param name="record">AlarmRecord for reactivating</param> public static void ReactivatelAlarm(AlarmRecord record) { //1. register native alarm int NativeAlarmID = AlarmNativeHandler.CreateAlarm(record); //2. Update NativeAlarmID and AlarmState string UID = record.GetUniqueIdentifier(); }
/// <summary> /// Cancel native alarm /// and then deactivate AlarmRecord from AlarmRecordDictionary /// </summary> /// <param name="record">AlarmRecord</param> public static void DeactivatelAlarm(AlarmRecord record) { //1. cancel native alarm AlarmNativeHandler.DeleteAlarm(record); //2. Make AlarmRecord's AlarmState string UID = record.GetUniqueIdentifier(); UpdateDictionaryAndList(UID, 0, false); }
/// <summary> /// Delete current AlarmRecord /// </summary> public void Dismiss() { AlarmNativeHandler.StopSound(); AlarmNativeHandler.StopVibration(); if (_alarmRecord != null) { AlarmModel.DeleteAlarm(_alarmRecord); } }
/// <summary> /// Create native alarm /// </summary> public static void CreateAlarm() { // create a native alarm using AlarmModel.BindableAlarmRecord // After then, update Native alarm ID. BindableAlarmRecord.NativeAlarmID = AlarmNativeHandler.CreateAlarm(BindableAlarmRecord); AlarmRecord record = new AlarmRecord(); record.DeepCopy(BindableAlarmRecord); ObservableAlarmList.Add(record); AlarmRecordDictionary.Add(record.GetUniqueIdentifier(), record); SaveDictionary(); }
/// <summary> /// Cancel native alarm /// and then remove AlarmRecord from ObservableAlarmList and AlarmRecordDictionary /// </summary> /// <param name="alarm">AlarmRecord</param> public static void DeleteAlarm(AlarmRecord alarm) { Console.WriteLine("DeleteAlarm:" + alarm.ToString()); // Cancel the native alarm AlarmNativeHandler.DeleteAlarm(alarm); string UID = alarm.GetUniqueIdentifier(); // Delete alarm from dictionary AlarmModel.AlarmRecordDictionary.Remove(UID); // Delete alarm from List for (int i = AlarmModel.ObservableAlarmList.Count - 1; i >= 0; i--) { if (AlarmModel.ObservableAlarmList[i].GetUniqueIdentifier() == UID) { ObservableAlarmList.RemoveAt(i); break; } } AlarmModel.SaveDictionary(); }
/// <summary> /// Update alarm record /// </summary> /// <param name="record">AlarmRecord</param> public static void UpdateAlarm(AlarmRecord record) { var obj = record; // Update native alarm AlarmNativeHandler.UpdateAlarm(ref obj); record = obj; string alarmUID = record.GetUniqueIdentifier(); // Update list for (int i = 0; i < ObservableAlarmList.Count; i++) { AlarmRecord item = ObservableAlarmList[i]; if (item.GetUniqueIdentifier() == alarmUID) { Console.WriteLine("Found AlarmRecord(UID: " + item.GetUniqueIdentifier() + ") in ObservableAlarmList."); AlarmRecordDictionary.Remove(alarmUID); item.DeepCopy(record); AlarmRecordDictionary.Add(alarmUID, item); SaveDictionary(); break; } } }
public void ResumeAlert() { AlarmNativeHandler.ResumeSound(); _alertSoundState = SoundState.Start; }
public void PauseAlert() { AlarmNativeHandler.PauseSound(); AlarmNativeHandler.StopVibration(); _alertSoundState = SoundState.Pause; }
public void StartAlert() { AlarmNativeHandler.PlaySound(); AlarmNativeHandler.StartVibration(); _alertSoundState = SoundState.Start; }
public void StartAlert() { AlarmNativeHandler.PlaySound(); AlarmNativeHandler.StartVibration(); }
public void StartAlert() { _ = AlarmNativeHandler.PlaySound(); // caution: fire-and-forget asynchronous call AlarmNativeHandler.StartVibration(); _alertSoundState = SoundState.Start; }