Example #1
0
        /// <summary>
        /// The handles key press in feed list
        /// </summary>
        /// <param name="key">The <see cref="ConsoleKeyInfo"/></param>
        /// <param name="selectedItem">The <see cref="RssFeed"/></param>
        /// <param name="parent">The <see cref="Picklist{RssFeed}"/></param>
        /// <returns>The <see cref="bool"/></returns>
        private bool FeedList_OnItemKeyHandler(ConsoleKeyInfo key, RssFeed selectedItem, Picklist <RssFeed> parent)
        {
            //Open
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenFeed))
            {
                return(OpenSelectedFeed(selectedItem, parent));
            }

            //Exit app
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.QuitApp))
            {
                return(false);
            }

            //Reload all
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.ReloadAll))
            {
                ReloadAll(parent, true);
                parent.Refresh();
                return(true);
            }

            //Reload
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Reload))
            {
                if (!selectedItem.IsProcessing)
                {
                    ReloadOne(selectedItem, true);

                    Parallel.ForEach(parent.ListItems.Where(i => ((RssFeed)i).IsDynamic == true), (item) =>
                    {
                        ((RssFeed)item).Load(false);
                    });
                }
                return(true);
            }

            //Mark all read
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkAllRead))
            {
                return(MarkAllArticlesRead(selectedItem));
            }

            //Purge deleted
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Purge))
            {
                return(PurgeDeletedArticles(parent));
            }

            //Redraw view
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.RefreshView))
            {
                _mainView.Refresh();
            }

            //open feed URL
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenBrowser))
            {
                return(OpenFeedInBrowser(selectedItem));
            }

            //search
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Search))
            {
                parent.IsDisplayed = false;
                var result = GlobalMethods.Search(_mainView);
                parent.IsDisplayed = true;
                return(result);
            }
            return(true);
        }
Example #2
0
        private bool ArticleList_OnItemKeyHandler(ConsoleKeyInfo key, FeedItem selectedItem, Picklist <FeedItem> parent)
        {
            //Open article
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenArticle))
            {
                return(OpenArticle(selectedItem, parent));
            }
            //Mark selected item as read
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkRead))
            {
                if (selectedItem != null)
                {
                    selectedItem.MarkAsRead();
                    selectedItem.DisplayText = selectedItem.DisplayLine;
                }
            }
            //Mark all read
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkAllRead))
            {
                return(MarkAllRead());
            }
            //Mark selected item as unread
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkUnread))
            {
                if (selectedItem != null && !selectedItem.IsNew)
                {
                    selectedItem.MarkUnread();
                    selectedItem.DisplayText = selectedItem.DisplayLine;
                }
            }
            //Mark current item for deletion
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Delete))
            {
                if (selectedItem != null)
                {
                    selectedItem.MarkDeleted();
                    selectedItem.DisplayText = selectedItem.DisplayLine;
                }
            }

            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.DeleteAll))
            {
                return(DeleteAllArticles());
            }

            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.StepBack))
            {
                return(false);
            }

            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Reload))
            {
                return(Reload(parent));
            }
            //Download selected item content to local storage
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Download))
            {
                return(Download(selectedItem));
            }
            //Delete locally stored content
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.DeleteContent))
            {
                return(DeleteContent(selectedItem));
            }
            //open in browser
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenBrowser))
            {
                return(OpenArticleInBrowser(selectedItem));
            }
            //search
            if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Search))
            {
                parent.IsDisplayed = false;
                var result = GlobalMethods.Search(_mainView);
                parent.IsDisplayed = true;
                return(result);
            }
            return(true);
        }