示例#1
0
        /**
         *  change the section in theverge to use
         */
        private void changeSource()
        {
            View.ColorStringIL("Which source would you like to use? [current: ", ConsoleColor.Yellow);
            View.ColorStringIL(sources[Source - 1], ConsoleColor.DarkYellow);
            View.ColorStringNL("]", ConsoleColor.Yellow);

            Model.ShowSources();

            View.ColorStringIL("source", ConsoleColor.DarkYellow);
            Console.ResetColor();
            Console.Write(">");

            int  number;
            bool chosen = int.TryParse(Console.ReadLine(), out number);

            if (!chosen)
            {
                error("This source does not exist. Please choose another one.\n");
                changeSource();
            }
            else
            {
                Source = number;
                View.ColorStringNL("You selected " + sources[Source - 1], ConsoleColor.Green);
            }
        }
示例#2
0
        public void ShowHelp()
        {
            Console.WriteLine("The available commands are shown below:");

            View.ColorStringNL("\thelp", ConsoleColor.Yellow);
            Console.WriteLine("\t\tshow this information\n");

            View.ColorStringNL("\twhats up", ConsoleColor.Yellow);
            Console.WriteLine("\t\tget the latest articles\n");

            View.ColorStringNL("\tsource", ConsoleColor.Yellow);
            Console.WriteLine("\t\tchange the source for articles to show\n");

            View.ColorStringNL("\tshow saved", ConsoleColor.Yellow);
            Console.WriteLine("\t\tshow the articles in the storage\n");

            View.ColorStringNL("\tread -n|-s $articlenumber", ConsoleColor.Yellow);
            Console.WriteLine("\t\topen new|saved article with the number $article number\n");

            View.ColorStringNL("\tsave $articlenumber", ConsoleColor.Yellow);
            Console.WriteLine("\t\tsave article with number $articlenumber to storage\n");

            View.ColorStringNL("\tdelete $articlenumber", ConsoleColor.Yellow);
            Console.WriteLine("\t\tdelete article with the number $articlenumber from storage\n");

            View.ColorStringNL("\texit", ConsoleColor.Yellow);
            Console.WriteLine("\t\texit Broccoli");
        }
示例#3
0
        public void ShowSavedArticles()
        {
            View.ColorStringNL("Here are your saved articles:", ConsoleColor.Yellow);

            foreach (var articles in Storage.Show())
            {
                Console.WriteLine(articles.ID + ": " + articles.Title);
            }
        }
示例#4
0
        public void ShowArticles(int source)
        {
            //assign the downloaded articles to the array
            newArticles = Downloader.Download(source);
            View.ColorStringNL("Here are the latest articles:", ConsoleColor.Yellow);

            foreach (var article in newArticles)
            {
                Console.WriteLine(article.ID + ": " + article.Title);
            }
        }
示例#5
0
 //delete an article (with the specific number)
 private void delete(string input)
 {
     try {
         string[] words  = input.Split(' ');
         int      number = Convert.ToInt16(words[1]);
         if (number > 10 || number <= 0)
         {
             throw new FormatException();
         }
         Model.Delete(number);
         View.ColorStringNL("Article " + number + " has been deleted.", ConsoleColor.Green);
     }
     catch (IndexOutOfRangeException) {
         error("The command is invalid. Please make sure you entered it in the correct format and have a valid article number!");
     } catch (FormatException) {
         error("The command is invalid. Please make sure you entered a valid article number!");
     } catch (Exception e) {
         error(e.Message);
     }
 }