public void InvokeTopicClicked(string topic) { TopicClick?.Invoke(topic); }
private async void richTextBlock_Tapped(object sender, TappedRoutedEventArgs e) { if (e.OriginalSource is TextBlock) { var text = (e.OriginalSource as TextBlock).Text; if (CheckIsTopic(text)) { e.Handled = true; TopicClick?.Invoke(this, new WeiboTopicClickEventArgs(text.Replace("#", ""))); } else if (CheckIsUserName(text)) { e.Handled = true; UserClick?.Invoke(this, new WeiboUserClickEventArgs(text.Replace("@", ""))); } else if ((e.OriginalSource as TextBlock).Tag != null) { e.Handled = true; try { var item = (await Core.Api.ShortUrl.Info((e.OriginalSource as TextBlock).Tag.ToString())).Urls.FirstOrDefault(); switch (item.Type) { case 39: { var picid = item.AnnotationList?.FirstOrDefault()?.Item?.PicIds?.FirstOrDefault(); if (!string.IsNullOrEmpty(picid)) { var items = new List <ImageModel> { new ImageModel($"http://ww1.sinaimg.cn/large/{picid}.jpg") }; //TODO: better way to get image url await new ImageViewDialog(items).ShowAsync(); } else if (item.AnnotationList?.FirstOrDefault()?.Item?.ObjectType == "video") { if (item.AnnotationList?.FirstOrDefault()?.Item?.OriginalUrl != null) { await new WeiboVideoPlayer(item?.UrlLong, item.AnnotationList?.FirstOrDefault().Item.OriginalUrl).ShowAsync(); } else if (item.AnnotationList?.FirstOrDefault()?.Item?.Stream?.Url != null) { await new WeiboVideoPlayer(item?.UrlLong, item.AnnotationList?.FirstOrDefault()?.Item?.Stream?.Url).ShowAsync(); } else { await Launcher.LaunchUriAsync(new Uri(item.UrlLong)); } } else { await Launcher.LaunchUriAsync(new Uri(item.UrlLong)); } } break; default: await Launcher.LaunchUriAsync(new Uri(item.UrlLong)); break; } } catch { await Launcher.LaunchUriAsync(new Uri((e.OriginalSource as TextBlock).Tag.ToString())); } } } }
private void WeiboTextBlock_TopicClick(object sender, WeiboTopicClickEventArgs e) { TopicClick?.Invoke(this, e); }