public static void SetRemider(RecipeDataItem item)
            {
                if (!IsScheduled(item.UniqueId))
                {
                    //TODO-EX-4
                    Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId);
                    reminder.Title = item.Title;
                    reminder.Content = "Did you finished?";
                    if (System.Diagnostics.Debugger.IsAttached)
                        reminder.BeginTime = DateTime.Now.AddMinutes(1);
                    else
                        reminder.BeginTime = DateTime.Now.Add(TimeSpan.FromMinutes(Convert.ToDouble(item.PrepTime)));
                    reminder.ExpirationTime = reminder.BeginTime.AddMinutes(5);
                    reminder.RecurrenceType = RecurrenceInterval.None;
                    reminder.NavigationUri = new Uri("/RecipeDetailPage.xaml?ID=" + item.UniqueId + "&GID=" + item.Group.UniqueId, UriKind.Relative);
                    ScheduledActionService.Add(reminder);

                    //TODO-EX-5
                }
                else
                {
                    var schedule = ScheduledActionService.Find(item.UniqueId);
                    ScheduledActionService.Remove(schedule.Name);

                    //TODO-EX-6
                }
            }
Exemplo n.º 2
0
 public static void SetReminder(RecipeDataItem item)
 {
     if (!IsScheduled(item.UniqueId))
     {
         Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId);
         reminder.Title   = item.Title;
         reminder.Content = "Have you finished cooking?";
         if (System.Diagnostics.Debugger.IsAttached)
         {
             reminder.BeginTime = DateTime.Now.AddMinutes(1);
         }
         else
         {
             reminder.BeginTime = DateTime.Now.Add(TimeSpan.FromMinutes(Convert.ToDouble(item.PrepTime)));
         }
         reminder.ExpirationTime = reminder.BeginTime.AddMinutes(5);
         reminder.RecurrenceType = RecurrenceInterval.None;
         reminder.NavigationUri  = new Uri("/RecipeDetailPage.xaml?ID=" + item.UniqueId + "&GID=" + item.Group.UniqueId, UriKind.Relative);
         ScheduledActionService.Add(reminder);
     }
     else
     {
         var schedule = ScheduledActionService.Find(item.UniqueId);
         ScheduledActionService.Remove(schedule.Name);
     }
 }
        private void AddReminderButton_Click(object sender, RoutedEventArgs e)
        {
            var reminderDtTm = new DateTime(dpReminderDate.Value.Value.Year, dpReminderDate.Value.Value.Month, dpReminderDate.Value.Value.Day,
                                            tpReminderTime.Value.Value.Hour, tpReminderTime.Value.Value.Minute, tpReminderTime.Value.Value.Second);

            if (DateTime.Now > reminderDtTm)
            {
                App.ToastMe(StringResources.RVPage_Reminders_Messages_ReminderPastNow);
                return;
            }

            var s = string.Format(StringResources.RVPage_Reminders_ReminderTitle, App.ViewModel.ReturnVisitData.FullName);


            var r = new Microsoft.Phone.Scheduler.Reminder(Guid.NewGuid().ToString())
            {
                Content       = tbReminderNotes.Text,
                BeginTime     = reminderDtTm,
                Title         = s,
                NavigationUri = NavigationService.CurrentSource
            };

            ScheduledActionService.Add(r);
            tbReminderNotes.Text = "";
            App.ToastMe(StringResources.RVPage_Reminders_ReminderAdded);
            RefreshRemindersList();
        }
Exemplo n.º 4
0
        public void Remind(DateTime dateTime, string title, string message)
        {
            string param1Value = title;
            string param2Value = message;
            string queryString = "";

            if (param1Value != "" && param2Value != "")
            {
                queryString = "?param1=" + param1Value + "&param2=" + param2Value;
            }
            else if (param1Value != "" || param2Value != "")
            {
                queryString = (param1Value != null) ? "?param1=" + param1Value : "?param2=" + param2Value;
            }
            Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder("ServiceReminder");
            reminder.Title          = title;
            reminder.Content        = message;
            reminder.BeginTime      = dateTime;
            reminder.ExpirationTime = dateTime.AddDays(1);
            reminder.RecurrenceType = RecurrenceInterval.None;
            reminder.NavigationUri  = new Uri("/MainPage.xaml" + queryString, UriKind.Relative);
            ;

            // Register the reminder with the system.
            ScheduledActionService.Add(reminder);
        }
