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>(); }
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(); }); }
public void Unbind() { Bound = false; lb.ManipulationStateChanged -= lb_ManipulationStateChanged; lb = null; resource = null; }
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; } }
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>(); }
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; }
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; }
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(); }
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; } }
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); }
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); }
public TweetLoader(TwitterResource resource, bool cached) : this() { Resource = resource; service = ServiceDispatcher.GetService(resource.User); conversationService = new ConversationService(resource.User); Cached = cached; }
public void ListMentions(int count, Action <TwitterObjectCollection, RestResponse> action) { TwitterResource resource = new TwitterResource { Type = ResourceType.Mentions }; GetStatuses(resource, count, action); }
private void RaiseCheckIfCanResumePosition(TwitterResource resource) { var temp = CheckIfCanResumePosition; if (temp != null) { temp(this, new BroadcastArgs(resource, false)); } }
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; }
private void SaveColumn(TwitterResource toAdd) { if (!Config.Columns.Contains(toAdd)) { Config.Columns.Add(toAdd); Config.SaveColumns(); DataTransfer.ShouldReloadColumns = true; } }
public void RaiseScrollToTop(TwitterResource resource) { var temp = ScrollToTop; if (temp != null) { temp(this, new BroadcastArgs(resource)); } }
private void RaiseReload(TwitterResource resource) { var temp = ReloadLists; if (temp != null) { temp(this, new BroadcastArgs(resource, false)); } }
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); }
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 } }); }
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; } }
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; } }
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); }
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; } }
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 } }; }
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); }
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 }
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); } }
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 }
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; } }
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(); }
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); } }); }
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)); }
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); }
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; }
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; }
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. }
public void GetStatuses(TwitterResource resource, int count, Action <TwitterObjectCollection, RestResponse> action) { _client.BeginRequest(TwitterResourceToRequest(resource, count), ReceiveStatuses, action); }
public void ListMessages(int count, Action<TwitterObjectCollection, RestResponse> action) { TwitterResource resource = new TwitterResource { Type = ResourceType.Messages }; GetStatuses(resource, count, action); }
private static string GetCacheName(TwitterResource resource) { string Key = "Cache" + RemoveSymbols(resource.String); return Key; }
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); }
public void RaiseScrollToTop(TwitterResource resource) { var temp = ScrollToTop; if (temp != null) temp(this, new BroadcastArgs(resource)); }
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); }
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)); }); }
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); }
public BroadcastArgs(TwitterResource resource, bool broadcastToAll = false) { Resource = resource; BroadcastAll = broadcastToAll; }
private void RaiseReload(TwitterResource resource) { var temp = ReloadLists; if (temp != null) temp(this, new BroadcastArgs(resource, false)); }
private void RaiseCheckIfCanResumePosition(TwitterResource resource) { var temp = CheckIfCanResumePosition; if (temp != null) temp(this, new BroadcastArgs(resource, false)); }
public TweetLoader(TwitterResource resource) : this(resource, true) { LoadCacheAsync(); }
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(); }
public abstract void CreateColumnTile(TwitterResource Resource);
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)); }); }
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(); }); }
public void GetStatuses(TwitterResource resource, int count, Action<TwitterObjectCollection, RestResponse> action) { _client.BeginRequest(TwitterResourceToRequest(resource, count), ReceiveStatuses, action); }
void NavigateToResource(TwitterResource resource) { ResourceViewModel.Resource = resource; Navigate(Uris.ResourceView); }