コード例 #1
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string listId   = String.Empty;
            string taskData = (items.First() as ITextItem).Text;

            if (string.IsNullOrEmpty(taskData))
            {
                Services.Notifications.Notify("Remember The Milk",
                                              AddinManager.CurrentLocalizer.GetString("No title provided for new task."));
                yield break;
            }

            if (modifierItems.FirstOrDefault() != null)
            {
                listId = (modifierItems.FirstOrDefault() as RTMListItem).Id;
            }

            if (RTMPreferences.ReturnNewTask)
            {
                yield return(RTM.NewTask(listId, taskData));
            }
            else
            {
                Services.Application.RunOnThread(() => {
                    RTM.NewTask(listId, taskData);
                });
                yield break;
            }
        }
コード例 #2
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            RTMTaskItem   task      = null;
            List <string> temp_tags = new List <string> ();

            if (items.Any())
            {
                if (items.First() is RTMTaskItem)
                {
                    task = (items.First() as RTMTaskItem);
                }
                else if (items.First() is RTMTaskAttributeItem)
                {
                    task = (items.First() as RTMTaskAttributeItem).Parent;
                }
            }

            if (modifierItems.Any() && task != null)
            {
                foreach (Item item in modifierItems)
                {
                    temp_tags.Add((item as RTMTagItem).Name);
                }

                Services.Application.RunOnThread(() => {
                    RTM.DeleteTags(task.ListId, task.TaskSeriesId,
                                   task.Id, String.Join(",", temp_tags.ToArray()));
                });
            }
            yield break;
        }
コード例 #3
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            RTMTaskItem task = null;
            string      due  = String.Empty;

            if (items.Any())
            {
                if (items.First() is RTMTaskItem)
                {
                    task = (items.First() as RTMTaskItem);
                }
                else if (items.First() is RTMTaskAttributeItem)
                {
                    task = (items.First() as RTMTaskAttributeItem).Parent;
                }
            }

            if (modifierItems.Any())
            {
                due = (modifierItems.First() as ITextItem).Text;
            }

            if (task != null)
            {
                Services.Application.RunOnThread(() => {
                    RTM.SetDueDateTime(task.ListId, task.TaskSeriesId, task.Id, due);
                });
            }

            yield break;
        }
コード例 #4
0
 public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
 {
     Services.Application.RunOnThread(() => {
         RTM.UncompleteTask((items.First() as RTMTaskItem).ListId,
                            (items.First() as RTMTaskItem).TaskSeriesId,
                            (items.First() as RTMTaskItem).Id);
     });
     yield break;
 }
コード例 #5
0
 public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
 {
     Services.Application.RunOnThread(() => {
         RTM.SetRecurrence((items.First() as RTMTaskItem).ListId,
                           (items.First() as RTMTaskItem).TaskSeriesId,
                           (items.First() as RTMTaskItem).Id,
                           (modifierItems.FirstOrDefault() as ITextItem).Text);
     });
     yield break;
 }
コード例 #6
0
 public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
 {
     Services.Application.RunOnThread(() => {
         RTM.SetTaskPriority((items.First() as RTMTaskItem).ListId,
                             (items.First() as RTMTaskItem).TaskSeriesId,
                             (items.First() as RTMTaskItem).Id,
                             (modifierItems.First() as RTMPriorityItem).Priority);
     });
     yield break;
 }
コード例 #7
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string listname = (items.First() as RTMListItem).Id;

            Services.Application.RunOnThread(() => {
                RTM.DeleteList(listname);
            });

            yield break;
        }
コード例 #8
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            if (items.Any())
            {
                Services.Application.RunOnThread(() => {
                    RTM.DeleteNote((items.First() as RTMNoteItem).Id);
                });
            }

            yield break;
        }
