示例#1
0
 private static Interop.Alarm.DateTime ConvertDateTimeToStruct(DateTime value)
 {
     Interop.Alarm.DateTime time = new Interop.Alarm.DateTime();
     time.sec   = value.Second;
     time.min   = value.Minute;
     time.hour  = value.Hour;
     time.mday  = value.Day;
     time.mon   = value.Month - 1;
     time.year  = value.Year - 1900;
     time.wday  = (int)value.DayOfWeek;
     time.yday  = value.DayOfYear;
     time.isdst = 0;
     return(time);
 }
示例#2
0
        /// <summary>
        /// Sets an alarm to be triggered periodically, starting at a specific time.
        /// The date describes the time of the first occurrence.
        /// The weekFlag is the repeat value of the days of the week.
        /// If the weekFlag is AlarmWeekFlag.Tuesday, the alarm will repeat every Tuesday at a specific time.
        /// </summary>
        /// <remarks>This operation is permitted with UI application appcontrol only.</remarks>
        /// <param name="value"> The first active alarm time. </param>
        /// <param name="weekFlag"> The day of the week, AlarmWeekFlag may be a combination of days, like AlarmWeekFlag.Sunday | AlarmWeekFlag.Monday.</param>
        /// <param name="appControl"> The destination AppControl to perform specific work when the alarm is triggered. </param>
        /// <returns> An alarm instance is created with the set param values.</returns>
        /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
        /// <since_tizen> 3 </since_tizen>
        public static Alarm CreateAlarm(DateTime value, AlarmWeekFlag weekFlag, AppControl appControl)
        {
            Alarm alarm = null;
            int   alarmId;

            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
            AlarmError             ret  = (AlarmError)Interop.Alarm.CreateAlarmRecurWeek(appControl.SafeAppControlHandle, ref time, (int)weekFlag, out alarmId);

            alarm = new Alarm(alarmId);
            if (ret != AlarmError.None)
            {
                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
            }

            return(alarm);
        }
示例#3
0
        /// <summary>
        /// Sets a notification alarm to be triggered periodically, starting at a specific time.
        /// The date describes the time of the first occurrence.
        /// The weekFlag is the repeat value of the days of the week.
        /// If the weekFlag is AlarmWeekFlag.Tuesday, the alarm will repeat every Tuesday at a specific time.
        /// </summary>
        /// <param name="dateTime"> The first active alarm time. </param>
        /// <param name="weekFlag"> The day of the week, AlarmWeekFlag may be a combination of days,
        ///                         like AlarmWeekFlag.Sunday | AlarmWeekFlag.Monday.</param>
        /// <param name="notification"> The notification to be posted when the alarm is triggered. </param>
        /// <returns> An alarm instance is created with the set param values.</returns>
        /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
        /// <privilege>http://tizen.org/privilege/notification</privilege>
        /// <since_tizen> 3 </since_tizen>
        public static Alarm CreateAlarm(DateTime dateTime, AlarmWeekFlag weekFlag, Notification notification)
        {
            Alarm alarm = null;
            int   alarmId;
            NotificationSafeHandle safeHandle = NotificationManager.MakeNotificationSafeHandle(notification);

            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(dateTime);
            AlarmError             ret  = Interop.Alarm.CreateAlarmNotiRecurWeek(safeHandle, ref time, (int)weekFlag, out alarmId);

            if (ret != AlarmError.None)
            {
                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
            }

            alarm = new Alarm(alarmId);

            return(alarm);
        }
示例#4
0
        /// <summary>
        /// Sets an alarm to be triggered at a specific time.
        /// The date describes the time of the first occurrence.
        /// </summary>
        /// <param name="value"> The first active alarm time. </param>
        /// <param name="appControl"> The destination AppControl to perform specific work when the alarm is triggered. </param>
        /// <returns> An alarm instance is created with the set param values.</returns>
        /// <remarks>This operation is permitted with the UI application appcontrol only.</remarks>
        /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
        /// <since_tizen> 3 </since_tizen>
        public static Alarm CreateAlarm(DateTime value, AppControl appControl)
        {
            if (appControl == null)
            {
                throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
            }

            Alarm alarm = null;
            int   alarmId;

            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
            AlarmError             ret  = (AlarmError)Interop.Alarm.CreateAlarmOnceAtDate(appControl.SafeAppControlHandle, ref time, out alarmId);

            alarm = new Alarm(alarmId);
            if (ret != AlarmError.None)
            {
                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
            }

            return(alarm);
        }
示例#5
0
        internal static DateTime ConvertIntPtrToDateTime(Interop.Alarm.DateTime time)
        {
            DateTime value = new DateTime(1900 + time.year, 1 + time.mon, time.mday, time.hour, time.min, time.sec, DateTimeKind.Utc);

            return(value);
        }