Ejemplo n.º 1
0
        //When focus moves away from the ticker window or it
        //closes, it must first be undocked so that reserved screen space
        //is freed for use by other programs


        public void Refresh()
        //This function calls when the ticker needs to be refreshed
        {
            canv.Children.Clear();
            //The canvas is cleared of any TickerItemElements

            List <string>   sources = (DataRoutines.sourceRead()).ToList();
            List <newsItem> news    = RSS_Scraper.RSS_Scrape(sources);

            ticker.items.Clear();
            foreach (newsItem item in news)
            {
                ticker.items.Add(new TickerItemElement(item));
            }
            //The tickers list of items is cleared, and then filled
            //with a new set of news

            ticker.refreshInterval    = Properties.Settings.Default.refreshTime;
            ticker.animTimer.Interval = new TimeSpan(0, 0, 1);

            string tickerSpeedStr = Properties.Settings.Default.tickerSpeed;
            int    defaultSpeed   = 60;

            switch (tickerSpeedStr)
            {
            case "50%":
                defaultSpeed        = 2 * (defaultSpeed);
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;


            case "75%":
                defaultSpeed        = Convert.ToInt32((1.5 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;


            case "100%":
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;


            case "150%":
                defaultSpeed        = Convert.ToInt32((0.75 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;


            case "200%":
                defaultSpeed        = Convert.ToInt32((0.5 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
            }
            ticker.Start();
            //The ticker is then reset and started. WHile inefficient, this does function
            //as intended
        }
Ejemplo n.º 2
0
        //Upon construction, the sourceRead function is called, which
        //reads from a text file containing all news sources input

        private void addFeed(object sender, RoutedEventArgs e)
        {
            newSource = this.sourceInp.Text;
            bool valid = RSS_Scraper.validateSource(newSource);

            if (valid == true)
            {
                sources.Add(newSource);
                sourceInp.Text       = sourceInpText;
                sourceInp.Foreground = Brushes.Gray;
            }
            else if (valid == false)
            {
                MessageBox.Show(this, "The data you entered is not a valid RSS source, please try again.",
                                "Invalid Input", MessageBoxButton.OK);
                sourceInp.Text       = sourceInpText;
                sourceInp.Foreground = Brushes.Gray;
            }
        }
Ejemplo n.º 3
0
        //The function initTicker is called when loading is complete,
        //to initialise the key aspects of the window

        public void initTicker()
        {
            List <string> sources = (DataRoutines.sourceRead()).ToList();
            //The list of input newsSources is read using
            //DataRoutines.sourceRead

            List <newsItem> news = RSS_Scraper.RSS_Scrape(sources);

            //This list of input sources is then passed to
            //RSS_Scraper.RSS_Scrape, which gathers
            //all news from those sources

            ticker = new Ticker <TickerItemElement>(canv, this);
            //A new ticker is instantiated, with a parent of the
            //current tickerWindow instantiating it, and a
            //containing window of the canvas element canv

            foreach (newsItem item in news)
            {
                ticker.items.Add(new TickerItemElement(item));
            }
            //Subsequently, the list of items the ticker has to
            //scroll is added to with the gathered news, creating
            //tickerItemElements as the process occurs

            ticker.refreshInterval = Properties.Settings.Default.refreshTime;
            //The refresh interval of the ticker is set to the user set
            //property refreshTime

            string tickerSpeedStr = Properties.Settings.Default.tickerSpeed;
            int    defaultSpeed   = 60;

            //The default speed of the ticker corresponds to a 60 second
            //TimeSpan. The string tickerSpeedStr is linked to the tickerSpeed
            //user setting, and is used to determine the modifier to this
            //value

            switch (tickerSpeedStr)
            {
            //The following switch-case block will choose the
            //appropriate modifier to the speed value

            case "50%":
                defaultSpeed        = 2 * (defaultSpeed);
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
            //The speed being set to 50% slower means that the TimeSpan must
            //be doubled

            case "75%":
                defaultSpeed        = Convert.ToInt32((1.5 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
            //For 75%, this is halfway between 1.0 and 2.0 times the default value. As
            //this is multiplying by a double, the program must convert to the integer
            //deafult value to a double and back to an integer for use in the TimeSpan

            case "100%":
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
            //This is the default value, so there are no changes made

            case "150%":
                defaultSpeed        = Convert.ToInt32((0.75 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
            //A 150% speed corresponds to a 0.75 times multiplier, making the TimeSpan
            //smaller

            case "200%":
                defaultSpeed        = Convert.ToInt32((0.5 * (Convert.ToDouble(defaultSpeed))));
                ticker.animDuration = new TimeSpan(0, 0, defaultSpeed);
                break;
                //A 200% speed halves the TimeSpan to 30 seconds
            }


            ticker.Start();
            dock();
            //The ticker is started and the dock function called
        }