Example #1
0
        public static IEnumerable<TwitterStatus> GetFromCache(TwitterResource resource)
        {
            string fileName = GetCacheName(resource);
            var serializer = new SharpSerializer(SerializerSettings);

            IEnumerable<TwitterStatus> statuses = null;

            MutexUtil.DoWork("OCELL_FILE_MUTEX" + fileName, () =>
            {
                try
                {
                    using (var stream = FileAbstractor.GetFileStream(fileName))
                    {
                        if (stream.Length != 0)
                            statuses = serializer.Deserialize(stream) as IEnumerable<TwitterStatus>;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            });

            return statuses ?? new List<TwitterStatus>();
        }
Example #2
0
        private void CreateColumns(UserToken user)
        {
            TwitterResource Home = new TwitterResource {
                Type = ResourceType.Home, User = user
            };
            TwitterResource Mentions = new TwitterResource {
                Type = ResourceType.Mentions, User = user
            };
            TwitterResource Messages = new TwitterResource {
                Type = ResourceType.Messages, User = user
            };

            Deployment.Current.Dispatcher.InvokeIfRequired(() =>
            {
                if (!Config.Columns.Contains(Home))
                {
                    Config.Columns.Add(Home);
                }
                if (!Config.Columns.Contains(Mentions))
                {
                    Config.Columns.Add(Mentions);
                }
                if (!Config.Columns.Contains(Messages))
                {
                    Config.Columns.Add(Messages);
                }
                Config.SaveColumns();
            });
        }
Example #3
0
 public void Unbind()
 {
     Bound = false;
     lb.ManipulationStateChanged -= lb_ManipulationStateChanged;
     lb       = null;
     resource = null;
 }
Example #4
0
        protected void Load(TwitterResource resource)
        {
            var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);

            switch (resource.Type)
            {
                case ResourceType.Home:
                    service.ListTweetsOnHomeTimeline(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Mentions:
                    service.ListTweetsMentioningMe(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Messages:
                    service.ListDirectMessagesReceived(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Favorites:
                    service.ListFavoriteTweets((status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.List:
                    service.ListTweetsOnList(resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                            resource.Data.Substring(resource.Data.IndexOf('/') + 1), 1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Search:
                    service.Search(resource.Data, 1, 20, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Tweets:
                    service.ListTweetsOnSpecifiedUserTimeline(resource.Data, 1, true, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
            }
        }
Example #5
0
        public static IEnumerable<TwitterStatus> GetFromCache(TwitterResource resource)
        {
            string fileName = GetCacheName(resource);
            var serializer = new SharpSerializer(SerializerSettings);
            Mutex mutex = new Mutex(false, "OCELL_FILE_MUTEX" + fileName);
            IEnumerable<TwitterStatus> statuses = null;

            if (mutex.WaitOne(1000))
            {
                try
                {
                    using (var stream = FileAbstractor.GetFileStream(fileName))
                    {
                        statuses = serializer.Deserialize(stream) as IEnumerable<TwitterStatus>;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    mutex.ReleaseMutex();
                }
            }

            mutex.Dispose();
            return statuses ?? new List<TwitterStatus>();
        }
Example #6
0
        void Initialize()
        {
            CreateText(viewModel.Tweet);
            viewModel.Completed = true;

            if (DataTransfer.Status == null)
            {
                NavigationService.GoBack();
                return;
            }

            TwitterResource resource = new TwitterResource
            {
                Data = DataTransfer.Status.Id.ToString(),
                Type = ResourceType.Conversation,
                User = DataTransfer.CurrentAccount
            };

            if (conversation.Loader == null)
            {
                conversation.Loader = new TweetLoader(resource);
            }

            if (conversation.Loader.Resource != resource)
            {
                conversation.Loader.Source.Clear();
                conversation.Resource = resource;
            }

            conversation.Loader.Cached        = false;
            conversation.AutoManageNavigation = true;
        }
Example #7
0
 public static bool ColumnTileIsCreated(TwitterResource Resource)
 {
     ShellTile ColumnTile = ShellTile.ActiveTiles.FirstOrDefault(item => item != null
         && !string.IsNullOrWhiteSpace(item.NavigationUri.ToString()) &&
         item.NavigationUri.ToString().Contains(Uri.EscapeDataString(Resource.String)));
     return ColumnTile != null;
 }
 public void Bind(ExtendedListBox listbox)
 {
     lb = listbox;
     resource = listbox.Loader.Resource;
     lb.ManipulationStateChanged += lb_ManipulationStateChanged;
     Bound = true;
 }
Example #9
0
        public static void SaveToCache(TwitterResource resource, IEnumerable<TwitterStatus> list)
        {
            string fileName = GetCacheName(resource);

            var serializer = new SharpSerializer(SerializerSettings);
            Mutex mutex = new Mutex(false, "OCELL_FILE_MUTEX" + fileName);

            if (mutex.WaitOne(1000))
            {
                try
                {
                    using (var stream = FileAbstractor.GetFileStream(fileName))
                    {
                        serializer.Serialize(list.Distinct().OfType<TwitterStatus>().ToList(), stream);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    mutex.ReleaseMutex();
                }
            }

            mutex.Dispose();
        }
Example #10
0
        protected void Load(TwitterResource resource)
        {
            var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);

            switch (resource.Type)
            {
                case ResourceType.Home:
                    service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Mentions:
                    service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Messages:
                    service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Favorites:
                    service.ListFavoriteTweets(new ListFavoriteTweetsOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.List:
                    service.ListTweetsOnList(new ListTweetsOnListOptions
                    {
                        IncludeRts = false,
                        Count = 1,
                        OwnerScreenName = resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                        Slug = resource.Data.Substring(resource.Data.IndexOf('/') + 1)
                    }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Search:
                    service.Search(new SearchOptions { Count = 1, IncludeEntities = true, Q = resource.Data }, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Tweets:
                    service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 1, ScreenName = resource.Data, IncludeRts = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
            }
        }
Example #11
0
 public void Bind(ExtendedListBox listbox)
 {
     lb       = listbox;
     resource = listbox.Loader.Resource;
     lb.ManipulationStateChanged += lb_ManipulationStateChanged;
     Bound = true;
 }
Example #12
0
        public bool ColumnTileIsCreated(TwitterResource Resource)
        {
            ShellTile ColumnTile = ShellTile.ActiveTiles.FirstOrDefault(item => item != null &&
                                                                        !string.IsNullOrWhiteSpace(item.NavigationUri.ToString()) &&
                                                                        item.NavigationUri.ToString().Contains(Uri.EscapeDataString(Resource.String)));

            return(ColumnTile != null);
        }
Example #13
0
        public abstract void CreateComposeTile(); // Avoid Store complaints about "mehhh can't use ShellTile.Create in backgroundAgent"

        protected string GetTitle(TwitterResource Resource)
        {
            string title = Resource.Title.ToLowerInvariant();

            title = char.ToUpper(title[0]) + title.Substring(1);

            return(title);
        }
Example #14
0
 public TweetLoader(TwitterResource resource, bool cached)
     : this()
 {
     Resource = resource;
     service = ServiceDispatcher.GetService(resource.User);
     conversationService = new ConversationService(resource.User);
     Cached = cached;
 }
Example #15
0
        public void ListMentions(int count, Action <TwitterObjectCollection, RestResponse> action)
        {
            TwitterResource resource = new TwitterResource {
                Type = ResourceType.Mentions
            };

            GetStatuses(resource, count, action);
        }
Example #16
0
        private void RaiseCheckIfCanResumePosition(TwitterResource resource)
        {
            var temp = CheckIfCanResumePosition;

            if (temp != null)
            {
                temp(this, new BroadcastArgs(resource, false));
            }
        }
Example #17
0
        private static string GetTitle(TwitterResource Resource)
        {
            ListConverter Converter = new ListConverter();

            string Title = (string)Converter.Convert(Resource.String, null, null, null);
            Title = char.ToUpper(Title[0]) + Title.Substring(1);

            return Title;
        }
Example #18
0
 private void SaveColumn(TwitterResource toAdd)
 {
     if (!Config.Columns.Contains(toAdd))
     {
         Config.Columns.Add(toAdd);
         Config.SaveColumns();
         DataTransfer.ShouldReloadColumns = true;
     }
 }
Example #19
0
        public void RaiseScrollToTop(TwitterResource resource)
        {
            var temp = ScrollToTop;

            if (temp != null)
            {
                temp(this, new BroadcastArgs(resource));
            }
        }
Example #20
0
        private void RaiseReload(TwitterResource resource)
        {
            var temp = ReloadLists;

            if (temp != null)
            {
                temp(this, new BroadcastArgs(resource, false));
            }
        }
Example #21
0
        private static string GetTitle(TwitterResource Resource)
        {
            ListConverter Converter = new ListConverter();

            string Title = (string)Converter.Convert(Resource.String, null, null, null);

            Title = char.ToUpper(Title[0]) + Title.Substring(1);

            return(Title);
        }
Example #22
0
        public RestRequest TwitterResourceToRequest(TwitterResource resource, int count)
        {
            string path = "";

            switch (resource.Type)
            {
            case ResourceType.Favorites:
                path = "favorites.json";
                break;

            case ResourceType.Home:
                path = "statuses/home_timeline.json?count=" + count.ToString();
                break;

            case ResourceType.List:
                path = String.Format("lists/statuses.json?owner_screen_name={0}&slug={1}&per_page={2}",
                                     resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                                     resource.Data.Substring(resource.Data.IndexOf('/') + 1), count);
                break;

            case ResourceType.Mentions:
                path = "statuses/mentions.json?count=" + count.ToString();
                break;

            case ResourceType.Messages:
                path = "direct_messages.json?count=" + count.ToString();
                break;

            case ResourceType.Search:
                path = "search.json?q=" + resource.Data;
                break;

            case ResourceType.Tweets:
                path = "statuses/user_timeline.json?screen_name=" + resource.Data;
                break;

            default:
                throw new NotSupportedException("This resource is not supported");
            }

            return(new RestRequest
            {
                Path = path,
                Credentials = new OAuthCredentials
                {
                    Type = OAuthType.ProtectedResource,
                    SignatureMethod = OAuthSignatureMethod.HmacSha1,
                    ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                    ConsumerKey = _consumerToken,
                    ConsumerSecret = _consumerSecret,
                    Token = _userToken,
                    TokenSecret = _userSecret
                }
            });
        }
Example #23
0
        protected void Load(TwitterResource resource)
        {
            var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);

            switch (resource.Type)
            {
            case ResourceType.Home:
                service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions {
                    Count = 1, IncludeEntities = true
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.Mentions:
                service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions {
                    Count = 1, IncludeEntities = true
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.Messages:
                service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions {
                    Count = 1
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.Favorites:
                service.ListFavoriteTweets(new ListFavoriteTweetsOptions {
                    Count = 1
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.List:
                service.ListTweetsOnList(new ListTweetsOnListOptions
                {
                    IncludeRts      = false,
                    Count           = 1,
                    OwnerScreenName = resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                    Slug            = resource.Data.Substring(resource.Data.IndexOf('/') + 1)
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.Search:
                service.Search(new SearchOptions {
                    Count = 1, IncludeEntities = true, Q = resource.Data
                }, (status, response) => ReceiveTweetable(status.Statuses.Cast <ITweetable>(), response, resource));
                break;

            case ResourceType.Tweets:
                service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions {
                    Count = 1, ScreenName = resource.Data, IncludeRts = true
                }, (status, response) => ReceiveTweetable(status.Cast <ITweetable>(), response, resource));
                break;
            }
        }
Example #24
0
 void AddResource(TwitterResource resource)
 {
     if (Config.Columns.Contains(resource))
     {
         MessageService.ShowError(Localization.Resources.ColumnAlreadyPinned);
     }
     else if (MessageService.AskYesNoQuestion(String.Format(Localization.Resources.AskAddColumn, resource.Title)))
     {
         Config.Columns.Add(resource);
         Config.SaveColumns();
         DataTransfer.ShouldReloadColumns = true;
     }
 }
Example #25
0
        public static void CreateColumnTile(TwitterResource Resource)
        {
            if (Resource == null || ColumnTileIsCreated(Resource))
                return;

            StandardTileData ColumnTile = new StandardTileData
            {
                Title = GetTitle(Resource),
                BackgroundImage = new Uri("/Images/ColumnTile.png", UriKind.Relative)
            };

            Uri ColumnUri = new Uri("/MainPage.xaml?column=" + Uri.EscapeDataString(Resource.String), UriKind.Relative);

            ShellTile.Create(ColumnUri, ColumnTile);
        }
Example #26
0
 private void SetTag()
 {
     if (this.Tag != null && this.Tag is string)
     {
         Resource = new TwitterResource()
         {
             String = this.Tag as string
         }
     }
     ;
     else if (this.Tag is TwitterResource)
     {
         Resource = (TwitterResource)this.Tag;
     }
 }
Example #27
0
        public RestRequest TwitterResourceToRequest(TwitterResource resource, int count)
        {
            string path = "";
            switch (resource.Type)
            {
                case ResourceType.Favorites:
                    path = "favorites.json";
                    break;
                case ResourceType.Home:
                    path = "statuses/home_timeline.json?count=" + count.ToString();
                    break;
                case ResourceType.List:
                    path = String.Format("lists/statuses.json?owner_screen_name={0}&slug={1}&per_page={2}",
                        resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                                resource.Data.Substring(resource.Data.IndexOf('/') + 1), count);
                    break;
                case ResourceType.Mentions:
                    path = "statuses/mentions.json?count=" + count.ToString();
                    break;
                case ResourceType.Messages:
                    path = "direct_messages.json?count=" + count.ToString();
                    break;
                case ResourceType.Search:
                    path = "search.json?q=" + resource.Data;
                    break;
                case ResourceType.Tweets:
                    path = "statuses/user_timeline.json?screen_name=" + resource.Data;
                    break;
                default:
                    throw new NotSupportedException("This resource is not supported");
            }

            return new RestRequest
            {
                Path = path,
                Credentials = new OAuthCredentials
                            {
                                Type = OAuthType.ProtectedResource,
                                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                                ConsumerKey = _consumerToken,
                                ConsumerSecret = _consumerSecret,
                                Token = _userToken,
                                TokenSecret = _userSecret
                            }
            };
        }
Example #28
0
        public static void CreateColumnTile(TwitterResource Resource)
        {
            if (Resource == null || ColumnTileIsCreated(Resource))
            {
                return;
            }

            StandardTileData ColumnTile = new StandardTileData
            {
                Title           = GetTitle(Resource),
                BackgroundImage = new Uri("/Images/ColumnTile.png", UriKind.Relative)
            };

            Uri ColumnUri = new Uri("/MainPage.xaml?column=" + Uri.EscapeDataString(Resource.String), UriKind.Relative);

            ShellTile.Create(ColumnUri, ColumnTile);
        }
Example #29
0
        public override void CreateColumnTile(TwitterResource Resource)
        {
            #if !BACKGROUND_AGENT
            if (Resource == null || ColumnTileIsCreated(Resource))
                return;

            IconicTileData ColumnTile = new IconicTileData
            {
                Title = GetTitle(Resource),
                IconImage = new Uri("/Images/ColumnTile.png", UriKind.Relative)
            };

            Uri ColumnUri = new Uri("/MainPage.xaml?column=" + Uri.EscapeDataString(Resource.String), UriKind.Relative);

            ShellTile.Create(ColumnUri, ColumnTile);
            #endif
        }
Example #30
0
        public object Convert(object value, Type targeType, object parameter, CultureInfo culture)
        {
            if (value == null || !(value is TwitterResource))
            {
                return(Resources.Error);
            }

            TwitterResource resource = (TwitterResource)value;

            string listName     = "";
            int    indexOfSlash = resource.Data.IndexOf('/');

            if (indexOfSlash != -1)
            {
                listName = resource.Data.Substring(indexOfSlash + 1);
            }

            switch (resource.Type)
            {
            case ResourceType.Search:
                return(Resources.Search_CapitalFirst + "/" + resource.Data);

            case ResourceType.Tweets:
                return(Resources.User + "/@" + resource.Data);

            case ResourceType.List:
                return(Resources.Lists + "/" + listName);

            case ResourceType.Favorites:
                return(Resources.Favorites);

            case ResourceType.Home:
                return(Resources.Home);

            case ResourceType.Mentions:
                return(Resources.Mentions);

            case ResourceType.Messages:
                return(Resources.Messages);

            default:
                return(Resources.Error);
            }
        }
Example #31
0
        public override void CreateColumnTile(TwitterResource Resource)
        {
#if !BACKGROUND_AGENT
            if (Resource == null || ColumnTileIsCreated(Resource))
            {
                return;
            }

            IconicTileData ColumnTile = new IconicTileData
            {
                Title     = GetTitle(Resource),
                IconImage = new Uri("/Images/ColumnTile.png", UriKind.Relative)
            };

            Uri ColumnUri = new Uri("/MainPage.xaml?column=" + Uri.EscapeDataString(Resource.String), UriKind.Relative);

            ShellTile.Create(ColumnUri, ColumnTile);
#endif
        }
Example #32
0
        private void menuItemClick(object sender, EventArgs e)
        {
            MenuItem item = sender as MenuItem;

            if (item != null && item.Tag is TwitterResource)
            {
                TwitterResource resource = (TwitterResource)item.Tag;
                try
                {
                    Config.Columns.Remove(resource);
                }
                catch (Exception)
                {
                    return;
                }
                Config.SaveColumns();
                DataTransfer.ShouldReloadColumns = true;
            }
        }
Example #33
0
        void AddSelectedList()
        {
            var list = ListSelection as TwitterList;

            if (list == null)
            {
                return;
            }

            var toAdd = new TwitterResource
            {
                Type = ResourceType.List,
                Data = list.FullName,
                User = DataTransfer.CurrentAccount
            };

            SaveColumn(toAdd);
            ListSelection = null;
            GoBack();
        }
Example #34
0
        public static void SaveToCache(TwitterResource resource, IEnumerable<TwitterStatus> list)
        {
            string fileName = GetCacheName(resource);

            var serializer = new SharpSerializer(SerializerSettings);
            MutexUtil.DoWork("OCELL_FILE_MUTEX" + fileName, () =>
            {
                try
                {
                    using (var stream = FileAbstractor.GetFileStream(fileName))
                    {
                        serializer.Serialize(list.Distinct().OfType<TwitterStatus>().ToList(), stream);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            });
        }
Example #35
0
        public EnterSearchModel()
            : base("EnterSearch")
        {
            this.PropertyChanged += (sender, e) =>
            {
                buttonClick.RaiseCanExecuteChanged();
            };

            buttonClick = new DelegateCommand((obj) =>
                {
                    var resource = new TwitterResource
                    {
                        User = DataTransfer.CurrentAccount ?? Config.Accounts.FirstOrDefault(),
                        Type = ResourceType.Search,
                        Data = Query
                    };

                    ResourceViewModel.Resource = resource;
                    Navigate(Uris.ResourceView);
                }, (obj) => !string.IsNullOrWhiteSpace(Query));
        }
Example #36
0
        private void OnSelectionChanged()
        {
            TwitterTrend trend = ListSelection as TwitterTrend;

            if (trend == null)
            {
                return;
            }

            ListSelection = null;

            var resource = new TwitterResource
            {
                Data = trend.Name,
                Type = ResourceType.Search,
                User = DataTransfer.CurrentAccount
            };

            ResourceViewModel.Resource = resource;
            Navigate(Uris.ResourceView);
        }
Example #37
0
        public EnterSearchModel()
            : base("EnterSearch")
        {
            this.PropertyChanged += (sender, e) =>
            {
                buttonClick.RaiseCanExecuteChanged();
            };

            buttonClick = new DelegateCommand((obj) =>
            {
                var resource = new TwitterResource
                {
                    User = DataTransfer.CurrentAccount ?? Config.Accounts.FirstOrDefault(),
                    Type = ResourceType.Search,
                    Data = Query
                };

                ResourceViewModel.Resource = resource;
                Navigate(Uris.ResourceView);
            }, (obj) => !string.IsNullOrWhiteSpace(Query));
        }
Example #38
0
        void DMConversation_Loaded(object sender, RoutedEventArgs e)
        {
            if (DataTransfer.DMGroup == null)
            {
                NavigationService.GoBack();
                return;
            }

            List.Loader.Source.BulkAdd(DataTransfer.DMGroup.Messages.Cast<ITweetable>());

            string pairName = DataTransfer.DMGroup.Messages.First().GetPairName(DataTransfer.CurrentAccount);

            TwitterResource resource = new TwitterResource
            {
                Type = ResourceType.MessageConversation,
                User = DataTransfer.CurrentAccount,
                Data = pairName
            };

            List.Loader.Resource = resource;
            viewModel.PairName = pairName;
        }
Example #39
0
        void DMConversation_Loaded(object sender, RoutedEventArgs e)
        {
            if (DataTransfer.DMGroup == null)
            {
                NavigationService.GoBack();
                return;
            }

            List.Loader.Source.BulkAdd(DataTransfer.DMGroup.Messages.Cast <ITweetable>());

            string pairName = DataTransfer.DMGroup.Messages.First().GetPairName(DataTransfer.CurrentAccount);

            TwitterResource resource = new TwitterResource
            {
                Type = ResourceType.MessageConversation,
                User = DataTransfer.CurrentAccount,
                Data = pairName
            };

            List.Loader.Resource = resource;
            viewModel.PairName   = pairName;
        }
Example #40
0
        public static void SetupFilter(ExtendedListBox listbox)
        {
            if (listbox == null || listbox.Loader == null)
            {
                return;
            }

            TwitterResource resource = listbox.Resource;

            ColumnFilter filter = Config.Filters.FirstOrDefault(item => item.Resource == resource);

            if (filter != null)
            {
                filter.CleanOldFilters();
                listbox.Filter = filter;
            }
            else
            {
                listbox.Filter = new ColumnFilter();
            }

            listbox.Filter.Global = Config.GlobalFilter;
            listbox.Filter        = listbox.Filter; // Force update of filter.
        }
Example #41
0
 public void GetStatuses(TwitterResource resource, int count, Action <TwitterObjectCollection, RestResponse> action)
 {
     _client.BeginRequest(TwitterResourceToRequest(resource, count), ReceiveStatuses, action);
 }
Example #42
0
 public void ListMessages(int count, Action<TwitterObjectCollection, RestResponse> action)
 {
     TwitterResource resource = new TwitterResource { Type = ResourceType.Messages };
     GetStatuses(resource, count, action);
 }
Example #43
0
 private static string GetCacheName(TwitterResource resource)
 {
     string Key = "Cache" + RemoveSymbols(resource.String);
     return Key;
 }
Example #44
0
        protected void ReceiveTweetable(IEnumerable <ITweetable> statuses, TwitterResponse response, TwitterResource Resource)
        {
            WriteMemUsage("Received tweet for column.");
            if (statuses == null || !statuses.Any() || response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                WriteMemUsage("Exit with error");
                return;
            }

            string     tileString = Uri.EscapeDataString(Resource.String);
            ITweetable tweet      = statuses.FirstOrDefault();

            TileManager.SetColumnTweet(tileString, tweet.CleanText, tweet.AuthorName);
        }
Example #45
0
 public void RaiseScrollToTop(TwitterResource resource)
 {
     var temp = ScrollToTop;
     if (temp != null)
         temp(this, new BroadcastArgs(resource));
 }
Example #46
0
        private void OnSelectionChanged()
        {
            TwitterTrend trend = ListSelection as TwitterTrend;

            if (trend == null)
                return;

            ListSelection = null;

            var resource = new TwitterResource
               {
                   Data = trend.Name,
                   Type = ResourceType.Search,
                   User = DataTransfer.CurrentAccount
               };
            ResourceViewModel.Resource = resource;
            Navigate(Uris.ResourceView);
        }
Example #47
0
        private void ListBox_Loaded(object sender, RoutedEventArgs e)
        {
            ExtendedListBox list = sender as ExtendedListBox;
            if (list == null)
                return;
            var tag = list.Tag;

            ThreadPool.QueueUserWorkItem((threadcontext) =>
            {
                TwitterResource Resource = new TwitterResource();

                if (tag is TwitterResource)
                {
                    Resource = (TwitterResource)tag;
                    list.Resource = Resource;
                }

                Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list));

                list.Loader.ActivateLoadMoreButton = true;
                list.Loader.TweetsToLoadPerRequest = (int)Config.TweetsPerRequest;
                list.Loader.LoadRetweetsAsMentions = (bool)Config.RetweetAsMentions;

                list.Loader.PropertyChanged += (sender1, e1) =>
                {
                    if (e1.PropertyName == "IsLoading")
                    {
                        if (list.Loader.IsLoading)
                            viewModel.LoadingCount++;
                        else
                            viewModel.LoadingCount--;
                    }
                };

                viewModel.ScrollToTop += (sender1, e1) =>
                {
                    if (e1.BroadcastAll || e1.Resource == Resource)
                        list.ScrollToTop();
                };

                viewModel.ReloadLists += (sender1, e1) =>
                {
                    if (e1.BroadcastAll || e1.Resource == Resource)
                        ThreadPool.QueueUserWorkItem((context) => list.AutoReload());
                };

                viewModel.CheckIfCanResumePosition += (sender1, e1) =>
                {
                    if (e1.Resource == list.Loader.Resource && Config.ReloadOptions == ColumnReloadOptions.AskPosition)
                        list.TryTriggerResumeReading();
                };

                list.ReadyToResumePosition += (sender1, e1) =>
                {
                    var selectedPivot = (TwitterResource)viewModel.SelectedPivot;
                    if (list.Loader.Resource == selectedPivot)
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            long id;
                            if (Config.ReadPositions.TryGetValue(selectedPivot.String, out id)
                                && !list.VisibleItems.Any(x => x.Id == id))
                            {
                                ShowResumePositionPrompt(list);
                            }
                        });
                    }
                };

                list.Loader.LoadCacheAsync();

                list.AutoReload();

                Dispatcher.BeginInvoke(() =>
                {
                    list.Loaded -= ListBox_Loaded;
                    list.Loaded += new RoutedEventHandler(CheckForFilterUpdate);
                });

                GlobalEvents.FiltersChanged += (sender1, e1) => Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list));
            });
        }
Example #48
0
 private void SaveColumn(TwitterResource toAdd)
 {
     if (!Config.Columns.Contains(toAdd))
     {
         Config.Columns.Add(toAdd);
         Config.SaveColumns();
         DataTransfer.ShouldReloadColumns = true;
     }
 }
Example #49
0
        protected void ReceiveTweetable(IEnumerable<ITweetable> statuses, TwitterResponse response, TwitterResource Resource)
        {
            WriteMemUsage("Received tweet for column.");
            if (statuses == null || !statuses.Any() || response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                WriteMemUsage("Exit with error");
                return;
            }

            string tileString = Uri.EscapeDataString(Resource.String);
            ITweetable tweet = statuses.FirstOrDefault();

            TileManager.SetColumnTweet(tileString, tweet.CleanText, tweet.AuthorName);
        }
Example #50
0
 public BroadcastArgs(TwitterResource resource, bool broadcastToAll = false)
 {
     Resource = resource;
     BroadcastAll = broadcastToAll;
 }
Example #51
0
 private void RaiseReload(TwitterResource resource)
 {
     var temp = ReloadLists;
     if (temp != null)
         temp(this, new BroadcastArgs(resource, false));
 }
Example #52
0
 private void RaiseCheckIfCanResumePosition(TwitterResource resource)
 {
     var temp = CheckIfCanResumePosition;
     if (temp != null)
         temp(this, new BroadcastArgs(resource, false));
 }
Example #53
0
 public TweetLoader(TwitterResource resource)
     : this(resource, true)
 {
     LoadCacheAsync();
 }
Example #54
0
        void AddSelectedList()
        {
            var list = ListSelection as TwitterList;
            if (list == null)
                return;

            var toAdd = new TwitterResource
            {
                Type = ResourceType.List,
                Data = list.FullName,
                User = DataTransfer.CurrentAccount
            };

            SaveColumn(toAdd);
            ListSelection = null;
            GoBack();
        }
Example #55
0
 public abstract void CreateColumnTile(TwitterResource Resource);
Example #56
0
        void Initialize()
        {
            CreateText(viewModel.Tweet);
            viewModel.Completed = true;

            if (DataTransfer.Status == null)
            {
                NavigationService.GoBack();
                return;
            }

            TwitterResource resource = new TwitterResource
            {
                Data = DataTransfer.Status.Id.ToString(),
                Type = ResourceType.Conversation,
                User = DataTransfer.CurrentAccount
            };

            if (conversation.Loader == null)
            {
                conversation.Loader = new TweetLoader(resource);
            }

            if (conversation.Loader.Resource != resource)
            {
                conversation.Loader.Source.Clear();
                conversation.Resource = resource;
            }

            conversation.Loader.Cached = false;
            conversation.AutoManageNavigation = true;
        }
Example #57
0
        private void ListBox_Loaded(object sender, RoutedEventArgs e)
        {
            ExtendedListBox list = sender as ExtendedListBox;

            if (list == null)
            {
                return;
            }
            var tag = list.Tag;

            ThreadPool.QueueUserWorkItem((threadcontext) =>
            {
                TwitterResource Resource = new TwitterResource();

                if (tag is TwitterResource)
                {
                    Resource      = (TwitterResource)tag;
                    list.Resource = Resource;
                }

                Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list));

                list.Loader.ActivateLoadMoreButton = true;
                list.Loader.TweetsToLoadPerRequest = (int)Config.TweetsPerRequest;
                list.Loader.LoadRetweetsAsMentions = (bool)Config.RetweetAsMentions;

                list.Loader.PropertyChanged += (sender1, e1) =>
                {
                    if (e1.PropertyName == "IsLoading")
                    {
                        if (list.Loader.IsLoading)
                        {
                            viewModel.LoadingCount++;
                        }
                        else
                        {
                            viewModel.LoadingCount--;
                        }
                    }
                };

                viewModel.ScrollToTop += (sender1, e1) =>
                {
                    if (e1.BroadcastAll || e1.Resource == Resource)
                    {
                        list.ScrollToTop();
                    }
                };

                viewModel.ReloadLists += (sender1, e1) =>
                {
                    if (e1.BroadcastAll || e1.Resource == Resource)
                    {
                        ThreadPool.QueueUserWorkItem((context) => list.AutoReload());
                    }
                };

                viewModel.CheckIfCanResumePosition += (sender1, e1) =>
                {
                    if (e1.Resource == list.Loader.Resource && Config.ReloadOptions == ColumnReloadOptions.AskPosition)
                    {
                        list.TryTriggerResumeReading();
                    }
                };

                list.ReadyToResumePosition += (sender1, e1) =>
                {
                    var selectedPivot = (TwitterResource)viewModel.SelectedPivot;
                    if (list.Loader.Resource == selectedPivot)
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            long id;
                            if (Config.ReadPositions.TryGetValue(selectedPivot.String, out id) &&
                                !list.VisibleItems.Any(x => x.Id == id))
                            {
                                ShowResumePositionPrompt(list);
                            }
                        });
                    }
                };

                list.Loader.LoadCacheAsync();

                list.AutoReload();

                Dispatcher.BeginInvoke(() =>
                {
                    list.Loaded -= ListBox_Loaded;
                    list.Loaded += new RoutedEventHandler(CheckForFilterUpdate);
                });

                GlobalEvents.FiltersChanged += (sender1, e1) => Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list));
            });
        }
Example #58
0
 private void CreateColumns(UserToken user)
 {
     TwitterResource Home = new TwitterResource { Type = ResourceType.Home, User = user };
     TwitterResource Mentions = new TwitterResource { Type = ResourceType.Mentions, User = user };
     TwitterResource Messages = new TwitterResource { Type = ResourceType.Messages, User = user };
     Deployment.Current.Dispatcher.InvokeIfRequired(() =>
     {
         if (!Config.Columns.Contains(Home))
             Config.Columns.Add(Home);
         if (!Config.Columns.Contains(Mentions))
             Config.Columns.Add(Mentions);
         if (!Config.Columns.Contains(Messages))
             Config.Columns.Add(Messages);
         Config.SaveColumns();
     });
 }
Example #59
0
 public void GetStatuses(TwitterResource resource, int count, Action<TwitterObjectCollection, RestResponse> action)
 {
     _client.BeginRequest(TwitterResourceToRequest(resource, count), ReceiveStatuses, action);
 }
Example #60
0
 void NavigateToResource(TwitterResource resource)
 {
     ResourceViewModel.Resource = resource;
     Navigate(Uris.ResourceView);
 }