public FlipViewPostContext(IPanelHost host, PostCollector collector, Post post, string targetComment) { Post = post; Collector = collector; Host = host; TargetComment = targetComment; }
public async void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { // Capture the host m_host = host; Subreddit subreddit = null; if (arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_NAME)) { // Try to get the subreddit locally subreddit = App.BaconMan.SubredditMan.GetSubredditByDisplayName((string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]); // If that failed try to get it from the web if (subreddit == null) { // Show the loading UI ShowFullScreenLoading(); // Try to get the subreddit from the web subreddit = await App.BaconMan.SubredditMan.GetSubredditFromWebByDisplayName((string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]); // Hide the loading UI // The loading ring will be set inactive by the animation complete HideFullScreenLoading(); } } if (subreddit == null) { // Hmmmm. We can't load the subreddit. Show a message and go back ShowFullScreenLoading(); App.BaconMan.MessageMan.ShowMessageSimple("Hmmm, That's Not Right", "We can't load this subreddit right now, check your Internet connection."); // We can't call go back with navigating, so use the dispatcher to make a delayed call. await Task.Run(async() => { // We need to wait some time until the transition animation is done or we can't go back. await Task.Delay(500); // Try to go back now. await global::Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { m_host.GoBack(); }); }); // Get out of here. return; } // Get the sort type SortTypes sortType = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT) ? (SortTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT] : App.BaconMan.UiSettingsMan.SubredditList_DefaultSortType; SortTimeTypes postSortTime = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME) ? (SortTimeTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME] : App.BaconMan.UiSettingsMan.SubredditList_DefaultSortTimeType; // Do the rest of the setup SetupPage(subreddit, sortType, postSortTime); }
public async void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { // Capture the host m_host = host; Subreddit subreddit = null; if (arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_NAME)) { // Try to get the subreddit locally subreddit = App.BaconMan.SubredditMan.GetSubredditByDisplayName((string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]); // If that failed try to get it from the web if(subreddit == null) { // Show the loading UI ShowFullScreenLoading(); // Try to get the subreddit from the web subreddit = await App.BaconMan.SubredditMan.GetSubredditFromWebByDisplayName((string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]); // Hide the loading UI // The loading ring will be set inactive by the animation complete HideFullScreenLoading(); } } if(subreddit == null) { // Hmmmm. We can't load the subreddit. Show a message and go back ShowFullScreenLoading(); App.BaconMan.MessageMan.ShowMessageSimple("Hmmm, That's Not Right", "We can't load this subreddit right now, check your Internet connection."); // We can't call go back with navigating, so use the dispatcher to make a delayed call. await Task.Run(async () => { // We need to wait some time until the transition animation is done or we can't go back. await Task.Delay(500); // Try to go back now. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { m_host.GoBack(); }); }); // Get out of here. return; } // Get the sort type SortTypes sortType = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT) ? (SortTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT] : App.BaconMan.UiSettingsMan.SubredditList_DefaultSortType; SortTimeTypes postSortTime = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME) ? (SortTimeTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME] : App.BaconMan.UiSettingsMan.SubredditList_DefaultSortTimeType; // Do the rest of the setup SetupPage(subreddit, sortType, postSortTime); }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { m_panelManager = host; // If we get passed a search term search it right away. if(arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_QUERY)) { ui_searchBox.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_QUERY]; Search_Tapped(null, null); } }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { m_panelManager = host; // If we get passed a search term search it right away. if (arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_QUERY)) { ui_searchBox.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_QUERY]; Search_Tapped(null, null); } }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { m_host = host; // Set the text is we were passed it if (arguments.ContainsKey(PanelManager.NAV_ARGS_SUBMIT_POST_SUBREDDIT)) { ui_subredditSuggestBox.Text = (string)arguments[PanelManager.NAV_ARGS_SUBMIT_POST_SUBREDDIT]; } // Resigner for back presses App.BaconMan.OnBackButton += BaconMan_OnBackButton; }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { _mHost = host; // Set the text is we were passed it if (arguments.ContainsKey(PanelManager.NavArgsSubmitPostSubreddit)) { ui_subredditSuggestBox.Text = (string)arguments[PanelManager.NavArgsSubmitPostSubreddit]; } // Resigner for back presses App.BaconMan.OnBackButton += BaconMan_OnBackButton; }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { m_host = host; // Set the text is we were passed it if (arguments.ContainsKey(PanelManager.NAV_ARGS_SUBMIT_POST_SUBREDDIT)) { ui_subredditSuggestBox.Text = (string)arguments[PanelManager.NAV_ARGS_SUBMIT_POST_SUBREDDIT]; } // Resigner for back presses App.BaconMan.OnBackButton += BaconMan_OnBackButton; }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { // Grab the panel manager m_panelHost = host; // Make a new collector m_collector = new MessageCollector(App.BaconMan); // Sub to the collector callbacks m_collector.OnCollectionUpdated += Collector_OnCollectionUpdated; m_collector.OnCollectorStateChange += Collector_OnCollectorStateChange; // Ask the collector to update m_collector.Update(); }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { // Grab the panel manager m_panelHost = host; // Make a new collector m_collector = new MessageCollector(App.BaconMan); // Sub to the collector callbacks m_collector.OnCollectionUpdated += Collector_OnCollectionUpdated; m_collector.OnCollectorStateChange += Collector_OnCollectorStateChange; // Ask the collector to update m_collector.Update(); }
/// <summary> /// Fired when we should show a subreddit. /// </summary> /// <param name="subreddit"></param> public void SetSubreddit(IPanelHost host, Subreddit subreddit) { // Capture host m_host = host; // Make sure we don't already have it. if (m_currentSubreddit != null && m_currentSubreddit.Id.Equals(subreddit.Id)) { // Update the buttons SetSubButton(); SetSearchButton(); SetPinButton(); // Scroll the scroller to the top ui_contentRoot.ChangeView(null, 0, null, true); return; } // Set the current subreddit m_currentSubreddit = subreddit; // Set the title ui_titleTextBlock.Text = m_currentSubreddit.DisplayName; // Set the subs, if the value doesn't exist or the subreddit is fake make it "many" if (m_currentSubreddit.SubscriberCount.HasValue && !m_currentSubreddit.IsArtifical) { ui_subscribersTextBlock.Text = String.Format("{0:N0}", m_currentSubreddit.SubscriberCount) + " subscribers"; } else { ui_subscribersTextBlock.Text = "many subscribers"; } // Set the subscribe button SetSubButton(); SetPinButton(); SetSearchButton(); // Set the markdown SetMarkdown(); }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { m_panelManager = host; // If we get passed a search term search it right away. if(arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_QUERY)) { ui_searchBox.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_QUERY]; Search_Tapped(null, null); } else if (arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_SUBREDDIT_NAME)) { // We are opened from the side bar, set the subreddit name and go to post mode. // Set to post mode ui_searchForCombo.SelectedIndex = 3; // Fill out the subreddit name ui_postSubreddit.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_SUBREDDIT_NAME]; } }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { _mPanelManager = host; // If we get passed a search term search it right away. if (arguments.ContainsKey(PanelManager.NavArgsSearchQuery)) { ui_searchBox.Text = (string)arguments[PanelManager.NavArgsSearchQuery]; Search_Tapped(null, null); } else if (arguments.ContainsKey(PanelManager.NavArgsSearchSubredditName)) { // We are opened from the side bar, set the subreddit name and go to post mode. // Set to post mode ui_searchForCombo.SelectedIndex = 3; // Fill out the subreddit name ui_postSubreddit.Text = (string)arguments[PanelManager.NavArgsSearchSubredditName]; } }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { m_panelManager = host; // If we get passed a search term search it right away. if (arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_QUERY)) { ui_searchBox.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_QUERY]; Search_Tapped(null, null); } else if (arguments.ContainsKey(PanelManager.NAV_ARGS_SEARCH_SUBREDDIT_NAME)) { // We are opened from the side bar, set the subreddit name and go to post mode. // Set to post mode ui_searchForCombo.SelectedIndex = 3; // Fill out the subreddit name ui_postSubreddit.Text = (string)arguments[PanelManager.NAV_ARGS_SEARCH_SUBREDDIT_NAME]; } }
public FlipViewPostItem(IPanelHost host, PostCollector collector, Post post, string targetComment) { Context = new FlipViewPostContext(host, collector, post, targetComment); IsVisible = false; }
/// <summary> /// Fired when the panel is being created. /// </summary> /// <param name="host">A reference to the host.</param> /// <param name="arguments">Arguments for the panel</param> public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { // Capture the host m_host = host; // Check for the subreddit arg if (!arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_NAME)) { throw new Exception("No subreddit was given!"); } string subredditName = (string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]; // Kick off a background task to do the work Task.Run(async () => { // Try to get the subreddit from the local cache. Subreddit subreddit = App.BaconMan.SubredditMan.GetSubredditByDisplayName(subredditName); // It is very rare that we can't get it from the cache because something // else usually request it from the web and then it will be cached. if (subreddit == null) { // Since this can take some time, show the loading overlay ShowFullScreenLoading(); // Try to get the subreddit from the web subreddit = await App.BaconMan.SubredditMan.GetSubredditFromWebByDisplayName((string)arguments[PanelManager.NAV_ARGS_SUBREDDIT_NAME]); } // Check again. if (subreddit == null) { // Hmmmm. We can't load the subreddit. Show a message and go back App.BaconMan.MessageMan.ShowMessageSimple("Hmmm, That's Not Right", "We can't load this subreddit right now, check your Internet connection."); // We need to wait some time until the transition animation is done or we can't go back. // If we call GoBack while we are still navigating it will be ignored. await Task.Delay(1000); // Now try to go back. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { m_host.GoBack(); }); // Get out of here. return; } // Capture the subreddit m_subreddit = subreddit; // Get the current sort m_currentSort = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT) ? (SortTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT] : SortTypes.Hot; // Get the current sort time m_currentSortTime = arguments.ContainsKey(PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME) ? (SortTimeTypes)arguments[PanelManager.NAV_ARGS_SUBREDDIT_SORT_TIME] : SortTimeTypes.Week; // Try to get the target post id if (arguments.ContainsKey(PanelManager.NAV_ARGS_POST_ID)) { m_targetPost = (string)arguments[PanelManager.NAV_ARGS_POST_ID]; } // Try to get the force post, this will make us show only one post for the subreddit, // which is the post given. string forcePostId = null; if (arguments.ContainsKey(PanelManager.NAV_ARGS_FORCE_POST_ID)) { forcePostId = (string)arguments[PanelManager.NAV_ARGS_FORCE_POST_ID]; // If the UI isn't already shown show the loading UI. Most of the time this post wont' be cached // so it can take some time to load. ShowFullScreenLoading(); } // See if we are targeting a comment if (arguments.ContainsKey(PanelManager.NAV_ARGS_FORCE_COMMENT_ID)) { m_targetComment = (string)arguments[PanelManager.NAV_ARGS_FORCE_COMMENT_ID]; } // Get the collector and register for updates. m_collector = PostCollector.GetCollector(m_subreddit, App.BaconMan, m_currentSort, m_currentSortTime, forcePostId); m_collector.OnCollectionUpdated += Collector_OnCollectionUpdated; // Kick off an update of the subreddits if needed. m_collector.Update(); // Set any posts that exist right now UpdatePosts(0, m_collector.GetCurrentPosts()); }); }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { m_host = host; }
/// <summary> /// Fired when the panel is being created. /// </summary> /// <param name="host">A reference to the host.</param> /// <param name="arguments">Arguments for the panel</param> public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { // Capture the host _host = host; // Check for the subreddit arg if (!arguments.ContainsKey(PanelManager.NavArgsSubredditName)) { throw new Exception("No subreddit was given!"); } var subredditName = (string)arguments[PanelManager.NavArgsSubredditName]; // Kick off a background task to do the work Task.Run(async() => { // Try to get the subreddit from the local cache. var subreddit = App.BaconMan.SubredditMan.GetSubredditByDisplayName(subredditName); // It is very rare that we can't get it from the cache because something // else usually request it from the web and then it will be cached. if (subreddit == null) { // Since this can take some time, show the loading overlay ShowFullScreenLoading(); // Try to get the subreddit from the web subreddit = await App.BaconMan.SubredditMan.GetSubredditFromWebByDisplayName((string)arguments[PanelManager.NavArgsSubredditName]); } // Check again. if (subreddit == null) { // Hmmmm. We can't load the subreddit. Show a message and go back App.BaconMan.MessageMan.ShowMessageSimple("Hmmm, That's Not Right", "We can't load this subreddit right now, check your Internet connection."); // We need to wait some time until the transition animation is done or we can't go back. // If we call GoBack while we are still navigating it will be ignored. await Task.Delay(1000); // Now try to go back. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { _host.GoBack(); }); // Get out of here. return; } // Capture the subreddit _subreddit = subreddit; // Get the current sort _currentSort = arguments.ContainsKey(PanelManager.NavArgsSubredditSort) ? (SortTypes)arguments[PanelManager.NavArgsSubredditSort] : SortTypes.Hot; // Get the current sort time _currentSortTime = arguments.ContainsKey(PanelManager.NavArgsSubredditSortTime) ? (SortTimeTypes)arguments[PanelManager.NavArgsSubredditSortTime] : SortTimeTypes.Week; // Try to get the target post id if (arguments.ContainsKey(PanelManager.NavArgsPostId)) { _targetPost = (string)arguments[PanelManager.NavArgsPostId]; } // Try to get the force post, this will make us show only one post for the subreddit, // which is the post given. string forcePostId = null; if (arguments.ContainsKey(PanelManager.NavArgsForcePostId)) { forcePostId = (string)arguments[PanelManager.NavArgsForcePostId]; // If the UI isn't already shown show the loading UI. Most of the time this post wont' be cached // so it can take some time to load. ShowFullScreenLoading(); } // See if we are targeting a comment if (arguments.ContainsKey(PanelManager.NavArgsForceCommentId)) { _targetComment = (string)arguments[PanelManager.NavArgsForceCommentId]; } // Get the collector and register for updates. _collector = PostCollector.GetCollector(_subreddit, App.BaconMan, _currentSort, _currentSortTime, forcePostId); _collector.OnCollectionUpdated += Collector_OnCollectionUpdated; // Kick off an update of the subreddits if needed. _collector.Update(); // Set any posts that exist right now UpdatePosts(0, _collector.GetCurrentPosts()); }); }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { m_host = host; }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { _mHost = host; if (!arguments.ContainsKey(PanelManager.NavArgsUserName)) { ReportUserLoadFailed(); return; } // Get the user var userName = (string)arguments[PanelManager.NavArgsUserName]; ui_userName.Text = userName; // Show loading ui_loadingOverlay.Show(true, "Finding " + userName); // Do the loading on a thread to get off the UI Task.Run(async() => { // Make the request _mUser = await MiscellaneousHelper.GetRedditUser(App.BaconMan, userName); // Jump back to the UI thread, we will use low priority so we don't make any animations choppy. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { // Check we got it. if (_mUser == null) { ReportUserLoadFailed(); return; } // Fill in the UI var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); var postTime = origin.AddSeconds(_mUser.CreatedUtc).ToLocalTime(); ui_accountAgeText.Text = $"{TimeToTextHelper.TimeElapseToText(postTime)} old"; // Set cake day var elapsed = DateTime.Now - postTime; var fullYears = Math.Floor((elapsed.TotalDays / 365)); var daysUntil = (int)(elapsed.TotalDays - (fullYears * 365)); ui_cakeDayHolder.Visibility = daysUntil == 0 ? Visibility.Visible : Visibility.Collapsed; // Set karma ui_linkKarmaText.Text = $"{_mUser.LinkKarma:N0}"; ui_commentKarmaText.Text = $"{_mUser.CommentKarma:N0}"; // Set Gold ui_goldHolder.Visibility = _mUser.IsGold ? Visibility.Visible : Visibility.Collapsed; // Hide loading ui_loadingOverlay.Hide(); // Kick off the updates GetUserComments(); GetUserPosts(); }); }); }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { // Ignore }
public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments) { m_host = host; if(!arguments.ContainsKey(PanelManager.NAV_ARGS_USER_NAME)) { ReportUserLoadFailed(); return; } // Get the user string userName = (string)arguments[PanelManager.NAV_ARGS_USER_NAME]; ui_userName.Text = userName; // Show loading ui_loadingOverlay.Show(true, "Finding "+ userName); // Do the loading on a thread to get off the UI Task.Run(async () => { // Make the request m_user = await MiscellaneousHelper.GetRedditUser(App.BaconMan, userName); // Jump back to the UI thread, we will use low priority so we don't make any animations choppy. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { // Check we got it. if (m_user == null) { ReportUserLoadFailed(); return; } // Fill in the UI DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime postTime = origin.AddSeconds(m_user.CreatedUtc).ToLocalTime(); ui_accountAgeText.Text = $"{TimeToTextHelper.TimeElapseToText(postTime)} old"; // Set cake day TimeSpan elapsed = DateTime.Now - postTime; double fullYears = Math.Floor((elapsed.TotalDays / 365)); int daysUntil = (int)(elapsed.TotalDays - (fullYears * 365)); ui_cakeDayHolder.Visibility = daysUntil == 0 ? Visibility.Visible : Visibility.Collapsed; // Set karma ui_linkKarmaText.Text = String.Format("{0:N0}", m_user.LinkKarma); ui_commentKarmaText.Text = String.Format("{0:N0}", m_user.CommentKarma); // Set Gold ui_goldHolder.Visibility = m_user.IsGold ? Visibility.Visible : Visibility.Collapsed; // Hide loading ui_loadingOverlay.Hide(); // Kick off the updates GetUserComments(); GetUserPosts(); }); }); }
public void PanelSetup(IPanelHost host, Dictionary <string, object> arguments) { // Ignore }