private static void OnSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { try { var textblock = (InReplyToBlock) obj; textblock.Inlines.Clear(); textblock.Visibility = Visibility.Collapsed; if (textblock.ReplyID != "0" && !string.IsNullOrEmpty(textblock.ReplyID)) { var link = new InlineLink(); link.HoverColour = (Brush) link.FindResource("HoverColour"); link.NormalColour = (Brush) link.FindResource("BaseColour"); link.Inlines.Add(textblock.ReplyTo); link.TextDecorations = null; link.ToolTip = "View conversation"; link.MouseLeftButtonDown += conversationLink_Click; textblock.Inlines.Add(new Run(" in reply to ")); textblock.Inlines.Add(link); textblock.Visibility = Visibility.Visible; } } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } }
public InlineLink Match(String word, Brush lBrush, IStatusUpdate oStatusUpdate) { if (!_fontmap.ContainsKey(word.ToLower())) return null; var il = new InlineLink(); il.FontFamily = (FontFamily) il.FindResource(_fontmap[word.ToLower()]); il.FontSize = _textProcessorEngine.FsDefault; il.Foreground = _textProcessorEngine.BrText; il.Text = word; il.ToolTip = "Why do people hate on Comic Sans?"; return il; }
public InlineLink Match(String word, Brush lBrush, IStatusUpdate oStatusUpdate) { if (_highlightWordSettingsProvider.HighlightWords.Any(k => word.ToLower().Contains(k.Text.ToLower()))) { var il = new InlineLink { FontFamily = _textProcessorEngine.FfDefault, FontSize = _textProcessorEngine.FsDefault, Foreground = _textProcessorEngine.BrText, Text = word }; il.Background = (Brush)il.FindResource("HighlightBackgroundColour"); return il; } return null; }
public InlineLink Match(String word, Brush lBrush, IStatusUpdate oStatusUpdate) { foreach (var k in _backgroundmap) { if (!word.ToLower().Contains(k.Key.ToLower())) continue; var il = new InlineLink { FontFamily = _textProcessorEngine.FfDefault, FontSize = _textProcessorEngine.FsDefault, Foreground = _textProcessorEngine.BrText, Text = word }; il.Background = (Brush) il.FindResource(k.Value); return il; } return null; }
private async void AddAdditionalSmartText(InlineLink il, string f) { foreach ( IAdditonalTextSmarts textSmarts in _textProcessorEngine.AdditonalTextSmarts.Where(textSmarts => textSmarts.CanPageTitle(f))) { string title = await textSmarts.Process(f); if (title == null) continue; var ilt = new InlineLink { Text = "\u201C" + title + "\u201D ", FontFamily = _textProcessorEngine.FfDefault, FontSize = _textProcessorEngine.FsDefault, Foreground = _textProcessorEngine.BrText, Background = (Brush) il.FindResource("LighterGreyColour"), HoverColour = _textProcessorEngine.BrText, NormalColour = _textProcessorEngine.BrText, FontStyle = FontStyles.Italic, }; il.Inlines.Add(_textProcessorEngine.WebSymbolHelper(" \u005D", null)); il.Inlines.Add(ilt); } }
private static void OnSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { try { var textblock = (TimeReplyToBlock) obj; textblock.Inlines.Clear(); var time = new InlineLink(); var tweet = textblock.DataContext as Tweet; if (tweet == null) return; var uri = new Uri(string.Format("http://twitter.com/{0}/status/{1}", tweet.Contact.Name.ToLower(), tweet.ID)); var clockimage = new InlineLink { Text = "P ", Name = "clockimage", FontFamily = (FontFamily) textblock.FindResource("WebSymbols"), FontSize = 9, Foreground = (Brush) textblock.FindResource("BaseColour"), HoverColour = (Brush) textblock.FindResource("BaseColour"), NormalColour = (Brush) textblock.FindResource("BaseColour") }; time.Url = uri; time.Tag = tweet.Contact.Name.ToLower() + " " + tweet.ID; // grab these now for the dragging and dropping later time.MouseMove += time_link_drag; time.Inlines.Add(textblock.Time); time.MouseUp += link_Click; time.TextDecorations = null; time.HoverColour = (Brush) time.FindResource("HoverColour"); time.NormalColour = (Brush) time.FindResource("BaseColour"); time.ToolTip = "Open tweet in the default browser" + Environment.NewLine + uri + Environment.NewLine + "Or drag to desktop to create link to this tweet"; textblock.Inlines.Add(clockimage); textblock.Inlines.Add(time); if (!String.IsNullOrEmpty(textblock.SourceUri) && !String.IsNullOrEmpty(textblock.SourceText)) { try { if (Uri.TryCreate(textblock.SourceUri, UriKind.Absolute, out uri)) { var link = new InlineLink {Url = new Uri(textblock.SourceUri)}; link.Inlines.Add(textblock.SourceText); link.HoverColour = (Brush) link.FindResource("HoverColour"); link.NormalColour = (Brush) link.FindResource("BaseColour"); link.MouseLeftButtonDown += link_Click; link.TextDecorations = null; link.ToolTip = "Open link to tweeting application\'s web site"; textblock.Inlines.Add(new Run(" from ")); textblock.Inlines.Add(link); } else { textblock.Inlines.Add("from " + textblock.SourceText); } } catch { textblock.Inlines.Add("from " + textblock.SourceText); } } else if (!String.IsNullOrEmpty(textblock.SourceText)) { textblock.Inlines.Add(textblock.SourceText); } } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } }