Example #1
0
        public void Update()
        {
            if ((DateTime.Now - lastCheck).TotalSeconds > refreshInterval)
            {
                lastCheck = DateTime.Now;

                List<Tweet> fresh = twitter.FetchTweets();
                if (fresh != null && fresh.Count > 0)
                {
                    foreach (Tweet t in fresh)
                    {
                        Alert newAlert = new Alert(t.Text);
                        // TODO
                        list.Add(newAlert);
                    }

                    if (OnAlert != null)
                        OnAlert.Invoke();
                }
            }
        }
Example #2
0
        public void Update()
        {
            if ((DateTime.Now - lastCheck).TotalSeconds > refreshInterval)
            {
                lastCheck = DateTime.Now;

                List<Tweet> fresh = twitter.FetchTweets();
                if (fresh != null && fresh.Count > 0)
                {
                    foreach (Tweet t in fresh)
                    {
                        Alert newAlert = null;

                        string tweetText = t.Text;
                        Console.WriteLine(t.Text);
                        Match match = Regex.Match(tweetText, @"([A-Za-z\s\-)]+) (\([A-Za-z\s]+\)): ([A-Za-z\t\s\']+) - ([0-9]+)m - ([0-9]+)cr[\t\s]?-?[\s]?([A-Za-z\t\s\(\)]+)?", RegexOptions.IgnoreCase);
                        if (match.Success)
                        {
                            string location = match.Groups[1].Value + " " + match.Groups[2].Value;
                            string title = match.Groups[3].Value;
                            string duration = match.Groups[4].Value;
                            string credits = match.Groups[5].Value;
                            string reward = match.Groups[6].Value;
                            Console.WriteLine(reward);
                            newAlert = new Alert(location, title, duration, credits, reward, t.Created, GetEndTime(t.Created, duration));
                        }

                        if (newAlert != null)
                        {
                            DateTime Expires = newAlert.Expires;
                            DateTime Now = DateTime.Now;
                            TimeSpan Remaining = Expires - Now;
                            newAlert.Remaining = Remaining;
                            if (!ProgramOptions.ShowAll && ProgramOptions.MinCredits > Int32.Parse(newAlert.Credits) && newAlert.Reward != null)
                            {
                                newAlert.Show = false;
                            }
                            if (Remaining.Minutes > 1 && newAlert.Show)
                            {
                                list.Add(newAlert);
                                App.Current.Dispatcher.BeginInvoke((Action)delegate()
                                {
                                    Balloon balloon = new Balloon();
                                    balloon.DataContext = newAlert;
                                    taskbarIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 99999999);
                                    viewList.Add(newAlert);
                                    if (ProgramOptions.PlaySound)
                                    {
                                        sp = new SoundPlayer(ProgramOptions.Sound);
                                        sp.Stream.Position = 0;
                                        sp.Play();
                                    }
                                });
                            }
                        }
                    }

                    if (OnAlert != null)
                        OnAlert.Invoke();
                }
            }
        }