Example #1
0
 private void btnRmUrl_Click(object sender, EventArgs e)
 {
     timer.Stop();
     if (urlprovider.removeurl(TxtbxUrl.Text))
     {
         populatelistview();
         RTxtDisplay.Text = string.Format("{0} is removed to the urls list", TxtbxUrl.Text);
     }
     timer.Start();
 }
        public static int Main(string[] args)
        {
            setup();

            while (true)
            {
                char command = Console.ReadKey().KeyChar;
                switch (command)
                {
                case 'q':
                {
                    timer.Stop();
                    Console.WriteLine("\n quit .....");
                    return(0);
                }

                case 's':
                {
                    Console.WriteLine("\n start the application :");
                    timer.Start();
                    break;
                }

                case 'a':
                {
                    timer.Stop();

                    Console.Write("\n add url entry: ");

                    string url = Console.ReadLine();

                    if (urlprovider.addurl(url))
                    {
                        Console.WriteLine("\n new url entry was addes");
                    }
                    else
                    {
                        Console.WriteLine("\n failed to add the url entry");
                    }

                    urls = urlprovider.geturls();
                    timer.Start();
                    break;
                }

                case 'c':
                {
                    timer.Stop();
                    Console.WriteLine("\n enter the specified timer intervals: ");
                    double interval = Convert.ToDouble(Console.ReadLine());
                    timer.Interval = interval;
                    timer.Start();
                    break;
                }

                case 'r':
                {
                    timer.Stop();
                    Console.Write("\n select url to remove: ");
                    string url = Console.ReadLine();

                    if (urlprovider.removeurl(url))
                    {
                        Console.WriteLine("url removed successufully");
                    }
                    else
                    {
                        Console.WriteLine("fail to remove the url");
                    }
                    urls = urlprovider.geturls();
                    timer.Start();
                    break;
                }

                default:
                {
                    Console.WriteLine("invalid command");
                    break;
                }
                }
            }
        }