Exemplo n.º 5
0
        public void SetReminder(RecipeDataItem item)
        {
            if (!IsScheduled(item.UniqueId))
            {
                ScheduledAction schedule = ScheduledActionService.Find(item.UniqueId);
                if (null != schedule)
                    ScheduledActionService.Remove(schedule.Name);

                var reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId)
                {
                    Title = item.Title,
                    Content = "Has terminado de cocinar?",
                    BeginTime =
                        Debugger.IsAttached
                            ? DateTime.Now.AddSeconds(30)
                            : DateTime.Now.Add(TimeSpan.FromMinutes(Convert.ToDouble(item.PrepTime)))
                };

                reminder.ExpirationTime = reminder.BeginTime.AddSeconds(30);
                reminder.RecurrenceType = RecurrenceInterval.None;
                reminder.NavigationUri =
                    new Uri("../View/RecipeDetailPage.xaml?ID=" + item.UniqueId + "&GID=" + item.Group.UniqueId,
                        UriKind.Relative);

                ScheduledActionService.Add(reminder);
            }
            else
            {
                ScheduledAction schedule = ScheduledActionService.Find(item.UniqueId);
                ScheduledActionService.Remove(schedule.Name);
            }
        }
        public void Remind(DateTime dateTime, string title, string message)
        {
            string param1Value = title;
            string param2Value = message;
            string queryString = "";
            if (param1Value != "" && param2Value != "")
            {
                queryString = "?param1=" + param1Value + "&param2=" + param2Value;
            }
            else if (param1Value != "" || param2Value != "")
            {
                queryString = (param1Value != null) ? "?param1=" + param1Value : "?param2=" + param2Value;
            }
            Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder("ServiceReminder");
            reminder.Title = title;
            reminder.Content = message;
            reminder.BeginTime = dateTime;
            reminder.ExpirationTime = dateTime.AddDays(1);
            reminder.RecurrenceType = RecurrenceInterval.None;
            reminder.NavigationUri = new Uri("/MainPage.xaml" + queryString, UriKind.Relative);
            ;

            // Register the reminder with the system.
            ScheduledActionService.Add(reminder);
        }
        private void appbar_add_Click(object sender, EventArgs e)
        {
            var vm = (SessionViewModel)this.LayoutRoot.DataContext;
            bool found = false;

            foreach (var s in App.SavedSessions)
            {
                if (s.Title.Trim().Equals(vm.Session.Title.Trim(), StringComparison.InvariantCultureIgnoreCase))
                {
                    App.SavedSessions.Remove(s);
                    App.SavedSessionIds.Remove(vm.Session.Id);
                    found = false;
                    break;
                }
            }
            App.SavedSessions.Add(vm.Session);
            App.SavedSessionIds.Add(vm.Session.Id);
            //only add a reminder one time
            if (!found)
            {
                try
                {
                    Reminder reminder = new Reminder(vm.Session.Title);
                    reminder.BeginTime = vm.Session.Begins.AddMinutes(-5); // Add a reminder 5 mins before it starts
                    reminder.Content = vm.Session.Title;
                    reminder.RecurrenceType = RecurrenceInterval.None;

                    ScheduledActionService.Add(reminder);
                    XamMessageBox.Show("Favourite added", "Added to your favorites.",
                        () => { },
                        VerticalPosition.Center,
                        new XamMessageBoxCommand("OK", () => { }));
                }
                catch (Exception)
                {
                    //need to let use know we cound not add a reminder?
                    XamMessageBox.Show("Already a favorite", "This session is already a favorite.",
                        () => { },
                        VerticalPosition.Center,
                        new XamMessageBoxCommand("OK", () => { }));
                }

            }
        }
        private void btnSaveChange_Click(object sender, EventArgs e)
        {
            ShowProgressIndicator("Saving changes...");
            //reminder
            if (checkboxtime.IsChecked == true)
            {
                DateTime _datetime = (DateTime)datepicker.Value + ((DateTime)timepicker.Value).TimeOfDay;
                if (_datetime <= DateTime.Now)
                {
                    MessageBox.Show("The datetime must be in the future.");
                    goto Label_0211;
                }

                App.ViewModel.SelectedNote.TimeReminder = _datetime;
            }
            if (checkboxdis.IsChecked == true)
                try
                {
                    App.ViewModel.SelectedNote.NoteDistanceReminder = double.Parse(txtDistance.Text.Trim());
                }
                catch (Exception)
                {
                    App.ViewModel.SelectedNote.NoteDistanceReminder = 0.0f;
                }
            App.ViewModel.SelectedNote.IsTimeReminder = checkboxtime.IsChecked == true ? true : false;
            App.ViewModel.SelectedNote.IsDistanceReminder = checkboxdis.IsChecked == true ? true : false;

            // title
            if (txtTitle.Text.Length > 0)
                App.ViewModel.SelectedNote.NoteTitle = txtTitle.Text;
            else
            {
                MessageBox.Show("The title can not be empty.");
                goto Label_0211;
            }

            //description
            App.ViewModel.SelectedNote.NoteDescription = txtDescription.Text;
            //tags
            App.ViewModel.SelectedNote.NoteTags = txtTags.Text;
            //category
            App.ViewModel.SelectedNote.Category = categoriesListPicker.SelectedItem as ToDoCategory;
            //location
            App.ViewModel.SelectedNote.NoteLocation = LocationXmlParser.CreateXmlString(mylocation);
            ////photos
            App.ViewModel.SelectedNote.NotePhotos = XMLParser.MediaXmlParser.CreateXmlString(photos.ToList(), "photos");
            ////voices
            App.ViewModel.SelectedNote.NoteVoices = XMLParser.MediaXmlParser.CreateXmlString(voicespath.ToList(), "voices");
            App.ViewModel.SaveChangesToDB();

            ScheduledAction currentReminder = ScheduledActionService.Find(App.ViewModel.SelectedNote.ToDoNoteId.ToString());

            if (currentReminder != null)
            {
                ScheduledActionService.Remove(currentReminder.Name);
            }

            if (App.ViewModel.SelectedNote.IsTimeReminder)
            {
                var reminder = new Microsoft.Phone.Scheduler.Reminder(App.ViewModel.SelectedNote.ToDoNoteId.ToString())
                {
                    BeginTime = (DateTime)App.ViewModel.SelectedNote.TimeReminder,
                    Title = App.ViewModel.SelectedNote.NoteTitle,
                    Content = App.ViewModel.SelectedNote.NoteDescription,
                };

                ScheduledActionService.Add(reminder);
            }
            if (NavigationService.CanGoBack)
                NavigationService.GoBack();
            Label_0211:
            HideProgressIndicator();
        }
                private void AddReminderButton_Click(object sender, RoutedEventArgs e)
                {
                        var reminderDtTm = new DateTime(dpReminderDate.Value.Value.Year, dpReminderDate.Value.Value.Month, dpReminderDate.Value.Value.Day,
                                                        tpReminderTime.Value.Value.Hour, tpReminderTime.Value.Value.Minute, tpReminderTime.Value.Value.Second);
                        if (DateTime.Now > reminderDtTm) {
                                App.ToastMe(StringResources.RVPage_Reminders_Messages_ReminderPastNow);
                                return;
                        }

                        var s = string.Format(StringResources.RVPage_Reminders_ReminderTitle, App.ViewModel.ReturnVisitData.FullName);


                        var r = new Microsoft.Phone.Scheduler.Reminder(Guid.NewGuid().ToString())
                        {
                                Content = tbReminderNotes.Text,
                                BeginTime = reminderDtTm,
                                Title = s,
                                NavigationUri = NavigationService.CurrentSource
                        };
                        ScheduledActionService.Add(r);
                        tbReminderNotes.Text = "";
                        App.ToastMe(StringResources.RVPage_Reminders_ReminderAdded);
                        RefreshRemindersList();
                }