private void MarkdownText_OnMarkdownLinkTapped(object sender, UniversalMarkdown.OnMarkdownLinkTappedArgs e) { try { // See if what we have is a reddit link RedditContentContainer redditContent = MiscellaneousHelper.TryToFindRedditContentInLink(e.Link); if (redditContent != null && redditContent.Type != RedditContentType.Website) { // If we are opening a reddit link show the content and hide hide the message. App.BaconMan.ShowGlobalContent(redditContent); // Hide the box Close_OnIconTapped(null, null); } else { // If we have a link show it but don't close the message. App.BaconMan.ShowGlobalContent(e.Link); } } catch (Exception ex) { App.BaconMan.TelemetryMan.ReportUnexpectedEvent(this, "MOTDLinkFailedToOpen", ex); App.BaconMan.MessageMan.DebugDia("MOTDLinkFailedToOpen", ex); } }
/// <summary> /// Fired when we should load the content. /// </summary> public async void OnPrepareContent() { // Defer so we give the UI time to work. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { var headerText = ""; var minorText = ""; if (_contentPanelBase.Source.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { _content = MiscellaneousHelper.TryToFindRedditContentInLink(_contentPanelBase.Source.Url); switch (_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.User: headerText = "This post links to a reddit user page"; minorText = $"Tap anywhere to view {_content.User}"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); TelemetryManager.ReportUnexpectedEvent(this, "GotWebsiteOnPrepareRedditContent"); break; default: throw new ArgumentOutOfRangeException(); } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; // Hide loading _contentPanelBase.FireOnLoading(false); }); }
/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public async void OnPrepareContent() { // Defer so we give the UI time to work. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { string headerText = ""; string minorText = ""; if (m_base.Source.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(m_base.Source.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.User: headerText = "This post links to a reddit user page"; minorText = $"Tap anywhere to view {m_content.User}"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; // Hide loading m_base.FireOnLoading(false); }); }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); if (container != null) { ShowGlobalContent(container); } else { ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Called by the host when it queries if we can handle a post. /// </summary> /// <param name="post"></param> /// <returns></returns> static public bool CanHandlePost(Post post) { // If this is a self post with no text we will handle this. if (post.IsSelf && String.IsNullOrWhiteSpace(post.Selftext)) { return(true); } // Check if this is a reddit content post, if so this is us if (!String.IsNullOrWhiteSpace(post.Url)) { return(MiscellaneousHelper.TryToFindRedditContentInLink(post.Url) != null); } return(false); }
/// <summary> /// Called when we should show the content /// </summary> /// <param name="post"></param> public void OnPrepareContent(Post post) { string headerText = ""; string minorText = ""; if (post.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(post.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; case RedditContentType.Website: // This shouldn't happen App.BaconMan.MessageMan.DebugDia("Got website back when prepare on reddit content control"); App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "GotWebsiteOnPrepareRedditContent"); break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; }
/// <summary> /// Called by the host when it queries if we can handle a post. /// </summary> /// <param name="source"></param> /// <returns></returns> public static bool CanHandlePost(ContentPanelSource source) { // If this is a self post with no text we will handle this. if (source.IsSelf && string.IsNullOrWhiteSpace(source.SelfText)) { return(true); } // Check if this is a reddit content post, if so this is us if (string.IsNullOrWhiteSpace(source.Url)) { return(false); } // Check the content var container = MiscellaneousHelper.TryToFindRedditContentInLink(source.Url); // If we got a container and it isn't a web site return it. return(container != null && container.Type != RedditContentType.Website); }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public async void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); // If this is our special rate link, show rate and review. if (!String.IsNullOrWhiteSpace(link) && link.ToLower().Equals("ratebaconit")) { // Open the store await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { try { await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://review/?ProductId=9wzdncrfj0bc")); } catch (Exception) { } }); // Show a dialog. This will only work on devices that can show many windows. // So also set the time and if we restore fast enough we will show the dialog also App.BaconMan.MessageMan.ShowMessageSimple("Thanks ❤", "Thank you for reviewing Baconit, we really appreciate your support of the app!"); m_reviewLeaveTime = DateTime.Now; return; } // Make sure we got a response and it isn't a website if (container != null && container.Type != RedditContentType.Website) { ShowGlobalContent(container); } else { if (container != null && container.Type == RedditContentType.Website) { // We have a link from the reddit presenter, overwrite the link link = container.Website; } ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Fired when someone wants to show the global content presenter /// </summary> /// <param name="link">What to show</param> public void ShowGlobalContent(string link) { // Validate that the link can't be opened by the subreddit viewer RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(link); // Make sure we got a response and it isn't a website if (container != null && container.Type != RedditContentType.Website) { ShowGlobalContent(container); } else { if (container != null && container.Type == RedditContentType.Website) { // We have a link from the reddit presenter, overwrite the link link = container.Website; } ui_globalContentPresenter.ShowContent(link); } }
/// <summary> /// Called by the host when it queries if we can handle a post. /// </summary> /// <param name="post"></param> /// <returns></returns> static public bool CanHandlePost(Post post) { // If this is a self post with no text we will handle this. if (post.IsSelf && String.IsNullOrWhiteSpace(post.Selftext)) { return(true); } // Check if this is a reddit content post, if so this is us if (!String.IsNullOrWhiteSpace(post.Url)) { // Check the content RedditContentContainer container = MiscellaneousHelper.TryToFindRedditContentInLink(post.Url); // If we got a container and it isn't a web site return it. if (container != null && container.Type != RedditContentType.Website) { return(true); } } return(false); }
/// <summary> /// Called when we should show the content /// </summary> /// <param name="post"></param> public void OnPrepareContent(Post post) { string headerText = ""; string minorText = ""; if (post.IsSelf) { headerText = "There's no content here!"; minorText = "Scroll down to view the discussion."; } else { m_content = MiscellaneousHelper.TryToFindRedditContentInLink(post.Url); switch (m_content.Type) { case RedditContentType.Subreddit: headerText = "This post links to a subreddit"; minorText = $"Tap anywhere to view /r/{m_content.Subreddit}"; break; case RedditContentType.Comment: headerText = "This post links to a comment thread"; minorText = "Tap anywhere to view it"; break; case RedditContentType.Post: headerText = "This post links to a reddit post"; minorText = $"Tap anywhere to view it"; break; } } ui_headerText.Text = headerText; ui_minorText.Text = minorText; }