コード例 #9
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            RTMTaskItem task = null;
            string      url  = String.Empty;

            if (items.Any())
            {
                if (items.First() is RTMTaskItem)
                {
                    task = (items.First() as RTMTaskItem);
                }
                else if (items.First() is RTMTaskAttributeItem)
                {
                    task = (items.First() as RTMTaskAttributeItem).Parent;
                }
            }

            if (modifierItems.FirstOrDefault() != null)
            {
                url = ((modifierItems.FirstOrDefault() as ITextItem).Text);
            }

            // User may have entered explicit mode and entered a blank line.
            // To be safe; strip out all new line characters from input
            // for URL resetting.
            url = url.Replace("\n", "");

            // The URL set to the task may be reset if the entered text is empty.
            // Check if it's not empty.
            if (!string.IsNullOrEmpty(url))
            {
                // Check if the entered text is a valid URL.
                if (!CheckValidURL(url))
                {
                    // Error in entered URL.
                    Services.Notifications.Notify("Remember The Milk",
                                                  AddinManager.CurrentLocalizer.GetString("Invalid URL provided."));
                    yield break;
                }
            }

            if (task != null)
            {
                Services.Application.RunOnThread(() => {
                    RTM.SetURL(task.ListId, task.TaskSeriesId, task.Id, url);
                });
            }
            yield break;
        }
コード例 #10
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string note = String.Empty;

            if (modifierItems.FirstOrDefault() != null)
            {
                note = ((modifierItems.FirstOrDefault() as ITextItem).Text);
            }

            Services.Application.RunOnThread(() => {
                RTM.NewNote((items.First() as RTMTaskItem).ListId,
                            (items.First() as RTMTaskItem).TaskSeriesId,
                            (items.First() as RTMTaskItem).Id, note);
            });
            yield break;
        }
コード例 #11
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string locationId = String.Empty;

            if (modifierItems.Any())
            {
                locationId = (modifierItems.First() as RTMLocationItem).Id;
            }

            Services.Application.RunOnThread(() => {
                RTM.SetLocation((items.First() as RTMTaskItem).ListId,
                                (items.First() as RTMTaskItem).TaskSeriesId,
                                (items.First() as RTMTaskItem).Id, locationId);
            });
            yield break;
        }
コード例 #12
0
        /// <summary>
        /// Called when the "Authorize" button is clicked. Initializes the authentication.
        /// </summary>
        /// <param name="sender">
        /// Ignored
        /// </param>
        /// <param name="e">
        /// Ignored
        /// </param>
        protected virtual void OnAuthBtnClicked(object sender, System.EventArgs e)
        {
            frob = RTM.AuthInit();
            authinfo_lbl.Text = AddinManager.CurrentLocalizer.GetString("A webpage from Remember The Milk should be opened"
                                                                        + " in your web browser now. Please follow the instructions there and come back to complete"
                                                                        + " the authrozation by clicking the button below.");
            RTMPreferences.Token       = "";
            RTMPreferences.Username    = "";
            notification_frm.Sensitive = false;
            filter_frm.Sensitive       = false;
            Widget image = auth_btn.Image;

            auth_btn.Label    = AddinManager.CurrentLocalizer.GetString("Complete authorization");
            auth_btn.Image    = image;
            auth_btn.Clicked -= new EventHandler(OnAuthBtnClicked);
            auth_btn.Clicked += new EventHandler(OnCompleteBtnClicked);
        }
コード例 #13
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            if (modifierItems.Any())
            {
                string newListName = (modifierItems.First() as ITextItem).Text;
                if (String.IsNullOrEmpty(newListName))
                {
                    Log <RTM> .Debug("No list name provided for RTMRenameList action");

                    yield break;
                }

                Services.Application.RunOnThread(() => {
                    RTM.RenameList((items.First() as RTMListItem).Id, newListName);
                });
            }

            yield break;
        }
