private void ApplicationBarSaveButton_Click(object sender, EventArgs e)
        {
            DateTime beginTime = (DateTime)alarmTimePicker.Value;

            if (beginTime < DateTime.Now)
            {
                beginTime = beginTime.AddDays(1);
            }
            DateTime expirationTime = beginTime.AddSeconds(1);

            RecurrenceInterval recurrence = RecurrenceInterval.None;

            Alarm alarm = new Alarm(ALARM_NAME);

            alarm.Content        = ALARM_CONTENT;
            alarm.Sound          = new Uri("/Assets/Sounds/Alarm-06.wma", UriKind.Relative);
            alarm.BeginTime      = beginTime;
            alarm.ExpirationTime = expirationTime;
            alarm.RecurrenceType = recurrence;

            if (ScheduledActionService.Find(ALARM_NAME) != null)
            {
                ScheduledActionService.Remove(ALARM_NAME);
            }
            ScheduledActionService.Add(alarm);

            updateUI();
        }
        /// <summary>
        /// Creates a new Reminder instance and adds to current medicine's Reminders list
        /// </summary>
        /// <param name="beginTime">Begin time for Reminder</param>
        /// <param name="endTime">End time for Reminder</param>
        /// <param name="interval">Frequency of Reminder</param>
        public void AddReminderToList(DateTime beginTime, DateTime endTime, RecurrenceInterval interval)
        {
            String name = System.Guid.NewGuid().ToString();

            Reminder reminder = new Reminder(name);
            reminder.Title = "Its time to take medicine";
            reminder.BeginTime = beginTime;
            reminder.ExpirationTime = endTime;
            reminder.RecurrenceType = interval;

            medicine.Reminders.Add(reminder);
            //NotifyPropertyChanged("Reminders");
        }
