protected override void Render() { InlineCollection inlines = Inlines; inlines.Clear(); TwitterStatusViewer v = Owner; if (v == null) { return; } Status s = v.DataContext as Status; if (s == null) { return; } Status s1 = s; if (s.RetweetedStatus != null) { s = s.RetweetedStatus; } v.CreateTweetBody(s.Text, inlines); }
private static void InlinesSourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { InlineCollection inlines = null; if (obj is TextBlock) { inlines = ((TextBlock)obj).Inlines; } else if (obj is Paragraph) { inlines = ((Paragraph)obj).Inlines; } #if NETFX_CORE || SILVERLIGHT else if (obj is RichTextBlock) { var paragraph = new Paragraph(); inlines = paragraph.Inlines; var richTextBlock = (RichTextBlock)obj; richTextBlock.Blocks.Clear(); richTextBlock.Blocks.Add(paragraph); } #endif if (inlines != null) { inlines.Clear(); foreach (var inline in TextToInlines((string)e.NewValue)) { inlines.Add(inline); } } }
public static void LoadRichText(InlineCollection container, string content) { container.Clear(); if (content == null) return; HtmlDocument d = new HtmlDocument(); d.LoadHtml(content); Analyse(d.DocumentNode, container, ParsingStyle.Normal); }
void replaceInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, PrgPosition); ic.Add((new Run() { Text = " · " })); dualFontSize(ic, fsz, PrgDuration - PrgPosition); ic.Add((new Run() { Text = "\n", FontSize = 1 })); dualFontSize(ic, fsz, PrgDuration); }
public void ProvideQuote([NotNull] InlineCollection inlines) { Asure.NotNull(inlines); inlines.Clear(); var quote = GetNextQuote(); _analizer.Analize(quote); _analizer.ProcessAndStyle(inlines); }
/// <summary> /// Clears and populates the provided table with rows that have the following syntax: /// [row #] [state of new value] /// /// If the state of a value has changed, the value will be bolded. /// </summary> /// <param name="table">Table will be cleared and new rows will populate this table.</param> /// <param name="newValues">The new boolean values</param> /// <param name="oldValues">The boolean values that the new ones are being compared to</param> /// <param name="trueValue">Text if the new value is TRUE</param> /// <param name="falseValue">Text if the new vlaue is FALSE</param> public static Boolean CreateBooleanChartInTable( InlineCollection table, List <Boolean> newValues, List <Boolean> oldValues, String trueValue, String falseValue) { Boolean isBooleanChartCreated = false; // Make sure there are at least newValues to check or that there are the same number of old values as new values if ((newValues != null) && ((oldValues == null) || (newValues.Count == oldValues.Count))) { table.Clear(); // Each new value has it's own row for (int i = 0; i < (int)newValues.Count; i += 1) { var line = new Span(); // Row # var block = new Run(); block.Text = (i + 1).ToString("D", NumberFormatInfo.InvariantInfo); line.Inlines.Add(block); // Space between row # and the value (simulates a column) block = new Run(); block.Text = " "; line.Inlines.Add(block); // Print the textual form of TRUE/FALSE values block = new Run(); block.Text = newValues[i] ? trueValue : falseValue; // Bold values that have changed if ((oldValues != null) && (oldValues[i] != newValues[i])) { var bold = new Bold(); bold.Inlines.Add(block); line.Inlines.Add(bold); } else { line.Inlines.Add(block); } line.Inlines.Add(new LineBreak()); table.Add(line); } isBooleanChartCreated = true; } return(isBooleanChartCreated); }
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { InlineCollection inlines = GetInlines(d); if (inlines == null) { return; } inlines.Clear(); string plainText = GetPlainText(d) ?? string.Empty; IEnumerable <int> matchedCharPositions = GetMatchedCharPositions(d) ?? Enumerable.Empty <int>(); Style matchedCharStyle = GetMatchedCharStyle(d); int nextPos = 0; int matchRunStart = 0; foreach (int matchPos in matchedCharPositions.OrderBy(p => p).Where(p => p < plainText.Length)) { if (matchPos != nextPos) { AddMatchRun(); var nonMatchRun = new Run(plainText.Substring(nextPos, matchPos - nextPos)); inlines.Add(nonMatchRun); matchRunStart = matchPos; } nextPos = matchPos + 1; } AddMatchRun(); if (nextPos < plainText.Length) { var nonMatchRun = new Run(plainText.Substring(nextPos)); inlines.Add(nonMatchRun); } void AddMatchRun() { if (matchRunStart < nextPos) { var matchRun = new Run(plainText.Substring(matchRunStart, nextPos - matchRunStart)) { Style = matchedCharStyle }; inlines.Add(matchRun); } } }
public static void LoadRichText(InlineCollection container, string content) { container.Clear(); if (content == null) { return; } HtmlDocument d = new HtmlDocument(); d.LoadHtml(content); Analyse(d.DocumentNode, container, ParsingStyle.Normal); }
private static void OnFormattedTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { InlineCollection inlines = null; var textBlock = o as TextBlock; if (textBlock != null) { inlines = textBlock.Inlines; } else { var paragraph = o as Paragraph; if (paragraph != null) { inlines = paragraph.Inlines; } else { var span = o as Span; if (span != null) { inlines = span.Inlines; } } } if (inlines == null) { return; } inlines.Clear(); if (e.NewValue == null) { return; } var formattedInlines = FormattedTextConverter.Instance.Convert( e.NewValue, typeof(IEnumerable <Inline>), null, CultureInfo.InvariantCulture) as IEnumerable <Inline>; if (formattedInlines != null) { inlines.AddRange(formattedInlines); } }
void replace3Inlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, TimeSpan.FromSeconds(PrgPositSec)); ic.Add((new Run() { Text = " · " })); dualFontSize(ic, fsz, TimeSpan.FromSeconds(PrgDuratSec) - TimeSpan.FromSeconds(PrgPositSec)); ic.Add((new Run() { Text = "\n", FontSize = 1 })); dualFontSize(ic, fsz, TimeSpan.FromSeconds(PrgDuratSec)); }
public void ReplaceInlines(InlineCollection ic) { const int fsz = 22; ic.Clear(); //string s = string.Format(@"{0:h\:mm}<{1:h\:mm}", (StartPos), ts); dualFontSize(ic, fsz, PrgPosition); ic.Add((new Run() { Text = " · " })); dualFontSize(ic, fsz, PrgDuration - PrgPosition); ic.Add((new Run() { Text = "\n", FontSize = 1 })); dualFontSize(ic, fsz, PrgDuration); }
protected override void Render () { InlineCollection inlines = Inlines; inlines.Clear (); TwitterStatusViewer v = Owner; if (v == null) return; Status s = v.DataContext as Status; if (s == null) return; Status s1 = s; if (s.RetweetedStatus != null) s = s.RetweetedStatus; FontWeight defWeight = this.FontWeight; RoutedEventHandler defLinkHandler = new RoutedEventHandler (v.Hyperlink_Click); DependencyProperty nameFg = TwitterStatusViewer.NameForegroundProperty; Inlines.Add (v.CreateHyperlink (s.User.ScreenName + " [" + s.User.Name + "]", "/" + s.User.ScreenName, nameFg, defWeight, defLinkHandler)); if (!string.IsNullOrEmpty (s.InReplyToScreenName)) { Inlines.Add (v.CreateTextBlock (" in reply to ", FontWeights.Normal)); Inlines.Add (v.CreateHyperlink ("@" + s.InReplyToScreenName, "/" + s.InReplyToScreenName + (s.InReplyToStatusId == 0 ? string.Empty : "/status/" + s.InReplyToStatusId.ToString ()), nameFg, defWeight, defLinkHandler)); } if (s != s1) { Inlines.Add (v.CreateTextBlock (" retweeted by ", FontWeights.Normal)); Inlines.Add (v.CreateHyperlink ("@" + s1.User.ScreenName, "/" + s1.User.ScreenName, nameFg, defWeight, defLinkHandler)); } if (s.Source != null) { int p1 = s.Source.IndexOf ('>'); int p2 = s.Source.IndexOf ('<', Math.Max (0, p1)); string appName = s.Source; if (p1 >= 0 && p2 > 0) appName = s.Source.Substring (p1 + 1, p2 - p1 - 1); p1 = s.Source.IndexOf ('\"'); p2 = s.Source.IndexOf ('\"', Math.Max (0, p1 + 1)); Inlines.Add (v.CreateTextBlock (" from ", FontWeights.Normal)); if (p1 >= 0 && p2 > 0) { Inlines.Add (v.CreateHyperlink (appName, s.Source.Substring (p1 + 1, p2 - p1 - 1), nameFg, defWeight, defLinkHandler)); } else { Inlines.Add (appName); } } Inlines.Add (v.CreateTextBlock (" (" + s.CreatedAt.ToString ("MM/dd HH:mm:ss") + ")", FontWeights.Normal)); }
public static void CreateBooleanTable( InlineCollection Table, bool[] NewValues, bool[] OldValues, string IndexTitle, string ValueTitle, string TrueValue, string FalseValue ) { Table.Clear(); for (var i = 0; i < NewValues.Length; i += 1) { var line = new Span(); var block = new Run(); block.Text = (i + 1).ToString("###"); line.Inlines.Add(block); block = new Run(); block.Text = " "; line.Inlines.Add(block); block = new Run(); block.Text = NewValues[i] ? TrueValue : FalseValue; if ((OldValues != null) && (OldValues[i] != NewValues[i])) { var bold = new Bold(); bold.Inlines.Add(block); line.Inlines.Add(bold); } else { line.Inlines.Add(block); } line.Inlines.Add(new LineBreak()); Table.Add(line); } }
private static void InlinesSourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { InlineCollection inlines = null; if (obj is TextBlock) { inlines = ((TextBlock)obj).Inlines; } else if (obj is Paragraph) { inlines = ((Paragraph)obj).Inlines; } if (inlines != null) { inlines.Clear(); foreach (var inline in TextToInlines((string)e.NewValue)) { inlines.Add(inline); } } }
private void DisplayImpossibleDrinks(InlineCollection playerInlines, InlineCollection dealerInlines) { playerInlines.Clear(); playerInlines.Add(new Run() { Text = "-" }); dealerInlines.Clear(); dealerInlines.Add(new Run() { Text = "-" }); }
/// <summary> /// Clears and populates the provided table with rows that have the following syntax: /// [row #] [state of new value] /// /// If the state of a value has changed, the value will be bolded. /// </summary> /// <param name="table">Table will be cleared and new rows will populate this table.</param> /// <param name="newValues">The new boolean values</param> /// <param name="oldValues">The boolean values that the new ones are being compared to</param> /// <param name="trueValue">Text if the new value is TRUE</param> /// <param name="falseValue">Text if the new vlaue is FALSE</param> public static Boolean CreateBooleanChartInTable( InlineCollection table, List<Boolean> newValues, List<Boolean> oldValues, String trueValue, String falseValue) { Boolean isBooleanChartCreated = false; // Make sure there are at least newValues to check or that there are the same number of old values as new values if ((newValues != null) && ((oldValues == null) || (newValues.Count == oldValues.Count))) { table.Clear(); // Each new value has it's own row for (int i = 0; i < (int)newValues.Count; i += 1) { var line = new Span(); // Row # var block = new Run(); block.Text = (i + 1).ToString("D", NumberFormatInfo.InvariantInfo); line.Inlines.Add(block); // Space between row # and the value (simulates a column) block = new Run(); block.Text = " "; line.Inlines.Add(block); // Print the textual form of TRUE/FALSE values block = new Run(); block.Text = newValues[i] ? trueValue : falseValue; // Bold values that have changed if ((oldValues != null) && (oldValues[i] != newValues[i])) { var bold = new Bold(); bold.Inlines.Add(block); line.Inlines.Add(bold); } else { line.Inlines.Add(block); } line.Inlines.Add(new LineBreak()); table.Add(line); } isBooleanChartCreated = true; } return isBooleanChartCreated; }
void replaceDoneInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, (PrgPosition)); }
void replaceLeftInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, (PrgDuration - PrgPosition)); }
void replaceTotlInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, (PrgDuration)); }
void replaceDoneInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, TimeSpan.FromSeconds(PrgPositSec)); }
void replaceTotlInlines(InlineCollection ic) { ic.Clear(); dualFontSize(ic, fsz, TimeSpan.FromSeconds(PrgDuratSec)); }
private void DisplayExpectedDrinks(InlineCollection playerInlines, InlineCollection dealerInlines, double currentUserDrinks, double currentDealerDrinks, double unconstrainedUserDrinks, double unconstrainedDealerDrinks) { playerInlines.Clear(); playerInlines.Add(new Run() { Text = String.Format("{0:0.##}", currentUserDrinks) }); dealerInlines.Clear(); dealerInlines.Add(new Run() { Text = String.Format("{0:0.##}", currentDealerDrinks) }); if (!currentConstraint.IsSatisfiedBy(currentUnconstrainedStrategy)) { AddComparisonToOptimal(playerInlines, currentUserDrinks, unconstrainedUserDrinks, true); AddComparisonToOptimal(dealerInlines, currentDealerDrinks, unconstrainedDealerDrinks, false); } }