コード例 #14
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            RTMTaskItem task = null;
            string      est  = String.Empty;

            if (items.Any())
            {
                if (items.First() is RTMTaskItem)
                {
                    task = (items.First() as RTMTaskItem);
                }
                else if (items.First() is RTMTaskAttributeItem)
                {
                    task = (items.First() as RTMTaskAttributeItem).Parent;
                }
            }

            if (modifierItems.Any())
            {
                est = ((modifierItems.First() as ITextItem).Text);
            }

            if (!string.IsNullOrEmpty(est))
            {
                if (!CheckValidTime(est))
                {
                    Services.Notifications.Notify(AddinManager.CurrentLocalizer.GetString("Invalid Time format"),
                                                  AddinManager.CurrentLocalizer.GetString("The estimated time entered cannot be understood."),
                                                  "rtm.png@" + GetType().Assembly.FullName);
                    yield break;
                }
            }

            if (task != null)
            {
                Services.Application.RunOnThread(() => {
                    RTM.SetEstimateTime(task.ListId, task.TaskSeriesId, task.Id, est);
                });
            }

            yield break;
        }
コード例 #15
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            if (items.Any())
            {
                string newListName = (items.First() as ITextItem).Text;
                if (String.IsNullOrEmpty(newListName))
                {
                    Log <RTM> .Debug(AddinManager.CurrentLocalizer.GetString("No list name provided for RTMNewList action"));

                    yield break;
                }
                else
                {
                    Services.Application.RunOnThread(() => {
                        RTM.NewList(newListName);
                    });
                }
            }
            yield break;
        }
コード例 #16
0
        /// <summary>
        /// Called when user returns from the authentication webpage and clicks the "Complete" button.
        /// </summary>
        /// <param name="sender">
        /// Ignored
        /// </param>
        /// <param name="e">
        /// Ignored
        /// </param>
        protected virtual void OnCompleteBtnClicked(object sender, EventArgs e)
        {
            Auth auth;

            auth = RTM.AuthComplete(frob);
            if (auth != null)
            {
                RTMPreferences.Token    = auth.Token;
                RTMPreferences.Username = auth.User.Username;
                auth_btn.Clicked       -= new EventHandler(OnCompleteBtnClicked);
                auth_btn.Clicked       += new EventHandler(OnAuthBtnClicked);
                SetStateComplete();
            }
            else
            {
                authinfo_lbl.Text = AddinManager.CurrentLocalizer.GetString("Fail to complete authorization.");
                auth_btn.Clicked -= new EventHandler(OnCompleteBtnClicked);
                auth_btn.Clicked += new EventHandler(OnAuthBtnClicked);
                auth_btn.Label    = AddinManager.CurrentLocalizer.GetString("Authorize again");
            }
        }
コード例 #17
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            RTMTaskItem   task      = null;
            List <string> temp_tags = new List <string> ();
            string        s         = null;

            if (items.Any())
            {
                if (items.First() is RTMTaskItem)
                {
                    task = (items.First() as RTMTaskItem);
                }
                else if (items.First() is RTMTaskAttributeItem)
                {
                    task = (items.First() as RTMTaskAttributeItem).Parent;
                }
            }

            if (modifierItems.Any() && task != null)
            {
                foreach (Item item in modifierItems)
                {
                    s = GetText(item);
                    if (!String.IsNullOrEmpty(s))
                    {
                        temp_tags.Add(s);
                    }
                }

                Services.Application.RunOnThread(() => {
                    RTM.AddTags((items.First() as RTMTaskItem).ListId, (items.First() as RTMTaskItem).TaskSeriesId,
                                (items.First() as RTMTaskItem).Id, String.Join(",", temp_tags.ToArray()));
                });
            }
            yield break;
        }
コード例 #18
0
 public override IEnumerable <Item> ChildrenOfItem(Item parent)
 {
     return(RTM.AttributesForTask((parent as RTMTaskItem)));
 }
コード例 #19
0
 public override IEnumerable <Item> ChildrenOfItem(Item parent)
 {
     return(RTM.TasksForList((parent as RTMListItem).Id));
 }
コード例 #20
0
 public override IEnumerable <Item> ChildrenOfItem(Item parent)
 {
     return(RTM.TasksForTag((parent as RTMTagItem).Name));
 }