示例#3
0
        public static void SetSystemReminder(this TaskModel task)
        {
            if (task.HasReminder)
            {
                List <DateTime>    dates    = task.ReminderDates();
                RecurrenceInterval interval = task.Repeats.Interval();

                foreach (DateTime date in dates)
                {
                    ReminderHelper.Add(
                        ToReminderName(task.Uid, date),
                        task.Title,
                        task.Detail,
                        date,
                        new Uri(string.Format("/Views/EditTaskPage.xaml?Task={0}", task.Uid), UriKind.Relative),
                        interval);
                }
            }
        }
        public JsonResult CreateReccurenceInterval(RecurrenceIntervalModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new
                {
                    Result = "ERROR",
                    Message = "Form is not valid! " +
                              "Please correct it and try again."
                }));
            }

            if (!User.IsInRole("Officer"))
            {
                return(Json(new
                {
                    Result = "ERROR",
                    Message = "You do not have the authority to create a new interval."
                }));
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                RecurrenceInterval item = new RecurrenceInterval();
                item.Description = model.Description;
                item.Minutes     = model.Minutes;
                dm.AddToRecurrenceIntervals(item);
                dm.SaveChanges();

                model.Id = item.Id;

                return(Json(new { Result = "OK", Record = model }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
        public JsonResult DeleteRecurrenceInterval(int id)
        {
            if (!User.IsInRole("Officer"))
            {
                return(Json(new
                {
                    Result = "ERROR",
                    Message = "You do not have the authority delete this interval."
                }));
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                // Grab the item
                RecurrenceInterval item = dm.RecurrenceIntervals.Single(z => z.Id == id);

                // Delete the object only if there are no references
                if (item.Goals.Count < 1)
                {
                    dm.RecurrenceIntervals.DeleteObject(item);
                }

                // Otherwise just deactivate so we don't break any historical records
                else
                {
                    item.Active = false;
                }

                // Save the changes
                dm.SaveChanges();

                return(Json(new { Result = "OK" }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
示例#6
0
        public static void AddOrReplaceAlarm(
            string name,
            string content,
            DateTime beginTime,
            DateTime expirationTime,
            RecurrenceInterval recurrenceType,
            Uri alarmSound )
        {
            ScheduledAction action = ScheduledActionService.Find(name);

             Alarm alarm = new Alarm(name);
             alarm.Content = content;
             alarm.Sound = alarmSound;
             alarm.BeginTime = beginTime;
             alarm.ExpirationTime = expirationTime;
             alarm.RecurrenceType = recurrenceType;

             if (action == null)
                 ScheduledActionService.Add(alarm);
             else
                 ScheduledActionService.Replace(alarm);
        }
示例#7
0
        /// <summary>
        /// Alarm schedule
        /// </summary>
        /// <param name="recurrence"></param>
        /// <param name="endTime"></param>
        /// <param name="occurrences"></param>
        /// <param name="daysToRepeat"></param>
        public AlarmSchedule(RecurrenceInterval recurrence, DateTime? endTime, int occurrences, List<DayOfWeek> daysToRepeat, List<int> monthsToRepeat)
        {
            this.Repeats = recurrence;
            this.EndTime = endTime;
            this.Occurrences = occurrences;

            // Check that the days to repeat are unique and not repeating
            if (daysToRepeat.Distinct().Count() != daysToRepeat.Count)
            {
                throw new ArgumentException("Repeated days should be unique");
            }

            this.DaysToRepeat = daysToRepeat;

            // Check that the months to repeat are unique and not repeating
            if (monthsToRepeat.Distinct().Count() != monthsToRepeat.Count)
            {
                throw new ArgumentException("Repeated months should be unique");
            }

            this.MonthsToRepeat = monthsToRepeat;
        }
        public JsonResult UpdateRecurrenceInterval(RecurrenceIntervalModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new
                    {
                        Result = "ERROR",
                        Message = "Form is not valid! " +
                                  "Please correct it and try again."
                    }));
                }

                if (!User.IsInRole("Officer"))
                {
                    return(Json(new
                    {
                        Result = "ERROR",
                        Message = "You do not have the authority to update this interval."
                    }));
                }

                JourListDMContainer dm = new JourListDMContainer();

                RecurrenceInterval item = dm.RecurrenceIntervals.Single(z => z.Id == model.Id);
                item.Description = model.Description;
                item.Minutes     = model.Minutes;
                item.Active      = model.Active;
                dm.SaveChanges();

                return(Json(new { Result = "OK" }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
示例#9
0
        private static RecurrenceInterval Recurrence(string recurrenceStr)
        {
            RecurrenceInterval recurrence = RecurrenceInterval.None;

            RepeatType repeatType =
                (RepeatType)Enum.Parse(typeof(RepeatType), recurrenceStr, true);

            switch (repeatType)
            {
            case RepeatType.NotRepeated:
                recurrence = RecurrenceInterval.None;
                break;

            case RepeatType.Daily:
                recurrence = RecurrenceInterval.Daily;
                break;

            case RepeatType.Weekly:
                recurrence = RecurrenceInterval.Weekly;
                break;

            case RepeatType.Fortnightly:
                throw new NotSupportedException("Not support Fortnightly!");

            case RepeatType.Monthly:
                recurrence = RecurrenceInterval.Monthly;
                break;

            case RepeatType.Yearly:
                recurrence = RecurrenceInterval.Yearly;
                break;

            default:
                break;
            }

            return(recurrence);
        }
示例#10
0
        public static void AddOrReplaceReminder(
            string name,
            string title,
            string content,
            DateTime beginTime,
            DateTime expirationTime,
            RecurrenceInterval recurrenceType,
            Uri navigationUri)
        {
            Reminder reminder = new Reminder(name);
             reminder.Title = title;
             reminder.Content = content;
             reminder.BeginTime = beginTime;
             reminder.ExpirationTime = expirationTime;
             reminder.RecurrenceType = recurrenceType;
             reminder.NavigationUri = navigationUri;

             ScheduledAction action = ScheduledActionService.Find(name);
             if (action == null)
                 // Register the reminder with the system.
                 ScheduledActionService.Add(reminder);
              //   else
              //       ScheduledActionService.Replace(reminder);
        }
示例#11
0
        private void ApplicationBarSaveButton_Click(object sender, EventArgs e)
        {
            // The code in the following steps goes here.
            String   name      = System.Guid.NewGuid().ToString();
            DateTime date      = (DateTime)beginDatePicker.Value;
            DateTime time      = (DateTime)beginTimePicker.Value;
            DateTime beginTime = date + time.TimeOfDay;

            // Make sure that the begin time has not already passed.
            if (beginTime < DateTime.Now)
            {
                MessageBox.Show("the begin date must be in the future.");
                return;
            }

            // Get the expiration time for the notification.
            date = (DateTime)expirationDatePicker.Value;
            time = (DateTime)expirationTimePicker.Value;
            DateTime expirationTime = date + time.TimeOfDay;

            // Make sure that the expiration time is after the begin time.
            if (expirationTime < beginTime)
            {
                MessageBox.Show("expiration time must be after the begin time.");
                return;
            }

            RecurrenceInterval recurrence = RecurrenceInterval.None;

            if (dailyRadioButton.IsChecked == true)
            {
                IntervalHours = 2;
            }
            else if (weeklyRadioButton.IsChecked == true)
            {
                IntervalHours = 4;
            }
            else if (monthlyRadioButton.IsChecked == true)
            {
                IntervalHours = 6;
            }
            else if (endOfMonthRadioButton.IsChecked == true)
            {
                IntervalHours = 8;
            }
            else if (yearlyRadioButton.IsChecked == true)
            {
                IntervalHours = 10;
            }

            string param1Value = param1TextBox.Text;
            string param2Value = param2TextBox.Text;
            string queryString = "";

            if (param1Value != "" && param2Value != "")
            {
                queryString = "?param1=" + param1Value + "&param2=" + param2Value;
            }
            else if (param1Value != "" || param2Value != "")
            {
                queryString = (param1Value != null) ? "?param1=" + param1Value : "?param2=" + param2Value;
            }
            Uri navigationUri = new Uri("/Sva-Chikitsa/Alarms/LaunchPage.xaml" + queryString, UriKind.Relative);

            if ((bool)reminderRadioButton.IsChecked)
            {
                Reminder reminder = new Reminder(name);
                reminder.Title          = titleTextBox.Text;
                reminder.Content        = contentTextBox.Text;
                reminder.BeginTime      = beginTime;
                reminder.ExpirationTime = expirationTime;
                reminder.RecurrenceType = recurrence;
                reminder.NavigationUri  = navigationUri;

                // Register the reminder with the system.
                ScheduledActionService.Add(reminder);

                if (IntervalHours > 0)
                {
                    //i is started from 1 as 1 reminder added above
                    for (int i = 1; i < Frequency; i++)
                    {
                        name     = System.Guid.NewGuid().ToString();
                        reminder = new Reminder(name);
                        reminder.RecurrenceType = recurrence;
                        reminder.Title          = titleTextBox.Text;
                        reminder.Content        = contentTextBox.Text;
                        reminder.BeginTime      = beginTime.AddHours(IntervalHours * i);
                        reminder.ExpirationTime = expirationTime.AddHours(IntervalHours * i);
                        reminder.RecurrenceType = recurrence;
                        reminder.NavigationUri  = navigationUri;
                        ScheduledActionService.Add(reminder);
                    }
                }
            }
            else
            {
                Alarm alarm = new Alarm(name);
                alarm.Content        = contentTextBox.Text;
                alarm.Sound          = new Uri("/Ringtones/Ring01.wma", UriKind.Relative);
                alarm.BeginTime      = beginTime;
                alarm.ExpirationTime = expirationTime;
                alarm.RecurrenceType = recurrence;

                ScheduledActionService.Add(alarm);
            }
            if (IntervalHours > 0)
            {
                //i is started from 1 as 1 reminder added above
                for (int i = 1; i < Frequency; i++)
                {
                    Alarm alarm = new Alarm(name);
                    alarm.Content        = contentTextBox.Text;
                    alarm.Sound          = new Uri("/Ringtones/Ring01.wma", UriKind.Relative);
                    alarm.BeginTime      = beginTime;
                    alarm.ExpirationTime = expirationTime.AddHours(IntervalHours * i);
                    alarm.RecurrenceType = recurrence;
                    ScheduledActionService.Add(alarm);
                }
            }
            NavigationService.GoBack();
        }
示例#12
0
 public Reminder(string name)
 {
     this.Name = name; Title = null; Content = null; BeginTime = DateTime.MinValue; ExpirationTime = DateTime.MinValue; RecurrenceType = RecurrenceInterval.Daily; NavigationUri = null;
 }
 /// <summary>
 /// Create Reminder and schedule it
 /// </summary>
 /// <param name="reminderToDisplay"></param>
 /// <param name="date"></param>
 /// <param name="pillNames"></param>
 /// <param name="recurrenceInterval"></param>
 private void CreateReminder(string reminderToDisplay, DateTime date, string pillNames, RecurrenceInterval recurrenceInterval)
 {
         reminder = new Reminder(reminderToDisplay)
         {
             BeginTime = date,
             Title = reminderToDisplay,
             Content = pillNames,
             RecurrenceType = recurrenceInterval
         };
         ScheduledActionService.Add(reminder);
        
 }
        public bool SetReminder(DateTime beginTime, DateTime expirationTime, string name, RecurrenceInterval recurrence, string TitleText)
        {
            try
            {
                Reminder reminder = new Reminder(name);
                reminder.Title = TitleText;

                reminder.BeginTime = beginTime;
                reminder.ExpirationTime = expirationTime;
                reminder.RecurrenceType = recurrence;
                //reminder.NavigationUri = navigationUri;

                // Register the reminder with the system.
                ScheduledActionService.Add(reminder);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

            
            
        }
示例#15
0
        public static void Add(string name, string title, string content, DateTime beginTime, Uri navigationUri, RecurrenceInterval interval = RecurrenceInterval.None)
        {
            Remove(name);
            if (interval == RecurrenceInterval.None && beginTime <= DateTime.Now)
            {
                Debug.WriteLine("> Reminder Add: overdue: {0} <= {1}", beginTime, DateTime.Now);
                return;
            }

            try
            {
                const int titleMaxLength   = 63;
                const int contentMaxLength = 255;

                // Není povolena nulová délka
                if (string.IsNullOrWhiteSpace(title))
                {
                    title = AppResources.TitleUntitled;
                }

                // Maximum je 63 znaků
                if (title.Length > titleMaxLength)
                {
                    title = title.Substring(0, titleMaxLength - 3) + "...";
                }

                // Maximum je 255 znaků
                if (content.Length > contentMaxLength)
                {
                    content = content.Substring(0, contentMaxLength - 3) + "...";
                }

                ScheduledActionService.Add(new Reminder(name)
                {
                    BeginTime      = beginTime,
                    Title          = title,
                    Content        = content,
                    NavigationUri  = navigationUri,
                    RecurrenceType = interval
                });
            }
            catch (InvalidOperationException e)
            {
                Debug.WriteLine("> Add Reminder (InvalidOperationException): {0}", e.Message);
            }
            catch (SchedulerServiceException e)
            {
                Debug.WriteLine("> Add Reminder (SchedulerServiceException): {0}", e.Message);
            }
            catch (Exception e)
            {
                Debug.WriteLine("> Add Reminder (Exception): {0}", e.Message);
            }
        }
 private DateTime moveTime(DateTime time, RecurrenceInterval rec)
 {
     return moveTime(time, DateTime.Now, rec);
 }
        private DateTime moveTime(DateTime time, DateTime now, RecurrenceInterval rec)
        {
            TimeSpan add = new TimeSpan(0, 0, 0);

            if (time.Date < now.Date || time.TimeOfDay < now.TimeOfDay)
            {
                if (rec == RecurrenceInterval.Daily)
                {
                    add = new TimeSpan(1, 0, 0, 0);
                }
                else if (rec == RecurrenceInterval.Weekly)
                {
                    add = new TimeSpan(7, 0, 0, 0);
                }
            }

            return time + add;
        }
        private void addAmalToReminder(AmalItem item, RecurrenceInterval recurrence)
        {
            DateTime now = DateTime.Now.Date;

            DateTime beginTime = now + item.WaktuAmal.TimeOfDay;
            DateTime expireTime = now + item.WaktuAmal.TimeOfDay + new TimeSpan(1, 0, 0);

            String title;
            String name;

            if (item.ItemName.Length > 63)
            {
                title = item.ItemName.Substring(0, 60) + "...";
                name = item.ItemName.Substring(0, 63);
            }
            else
            {
                title = name = item.ItemName;
            }

            if (ScheduledActionService.Find(name) == null)
            {
                Reminder reminder = new Reminder(name);

                reminder.Title = title;
                reminder.Content = "Jangan lupa amalnya!";// item.ItemName;
                reminder.BeginTime = moveTime(beginTime, recurrence);
                reminder.ExpirationTime = moveTime(expireTime, reminder.BeginTime, recurrence);
                reminder.RecurrenceType = recurrence;
                reminder.NavigationUri = new Uri("/LamanAmal1.xaml?id=" + item.AmalItemId, UriKind.Relative);

                // Register the reminder with the system.
                ScheduledActionService.Add(reminder);
            }
            else
            {
                Reminder reminder = ScheduledActionService.Find(name) as Reminder;
                reminder.BeginTime = moveTime(beginTime, recurrence);
                reminder.ExpirationTime = moveTime(expireTime, reminder.BeginTime, recurrence);

                ScheduledActionService.Replace(reminder);
            }
        }
示例#19
0
        private void ApplicationBarSaveButton_Click(object sender, EventArgs e)
        {
            // Generate a unique name for the new reminder. You can choose a
            // name that is meaningful for your app, or just use a GUID.
            String name = System.Guid.NewGuid().ToString();



            // Get the begin time for the reminder by combining the DatePicker
            // value and the TimePicker value.
            DateTime date      = (DateTime)beginDatePicker.Value;
            DateTime time      = (DateTime)beginTimePicker.Value;
            DateTime beginTime = date + time.TimeOfDay;

            // Make sure that the begin time has not already passed.
            if (beginTime < DateTime.Now)
            {
                MessageBox.Show("the begin date must be in the future.");
                return;
            }

            // Get the expiration time for the reminder
            date = (DateTime)expirationDatePicker.Value;
            time = (DateTime)expirationTimePicker.Value;
            DateTime expirationTime = date + time.TimeOfDay;

            // Make sure that the expiration time is after the begin time.
            if (expirationTime < beginTime)
            {
                MessageBox.Show("expiration time must be after the begin time.");
                return;
            }

            // Determine which recurrence radio button is checked.
            RecurrenceInterval recurrence = RecurrenceInterval.None;

            if (dailyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Daily;
            }
            else if (weeklyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Weekly;
            }
            else if (monthlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Monthly;
            }
            else if (endOfMonthRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.EndOfMonth;
            }
            else if (yearlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Yearly;
            }


            // Create a Uri for the page that will be launched if the user
            // taps on the reminder. Use query string parameters to pass
            // content to the page that is launched.
            string param1Value = param1TextBox.Text;
            string param2Value = param2TextBox.Text;
            string queryString = "";

            if (param1Value != "" && param2Value != "")
            {
                queryString = "?param1=" + param1Value + "&param2=" + param2Value;
            }
            else if (param1Value != "" || param2Value != "")
            {
                queryString = (param1Value != null) ? "?param1=" + param1Value : "?param2=" + param2Value;
            }

            Uri navigationUri = new Uri("/ShowParams.xaml" + queryString, UriKind.Relative);

            Reminder reminder = new Reminder(name);

            reminder.Title          = titleTextBox.Text;
            reminder.Content        = contentTextBox.Text;
            reminder.BeginTime      = beginTime;
            reminder.ExpirationTime = expirationTime;
            reminder.RecurrenceType = recurrence;
            reminder.NavigationUri  = navigationUri;

            // Register the reminder with the system.
            ScheduledActionService.Add(reminder);

            // Navigate back to the main reminder list page.
            NavigationService.GoBack();
        }
示例#20
0
        private void ApplicationBarSaveButton_Click(object sender, EventArgs e)
        {
            // The code in the following steps goes here.

            // Generate a unique name for the new notification. You can choose a
            // name that is meaningful for your app, or just use a GUID.
            String name = System.Guid.NewGuid().ToString();

            // Get the begin time for the notification by combining the DatePicker
            // value and the TimePicker value.
            DateTime date           = (DateTime)expirationDatePicker.Value;
            DateTime time           = (DateTime)expirationTimePicker.Value;
            DateTime expirationTime = date + time.TimeOfDay;

            // Make sure that the begin time has not already passed.
            if (expirationTime < DateTime.Now)
            {
                MessageBox.Show("the desired date must be in the future.");
                return;
            }

            // Get the expiration time for the notification.
            //         date = (DateTime)expirationDatePicker.Value;
            //        time = (DateTime)expirationTimePicker.Value;
//            DateTime beginTime = date + time.TimeOfDay;

            // Make sure that the expiration time is after the begin time.

            double buffer = 0;

            if (txtBuffer.Text == "")
            {
                buffer = 0;
            }
            else
            {
                buffer = Convert.ToDouble(txtBuffer.Text);
            }

/*
 *          if (expirationTime.AddMinutes(-buffer) < DateTime.Now)
 *          {
 *              MessageBox.Show("Not enough time span.");
 *              return;
 *          } */

            // Determine which recurrence radio button is checked.
            RecurrenceInterval recurrence = RecurrenceInterval.None;

            if (dailyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Daily;
            }
            else if (weeklyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Weekly;
            }
            else if (monthlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Monthly;
            }
            else if (endOfMonthRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.EndOfMonth;
            }
            else if (yearlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Yearly;
            }

            // Create a URI for the page that will be launched if the user
            // taps on the reminder. Use query string parameters to pass
            // content to the page that is launched.

            /*         string param1Value = param1TextBox.Text;
             *       string param2Value = param2TextBox.Text;
             *       string queryString = "";
             *       if (param1Value != "" && param2Value != "")
             *       {
             *           queryString = "?param1=" + param1Value + "&param2=" + param2Value;
             *       }
             *       else if (param1Value != "" || param2Value != "")
             *       {
             *           queryString = (param1Value != null) ? "?param1=" + param1Value : "?param2=" + param2Value;
             *       }
             *       Uri navigationUri = new Uri("/ShowParams.xaml" + queryString, UriKind.Relative); */


            //See if reminderRadioButton is checked

            /*      if ((bool)reminderRadioButton.IsChecked)
             *    {
             *        Reminder reminder = new Reminder(name);
             *        reminder.Title = titleTextBox.Text;
             *        reminder.Content = contentTextBox.Text;
             *        reminder.BeginTime = beginTime;
             *        reminder.ExpirationTime = expirationTime;
             *        reminder.RecurrenceType = recurrence;
             *        reminder.NavigationUri = navigationUri;
             *
             *        // Register the reminder with the system.
             *        ScheduledActionService.Add(reminder);
             *    } */

            //if reminderRadioButton is not checked, then it's an alarm
            TimeSpan timeDiff = expirationTime.AddMinutes(buffer).Subtract(DateTime.Now);

            if (timeDiff.Milliseconds <= 0)
            {
                MessageBox.Show("Not enough time span.");
                return;
            }
            else
            {
                Alarm alarm = new Alarm(name);
//                alarm.Content = contentTextBox.Text;
                alarm.Sound          = new Uri("/Ringtones/la_cucaracha.mp3", UriKind.Relative);
                alarm.ExpirationTime = expirationTime; //THIS IS ACTUALLY THE DESIRED ARRIVAL TIME
                double traveltime = 0;
                double need       = traveltime + buffer;
                alarm.BeginTime = expirationTime.AddMinutes(-need); //THIS IS ACTUALLY THE WAKE UP TIME

                //            alarm.Title = titleTextBox.Text;
                alarm.Content = titleTextBox.Text + " " + destinationTextBox.Text;
                //               alarm.ExpirationTime = expirationTime;
                alarm.RecurrenceType = recurrence;

                ScheduledActionService.Add(alarm);
            }

            // Navigate back to the main reminder list page.
            NavigationService.GoBack();
        }
示例#21
0
 private void RegisterAlarm(AlarmModel alarmModel, string alarmID, DateTime beginTime, RecurrenceInterval recurrenceInterval = RecurrenceInterval.Weekly)
 {
     bool haveFound;
     Alarm alarm = ScheduledActionService.Find(alarmID) as Alarm;
     if (alarm == null)
     {
         haveFound = false;
         alarm = new Alarm(alarmID);
     }
     else
     {
         haveFound = true;
     }
     alarm.Content = alarmModel.Name;
     alarm.Sound = alarmModel.Sound.Uri;
     alarm.RecurrenceType = recurrenceInterval;
     if (beginTime < DateTime.Now && recurrenceInterval== RecurrenceInterval.None)
     {
         alarm.BeginTime = beginTime.Add(new TimeSpan(1, 0, 0, 0));
     }
     else
     {
         alarm.BeginTime = beginTime;
     }
     if (haveFound)
     {
         ScheduledActionService.Replace(alarm);
     }
     else
     {
         ScheduledActionService.Add(alarm);
     }
 }
示例#22
0
        public void AddReminder()
        {
            // Get the begin time for the notification by combining the DatePicker
            // value and the TimePicker value.
            DateTime date      = (DateTime)beginDatePicker.Value;
            DateTime time      = (DateTime)beginTimePicker.Value;
            DateTime beginTime = date + time.TimeOfDay;

            // Make sure that the begin time has not already passed.
            if (beginTime < DateTime.Now)
            {
                MessageBox.Show("the begin date must be in the future.");
                return;
            }

            // Get the expiration time for the notification.
            date = (DateTime)expirationDatePicker.Value;
            time = (DateTime)expirationTimePicker.Value;
            DateTime expirationTime = date + time.TimeOfDay;

            // Make sure that the expiration time is after the begin time.
            if (expirationTime < beginTime)
            {
                MessageBox.Show("expiration time must be after the begin time.");
                return;
            }


            if (dailyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Daily;
            }
            else if (weeklyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Weekly;
            }
            else if (monthlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Monthly;
            }
            else if (endOfMonthRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.EndOfMonth;
            }
            else if (yearlyRadioButton.IsChecked == true)
            {
                recurrence = RecurrenceInterval.Yearly;
            }

            Reminder reminder = new Reminder((notifications.Count <ScheduledNotification>() > 0 ? (notifications.Count <ScheduledNotification>() + 1).ToString() : "1"));

            reminder.Title          = string.Format("{0}{1}", title, (notifications.Count <ScheduledNotification>() > 0 ? (notifications.Count <ScheduledNotification>() + 1).ToString() : "1"));
            reminder.Content        = content;
            reminder.BeginTime      = beginTime;
            reminder.ExpirationTime = expirationTime;
            reminder.RecurrenceType = recurrence;

            ScheduledActionService.Add(reminder);

            MessageBox.Show("reminder added!");
            NavigationService.GoBack();
        }