Example #1
0
        private void loadFeed( Feed feed )
        {
            String feedName = feed.FeedName;

            var user     = User.GetUserFromScreenName( feedName.Remove( 0, 1 ) );
            var timeline = user.GetUserTimeline( Properties.Settings.Default.MaxTweets );

            Application.Current.Dispatcher.Invoke( ( Action )delegate {
                List<Tweet> tweets = new List<Tweet>( );
                foreach( ITweet t in timeline ) {
                    tweets.Add( new Tweet( t.IsRetweet ? "@" + t.RetweetedTweet.Creator.ScreenName : "@" + t.Creator.ScreenName,
                                           t.IsRetweet ? t.RetweetedTweet.Creator.ProfileImageUrl : t.Creator.ProfileImageUrl,
                                           t.Text,
                                           t.CreatedAt.ToShortDateString( ),
                                           t.CreatedAt.ToShortTimeString( ),
                                           t.IsRetweet ? "Retweeted by " + t.Creator.ScreenName : "" ) );
                }
                feeds[feed] = tweets;
            } );
        }
Example #2
0
        private void updateFeed( Feed feed )
        {
            String feedName = feed.FeedName;

            var user     = User.GetUserFromScreenName( feedName.Remove( 0, 1 ) );
            var timeline = user.GetUserTimeline( Properties.Settings.Default.MaxTweets );

            //Get and display all new tweets
            Application.Current.Dispatcher.Invoke( ( Action )delegate {
                //27/02/2016
                //discovered a bug where sometimes a tweet or two will be missing from the timeline when it is found on other iterations
                List<Tweet> tweets = new List<Tweet>( );
                foreach( ITweet t in timeline ) {
                    tweets.Add( new Tweet( t.IsRetweet ? "@" + t.RetweetedTweet.Creator.ScreenName : "@" + t.Creator.ScreenName,
                                           t.IsRetweet ? t.RetweetedTweet.Creator.ProfileImageUrl : t.Creator.ProfileImageUrl,
                                           t.Text,
                                           t.CreatedAt.ToShortDateString( ),
                                           t.CreatedAt.ToShortTimeString( ),
                                           t.IsRetweet ? "Retweeted by " + t.Creator.ScreenName : "" ) );
                }

                bool newTweetsFound = false;
                List<Tweet> newTweets = new List<Tweet>( );
                foreach( Tweet tweet in tweets ) {
                    if( !foundInTweetList( feed, tweet ) ) {
                        newTweets.Add( tweet );
                        newTweetsFound = true;
                        //If more than 5 new tweets are found at any one time, only
                        //return the first tweet. This is to prevent bunch of tweet
                        //notifications appearing on the desktop
                        if( newTweets.Count >= 5 ) {
                            newTweets.RemoveRange( 1, newTweets.Count - 1 );
                            break;
                        }
                    }
                }

                //Only update if new tweets are found
                //NOTE: this is to avoid the above bug
                if( newTweetsFound ) {
                    feeds[feed] = tweets;
                }

                foreach( Tweet nt in newTweets ) {
                    newTweet( nt, "New Tweet:" );
                }
            } );
        }
Example #3
0
        private bool foundInTweetList( Feed feed, Tweet tweet )
        {
            List<Tweet> tweets = feeds[feed];

            if( tweets.Count == 0 ) {
                return false;
            }

            foreach( Tweet t in tweets ) {
                if( tweet.Equals( t ) ) {
                    return true;
                }
            }

            return false;
        }
Example #4
0
 public void removeFeedConnection( Feed feed  )
 {
     String feedName = feed.FeedName;
     if( feeds.ContainsKey( feed ) ) {
         lock( threadLock ) {
             feed.Enabled = false;
             feeds.Remove( feed );
         }
     }
 }
Example #5
0
 public List<Tweet> getTweets( Feed feed )
 {
     return feeds[feed];
 }
Example #6
0
 public Tweet getLastTweet( Feed feed )
 {
     return feeds[feed][0];
 }
Example #7
0
        public void addFeedConnection( Feed feed )
        {
            if( !feeds.ContainsKey( feed ) ) {
                lock( threadLock ) {
                    feed.Enabled = true;
                    feeds[feed] = new List<Tweet>( );
                }
            }

            if( !isFirstRun ) {
                loadFeed( feed );
                newTweet( feeds[feed][0], "Last Tweet:" );
            }
        }