/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public async void OnPrepareContent() { // Since some of this can be costly, delay the work load until we aren't animating. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { m_markdownBlock = new MarkdownTextBlock(); m_markdownBlock.OnMarkdownLinkTapped += MarkdownBlock_OnMarkdownLinkTapped; m_markdownBlock.OnMarkdownReady += MarkdownBox_OnMarkdownReady; m_markdownBlock.Markdown = m_base.Source.SelfText; m_markdownBlock.Foreground = new SolidColorBrush(global::Windows.UI.Colors.Black); m_markdownBlock.FontSize = 12; ui_contentRoot.Children.Add(m_markdownBlock); if (m_base.Source.post != null) { votesText.Text = m_base.Source.post.Score.ToString(); authorText.Text = m_base.Source.post.Author; subredditText.Text = m_base.Source.post.Subreddit; titleText.Text = m_base.Source.post.Title; commentsText.Text = m_base.Source.post.NumComments.ToString() + " comments"; } m_context = m_base.Source.context; }); }
/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public async void OnPrepareContent() { // Since some of this can be costly, delay the work load until we aren't animating. await global::Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { lock (this) { // If we are destroyed or already created return. if (m_base.IsDestoryed || m_webView != null) { return; } MakeWebView(); } }); if (m_base.Source.post != null) { votesText.Text = m_base.Source.post.Score.ToString(); authorText.Text = m_base.Source.post.Author; subredditText.Text = m_base.Source.post.Subreddit; titleText.Text = m_base.Source.post.Title; commentsText.Text = m_base.Source.post.NumComments.ToString() + " comments"; } m_context = m_base.Source.context; }
public static ContentPanelSource CreateFromPost(FlipViewPostContext context, Post post) { ContentPanelSource source = new ContentPanelSource(); source.Id = post.Id; source.Url = post.Url; source.SelfText = post.Selftext; source.Subreddit = post.Subreddit; source.IsNSFW = post.IsOver18; source.IsSelf = post.IsSelf; source.post = post; source.context = context; return(source); }
/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public async void OnPrepareContent() { //Run our work on a background thread. await Task.Run(() => { // Get the image Url string imageUrl = ImageManager.GetImageUrl(m_base.Source.Url); // Make sure we got it. if (String.IsNullOrWhiteSpace(imageUrl)) { // This is bad, we should be able to get the url. // Jump back to the UI thread m_base.FireOnFallbackToBrowser(); return; } // Make sure we aren't destroyed. if (m_base.IsDestoryed) { return; } // Fire off a request for the image. ImageManager.ImageManagerRequest request = new ImageManager.ImageManagerRequest() { ImageId = m_base.Source.Id, Url = imageUrl }; request.OnRequestComplete += OnRequestComplete; App.BaconMan.ImageMan.QueueImageRequest(request); }); votesText.Text = m_base.Source.post.Score.ToString(); authorText.Text = m_base.Source.post.Author; subredditText.Text = m_base.Source.post.Subreddit; titleText.Text = m_base.Source.post.Title; commentsText.Text = m_base.Source.post.NumComments.ToString() + " comments"; m_context = m_base.Source.context; }
/// <summary> /// Fired when we should load the content. /// </summary> /// <param name="source"></param> public void OnPrepareContent() { // Run the rest on a background thread. Task.Run(async() => { // Try to get the imgur url string gifUrl = GetImgurUrl(m_base.Source.Url); // If that failed try to get a url from GfyCat if (gifUrl.Equals(String.Empty)) { // We have to get it from gfycat gifUrl = await GetGfyCatGifUrl(GetGfyCatApiUrl(m_base.Source.Url)); if (String.IsNullOrWhiteSpace(gifUrl)) { // If these failed it might just be a gif. try to send it to gfycat for conversion. gifUrl = await ConvertGifUsingGfycat(m_base.Source.Url); } } // Since some of this can be costly, delay the work load until we aren't animating. await global::Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { // If we didn't get anything something went wrong. if (String.IsNullOrWhiteSpace(gifUrl)) { m_base.FireOnFallbackToBrowser(); return; } lock (this) { // Make sure we aren't destroyed. if (m_base.IsDestoryed) { return; } // Create the media element m_gifVideo = new MediaElement(); m_gifVideo.HorizontalAlignment = HorizontalAlignment.Stretch; m_gifVideo.Tapped += OnVideoTapped; m_gifVideo.CurrentStateChanged += OnVideoCurrentStateChanged; m_gifVideo.IsLooping = true; // Set the source m_gifVideo.Source = new Uri(gifUrl, UriKind.Absolute); m_gifVideo.Play(); // Add the video to the root ui_scrollViewer.Children.Add(m_gifVideo); } }); }); votesText.Text = m_base.Source.post.Score.ToString(); authorText.Text = m_base.Source.post.Author; subredditText.Text = m_base.Source.post.Subreddit; titleText.Text = m_base.Source.post.Title; commentsText.Text = m_base.Source.post.NumComments.ToString() + " comments"; m_context = m_base.Source.context; }