Exemple #1
0
        internal void Initialize(River river)
        {
            AutoScrollSpeed          = Math.Abs(Settings.Default.AutoScrollSpeed);
            AutoScrollDirection      = Math.Sign(Settings.Default.AutoScrollDirection);
            IsProfanityFilterEnabled = Settings.Default.IsProfanityFilterEnabled;
            RetrievalOrder           = Settings.Default.RetrievalOrder;

            // Set up the FeedProcessor on a background thread.
            Thread thread = new Thread(() =>
            {
                ObservableCollection <string> flickrQuery = new ObservableCollection <string>(Split(Settings.Default.FlickrQuery.Trim()));
                Split(Settings.Default.FlickrBans.Trim()).ToList().ForEach(ban => flickrQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection <string> newsQuery = new ObservableCollection <string>(Split(Settings.Default.NewsQuery.Trim()));
                Split(Settings.Default.NewsBans.Trim()).ToList().ForEach(ban => newsQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection <string> twitterQuery = new ObservableCollection <string>(Split(Settings.Default.TwitterQuery.Trim()));
                Split(Settings.Default.TwitterBans.Trim()).ToList().ForEach(ban => twitterQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection <string> facebookQuery = new ObservableCollection <string>(Split(Settings.Default.FacebookQuery.Trim()));
                Split(Settings.Default.FacebookBans.Trim()).ToList().ForEach(ban => facebookQuery.Add(Processor.NegativeQueryMarker + ban));

                FeedProcessor = new FeedProcessor.Processor(
                    Settings.Default.FlickrApiKey,
                    Settings.Default.FacebookClientId,
                    Settings.Default.FacebookClientSecret,
                    Settings.Default.DisplayFbContentFromOthers,
                    Settings.Default.FlickrPollInterval,
                    Settings.Default.TwitterPollInterval,
                    Settings.Default.NewsPollInterval,
                    Settings.Default.FacebookPollInterval,
                    Settings.Default.MinFeedItemDate)
                {
                    Profanity = new ObservableCollection <string>(File.Exists("Profanity.txt") ? File.ReadAllLines("Profanity.txt") : new string[0]),
                    DistributeContentEvenly  = Settings.Default.DistributeContentEvenly,
                    IsProfanityFilterEnabled = IsProfanityFilterEnabled,
                    RetrievalOrder           = RetrievalOrder,
                    FlickrQuery   = flickrQuery,
                    NewsQuery     = newsQuery,
                    TwitterQuery  = twitterQuery,
                    FacebookQuery = facebookQuery
                };

                IsContentLoaded            = FeedProcessor.FeedCount == 0;
                var uiDisp                 = Dispatcher.CurrentDispatcher;
                FeedProcessor.CachePurged += (sender, e) => uiDisp.Invoke(new Action(() => { river.PurgeHistory(e.ValidData); }));
                FeedProcessor.FeedUpdated += FeedProcessor_FeedUpdated;

                IsInitialized = true;
                IsPaused      = false;

                // Cache the tag client, otherwise the first instance takes a while to start up.
                using (MicrosoftTagService.MIBPContractClient tagClient = new MicrosoftTagService.MIBPContractClient())
                {
                }
            });

            thread.Priority = ThreadPriority.Lowest;
            thread.Start();
        }
Exemple #2
0
        internal void Initialize(River river)
        {
            AutoScrollSpeed = Math.Abs(Settings.Default.AutoScrollSpeed);
            AutoScrollDirection = Math.Sign(Settings.Default.AutoScrollDirection);
            IsProfanityFilterEnabled = Settings.Default.IsProfanityFilterEnabled;
            RetrievalOrder = Settings.Default.RetrievalOrder;

            // Set up the FeedProcessor on a background thread.
            Thread thread = new Thread(() =>
            {
                ObservableCollection<string> flickrQuery = new ObservableCollection<string>(Split(Settings.Default.FlickrQuery.Trim()));
                Split(Settings.Default.FlickrBans.Trim()).ToList().ForEach(ban => flickrQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection<string> newsQuery = new ObservableCollection<string>(Split(Settings.Default.NewsQuery.Trim()));
                Split(Settings.Default.NewsBans.Trim()).ToList().ForEach(ban => newsQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection<string> twitterQuery = new ObservableCollection<string>(Split(Settings.Default.TwitterQuery.Trim()));
                Split(Settings.Default.TwitterBans.Trim()).ToList().ForEach(ban => twitterQuery.Add(Processor.NegativeQueryMarker + ban));

                ObservableCollection<string> facebookQuery = new ObservableCollection<string>(Split(Settings.Default.FacebookQuery.Trim()));
                Split(Settings.Default.FacebookBans.Trim()).ToList().ForEach(ban => facebookQuery.Add(Processor.NegativeQueryMarker + ban));

                FeedProcessor = new FeedProcessor.Processor(
                    Settings.Default.FlickrApiKey,
                    Settings.Default.FacebookClientId,
                    Settings.Default.FacebookClientSecret,
                    Settings.Default.DisplayFbContentFromOthers,
                    Settings.Default.FlickrPollInterval,
                    Settings.Default.TwitterPollInterval,
                    Settings.Default.NewsPollInterval,
                    Settings.Default.FacebookPollInterval,
                    Settings.Default.MinFeedItemDate)
                {
                    Profanity = new ObservableCollection<string>(File.Exists("Profanity.txt") ? File.ReadAllLines("Profanity.txt") : new string[0]),
                    DistributeContentEvenly = Settings.Default.DistributeContentEvenly,
                    IsProfanityFilterEnabled = IsProfanityFilterEnabled,
                    RetrievalOrder = RetrievalOrder,
                    FlickrQuery = flickrQuery,
                    NewsQuery = newsQuery,
                    TwitterQuery = twitterQuery,
                    FacebookQuery = facebookQuery
                };

                IsContentLoaded = FeedProcessor.FeedCount == 0;
                var uiDisp = Dispatcher.CurrentDispatcher;
                FeedProcessor.CachePurged += (sender, e) => uiDisp.Invoke(new Action(() => { river.PurgeHistory(e.ValidData); }));
                FeedProcessor.FeedUpdated += FeedProcessor_FeedUpdated;

                IsInitialized = true;
                IsPaused = false;

                // Cache the tag client, otherwise the first instance takes a while to start up.
                using (MicrosoftTagService.MIBPContractClient tagClient = new MicrosoftTagService.MIBPContractClient())
                {
                }
            });
            thread.Priority = ThreadPriority.Lowest;
            thread.Start();
        }