コード例 #1
0
 /// <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();
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        /// Delete current AlarmRecord
        /// </summary>
        public void Dismiss()
        {
            AlarmNativeHandler.StopSound();
            AlarmNativeHandler.StopVibration();

            if (_alarmRecord != null)
            {
                AlarmModel.DeleteAlarm(_alarmRecord);
            }
        }
コード例 #4
0
        /// <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();
        }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
        /// <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;
                }
            }
        }
コード例 #7
0
 public void ResumeAlert()
 {
     AlarmNativeHandler.ResumeSound();
     _alertSoundState = SoundState.Start;
 }
コード例 #8
0
 public void PauseAlert()
 {
     AlarmNativeHandler.PauseSound();
     AlarmNativeHandler.StopVibration();
     _alertSoundState = SoundState.Pause;
 }
コード例 #9
0
 public void StartAlert()
 {
     AlarmNativeHandler.PlaySound();
     AlarmNativeHandler.StartVibration();
     _alertSoundState = SoundState.Start;
 }
コード例 #10
0
 public void StartAlert()
 {
     AlarmNativeHandler.PlaySound();
     AlarmNativeHandler.StartVibration();
 }
コード例 #11
0
 public void StartAlert()
 {
     _ = AlarmNativeHandler.PlaySound(); // caution: fire-and-forget asynchronous call
     AlarmNativeHandler.StartVibration();
     _alertSoundState = SoundState.Start;
 }