Пример #1
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();
        }
Пример #2
0
 /// <summary>
 /// Determines whether ObservableAlarmList contains an alarm which is scheduled at the same time.
 /// </summary>
 /// <param name="duplicate">AlarmRecord</param>
 /// <returns> true if a same alarm is found in the list; otherwise, false.</returns>
 public static bool CheckAlarmExist(ref AlarmRecord duplicate)
 {
     foreach (AlarmRecord item in AlarmModel.ObservableAlarmList)
     {
         // Check scheduled time and alarm name
         if (item.ScheduledDateTime.Equals(AlarmModel.BindableAlarmRecord.ScheduledDateTime))
         {
             // a same alarm is found.
             duplicate.DeepCopy(item);
             return(true);
         }
     }
     // there's no same alarm.
     duplicate = null;
     return(false);
 }
Пример #3
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;
                }
            }
        }