private static void ExpandShrunkLink(Hyperlink link, Paragraph parent, RichTextBox rtb) { if (link.NavigateUri.AbsoluteUri.StartsWith("http://bit.ly")) { WebClient getBitly = new WebClient(); getBitly.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { XElement result = XElement.Parse(e.Result); XElement long_url = GetPath(result, "data/entry/long_url"); if (long_url != null) { string url = long_url.Value; // ToolTipService.SetToolTip(link, url); InlineUIContainer container = new InlineUIContainer(); Ellipse ellipse = new Ellipse(); ellipse.Width = 6; ellipse.Height = 6; ellipse.VerticalAlignment = VerticalAlignment.Center; ellipse.Margin = new Thickness(3); ellipse.Fill = new SolidColorBrush(Colors.Orange); ToolTipService.SetToolTip(ellipse, url); container.Child = ellipse; parent.Inlines.Insert(parent.Inlines.IndexOf(link) + 1, container); //link.Inlines.Add(container); } } }; getBitly.DownloadStringAsync(new Uri("http://api.bit.ly/v3/expand?shortUrl=" + HttpUtility.UrlEncode(link.NavigateUri.AbsoluteUri) + "&login=jimlynn&apiKey=R_769e4a2d579cef3c9c18be33dc4b160c&format=xml", UriKind.Absolute)); } else if (link.NavigateUri.AbsoluteUri.StartsWith("http://twitpic.com/")) { string url = link.NavigateUri.AbsoluteUri + "/full"; WebClient getTwitpic = new WebClient(); getTwitpic.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { //Regex getpic = new Regex("(<img(\\ [^=]+=\\\"[^\"]+\\\")*\\ *>)+"); Regex getpic = new Regex(@"(?<=img\s+.*src\=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])"); Match match = getpic.Match(e.Result); while (match.Success) { //if (match.Value.Contains("/images/logo-main.png") == false) if (match.Value.StartsWith("http://")) { var imgurl = match.Value; ICommand command = rtb.GetValue(StatusView.CommandProperty) as ICommand; if (command != null) { link.NavigateUri = null; link.Command = command; link.CommandParameter = imgurl; } break; } match = match.NextMatch(); } } }; getTwitpic.DownloadStringAsync(new Uri(url, UriKind.Absolute)); } else if (link.NavigateUri.AbsoluteUri.StartsWith("http://yfrog.com/")) { string id = link.NavigateUri.AbsoluteUri.Substring("http://yfrog.com/".Length); WebClient getYfrog = new WebClient(); getYfrog.DownloadStringCompleted+= (sender,e)=> { if (e.Error == null) { XElement xml = XElement.Parse(e.Result); XNamespace ns = "http://ns.imageshack.us/imginfo/7/"; var links = xml.Element(ns + "links"); ; if (links != null) { string url = links.Element(ns + "image_link").Value; ICommand command = rtb.GetValue(StatusView.CommandProperty) as ICommand; if (command != null) { link.NavigateUri = null; link.Command = command; link.CommandParameter = url; //link.Command = new RelayCommand<string>(Dis } //Regex getimg = new Regex("<link rel=\"image_src\" href=\"([^\"]+)\" />"); //Match match = getimg.Match(e.Result); //string url = match.Groups[1].Value; InlineUIContainer container = new InlineUIContainer(); Ellipse ellipse = new Ellipse(); ellipse.Width = 16; ellipse.Height = 16; ellipse.Fill = new SolidColorBrush(Colors.Orange); Image img = new Image(); BitmapImage bmp = new BitmapImage(new Uri(url, UriKind.Absolute)); img.Source = bmp; ToolTipService.SetToolTip(ellipse, img); container.Child = ellipse; parent.Inlines.Insert(parent.Inlines.IndexOf(link) + 1, container); } } }; getYfrog.DownloadStringAsync(new Uri("http://yfrog.com/api/xmlInfo?path=" + id, UriKind.Absolute)); } else if (link.NavigateUri.AbsoluteUri.StartsWith("http://tweetphoto.com/")) { string id = link.NavigateUri.AbsoluteUri.Substring("http://tweetphoto.com/".Length); WebClient getYfrog = new WebClient(); getYfrog.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { XElement xml = XElement.Parse(e.Result); XNamespace ns = "http://tweetphotoapi.com"; string url = xml.Element(ns + "BigImageUrl").Value; ICommand command = rtb.GetValue(StatusView.CommandProperty) as ICommand; if (command != null) { link.NavigateUri = null; link.Command = command; link.CommandParameter = url; //link.Command = new RelayCommand<string>(Dis } //Regex getimg = new Regex("<link rel=\"image_src\" href=\"([^\"]+)\" />"); //Match match = getimg.Match(e.Result); //string url = match.Groups[1].Value; InlineUIContainer container = new InlineUIContainer(); Ellipse ellipse = new Ellipse(); ellipse.Width = 16; ellipse.Height = 16; ellipse.Fill = new SolidColorBrush(Colors.Orange); Image img = new Image(); BitmapImage bmp = new BitmapImage(new Uri(url, UriKind.Absolute)); img.Source = bmp; ToolTipService.SetToolTip(ellipse, img); container.Child = ellipse; parent.Inlines.Insert(parent.Inlines.IndexOf(link) + 1, container); } }; getYfrog.DownloadStringAsync(new Uri("http://tweetphotoapi.com/api/tpapi.svc/photos/" + id, UriKind.Absolute)); } else if (link.NavigateUri.AbsoluteUri.StartsWith("http://twitgoo.com/")) { string id = link.NavigateUri.AbsoluteUri.Substring("http://twitgoo.com/".Length); WebClient getYfrog = new WebClient(); getYfrog.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { XElement xml = XElement.Parse(e.Result); string url = xml.Element("imageurl").Value; ICommand command = rtb.GetValue(StatusView.CommandProperty) as ICommand; if (command != null) { link.NavigateUri = null; link.Command = command; link.CommandParameter = url; //link.Command = new RelayCommand<string>(Dis } //Regex getimg = new Regex("<link rel=\"image_src\" href=\"([^\"]+)\" />"); //Match match = getimg.Match(e.Result); //string url = match.Groups[1].Value; InlineUIContainer container = new InlineUIContainer(); Ellipse ellipse = new Ellipse(); ellipse.Width = 16; ellipse.Height = 16; ellipse.Fill = new SolidColorBrush(Colors.Orange); Image img = new Image(); BitmapImage bmp = new BitmapImage(new Uri(url, UriKind.Absolute)); img.Source = bmp; ToolTipService.SetToolTip(ellipse, img); container.Child = ellipse; parent.Inlines.Insert(parent.Inlines.IndexOf(link) + 1, container); } }; getYfrog.DownloadStringAsync(new Uri("http://twitgoo.com/api/message/info/" + id, UriKind.Absolute)); } else if (link.NavigateUri.AbsoluteUri.Contains("imgur.com") && link.NavigateUri.AbsoluteUri.EndsWith(".jpg")) { string url = link.NavigateUri.AbsoluteUri; ICommand command = rtb.GetValue(StatusView.CommandProperty) as ICommand; if (command != null) { link.NavigateUri = null; link.Command = command; link.CommandParameter = url; //link.Command = new RelayCommand<string>(Dis } } }
public static bool GetExcludeMentions(RichTextBox richTextBox) { if (richTextBox == null) throw new ArgumentNullException("richTextBox"); else return (bool) richTextBox.GetValue(IntellisenseExtension.ExcludeMentionsProperty); }
public static bool GetIgnorePrefix(RichTextBox richTextBox) { if (richTextBox == null) throw new ArgumentNullException("richTextBox"); else return (bool) richTextBox.GetValue(IntellisenseExtension.IgnorePrefixProperty); }
public static FlowDocument GetBindableDocument(RichTextBox obj) { return (FlowDocument)obj.GetValue(BindableDocumentProperty); }
public static bool GetPreventTextInput(RichTextBox obj) { return (bool) obj.GetValue(PreventTextInputProperty); }
public static Window GetDragsWindow(RichTextBox obj) { return (Window)obj.GetValue(DragsWindowProperty); }