本文整理汇总了C#中System.Windows.Documents.Inline类的典型用法代码示例。如果您正苦于以下问题:C# Inline类的具体用法?C# Inline怎么用?C# Inline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Inline类属于System.Windows.Documents命名空间,在下文中一共展示了Inline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _AddLineImpl
protected override void _AddLineImpl( Inline inline )
{
FlowDocument.Blocks.Add( new Paragraph( inline ) {
Background = Brushes.MediumBlue,
Foreground = Brushes.White,
} );
}
示例2: OnHtmlTextChanged
private static void OnHtmlTextChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
{
// Go ahead and return out if we set the property on something other than a textblock, or set a value that is not a string.
var txtBox = depObj as TextBlock;
if(txtBox == null)
return;
if(!(e.NewValue is string))
return;
var html = e.NewValue as string;
string xaml;
InlineCollection xamLines;
try {
xaml = HtmlToXamlConverter.ConvertHtmlToXaml(html, false);
xamLines = ((Paragraph)((Section)System.Windows.Markup.XamlReader.Parse(xaml)).Blocks.FirstBlock).Inlines;
} catch {
// There was a problem parsing the html, return out.
return;
}
// Create a copy of the Inlines and add them to the TextBlock.
Inline[] newLines = new Inline[xamLines.Count];
xamLines.CopyTo(newLines, 0);
txtBox.Inlines.Clear();
foreach(var l in newLines) {
txtBox.Inlines.Add(l);
}
}
示例3: GetInlines
private Inline[] GetInlines()
{
Inline[] inlines = new Inline[3];
Match firstMatch = _result.TextMatches[0];
string sourceText = _result.SourceText;
int startIndex = Math.Max(0, firstMatch.Index - CHARS_TO_INCLUDE);
string prev = sourceText.Substring(startIndex, firstMatch.Index - startIndex);
inlines[0] = new Run()
{
Text = prev,
Foreground = new SolidColorBrush(Colors.Gray)
};
string match = firstMatch.Value;
inlines[1] = new Run()
{
Text = match,
Foreground = (Brush)App.Current.Resources["PhoneForegroundBrush"]
};
startIndex = firstMatch.Index + firstMatch.Value.Length;
int length = Math.Min(sourceText.Length - startIndex, CHARS_TO_INCLUDE);
string after = sourceText.Substring(startIndex, length);
inlines[2] = new Run()
{
Text = after,
Foreground = new SolidColorBrush(Colors.Gray)
};
return inlines;
}
示例4: Span
/// <summary>
/// Creates a new Span instance.
/// </summary>
/// <param name="childInline">
/// Optional child Inline for the new Span. May be null.
/// </param>
/// <param name="insertionPosition">
/// Optional position at which to insert the new Span. May be null.
/// </param>
public Span(Inline childInline, TextPointer insertionPosition)
{
if (insertionPosition != null)
{
insertionPosition.TextContainer.BeginChange();
}
try
{
if (insertionPosition != null)
{
// This will throw InvalidOperationException if schema validity is violated.
insertionPosition.InsertInline(this);
}
if (childInline != null)
{
this.Inlines.Add(childInline);
}
}
finally
{
if (insertionPosition != null)
{
insertionPosition.TextContainer.EndChange();
}
}
}
示例5: InlineTweetView
public InlineTweetView(Inline body, Tweet tweet)
: this()
{
_tweet = tweet;
_body.Inlines.Add(body);
DataContext = this;
}
示例6: Insert
public static Inline Insert(this Inline inline, Inline inlineToAdd)
{
var span = inline as Span ?? new Span(inline);
span.Inlines.Add(inlineToAdd);
return span;
}
示例7: Append
public static Inline Append(this Inline inline, Inline inlineToAdd)
{
var span = new Span(inline);
span.Inlines.Add(inlineToAdd);
return span;
}
示例8: TerminalControl
public TerminalControl()
{
InitializeComponent();
caretInline = Input.Inlines.LastInline;
RTB.PreviewMouseDown += OnControlMouseDown;
//TextReceiver.TextChanged += TextChanged;
}
示例9: AddIfNotNull
public static void AddIfNotNull(this InlineCollection inlineCollection, Inline inline)
{
if (inline == null)
{
return;
}
inlineCollection.Add(inline);
}
示例10: routeHyperlinks
void routeHyperlinks(Inline inl)
{
if (inl is Hyperlink)
(inl as Hyperlink).RequestNavigate += (s, e) => App.Current.OnRequestNavigate(s, e);
if (inl is Span)
foreach (var sub in (inl as Span).Inlines)
routeHyperlinks(sub);
}
示例11: InsertInspectedResult
public Inline InsertInspectedResult(Inline position, object obj)
{
LoadInspector(obj);
object result = _rubyEngine.InvokeMember(obj, "as_xaml");
if (result is MutableString) {
return InsertColorizedCode(position, result.ToString());
} else {
throw new NotImplementedError("do not have mechanism to insert UIElement in middle of flow document yet");
}
}
示例12: Paragraph
/// <summary>
/// Paragraph constructor.
/// </summary>
public Paragraph(Inline inline)
: base()
{
if (inline == null)
{
throw new ArgumentNullException("inline");
}
this.Inlines.Add(inline);
}
示例13: RemoveHyperlink
public static TextPointer RemoveHyperlink(TextPointer start)
{
var backspacePosition = start.GetNextInsertionPosition(LogicalDirection.Backward);
Hyperlink hyperlink;
if (backspacePosition == null || !IsHyperlinkBoundaryCrossed(start, backspacePosition, out hyperlink))
{
return null;
}
// Remember caretPosition with forward gravity. This is necessary since we are going to delete
// the hyperlink element preceeding caretPosition and after deletion current caretPosition
// (with backward gravity) will follow content preceeding the hyperlink.
// We want to remember content following the hyperlink to set new caret position at.
var newCaretPosition = start.GetPositionAtOffset(0, LogicalDirection.Forward);
// Deleting the hyperlink is done using logic below.
// 1. Copy its children Inline to a temporary array.
var hyperlinkChildren = hyperlink.Inlines;
var inlines = new Inline[hyperlinkChildren.Count];
hyperlinkChildren.CopyTo(inlines, 0);
// 2. Remove each child from parent hyperlink element and insert it after the hyperlink.
for (int i = inlines.Length - 1; i >= 0; i--)
{
hyperlinkChildren.Remove(inlines[i]);
hyperlink.SiblingInlines.InsertAfter(hyperlink, inlines[i]);
}
// 3. Apply hyperlink's local formatting properties to inlines (which are now outside hyperlink scope).
var localProperties = hyperlink.GetLocalValueEnumerator();
var inlineRange = new TextRange(inlines[0].ContentStart, inlines[inlines.Length - 1].ContentEnd);
while (localProperties.MoveNext())
{
var property = localProperties.Current;
var dp = property.Property;
object value = property.Value;
if (!dp.ReadOnly &&
dp != Inline.TextDecorationsProperty && // Ignore hyperlink defaults.
dp != TextElement.ForegroundProperty &&
dp != BaseUriHelper.BaseUriProperty &&
!IsHyperlinkProperty(dp))
{
inlineRange.ApplyPropertyValue(dp, value);
}
}
// 4. Delete the (empty) hyperlink element.
hyperlink.SiblingInlines.Remove(hyperlink);
return newCaretPosition;
}
示例14: LookupHyperlinks
private static void LookupHyperlinks(Inline inline)
{
if (inline is Hyperlink)
{
var hyperlink = ((Hyperlink) inline);
hyperlink.RequestNavigate += HyperlinkRequestNavigate;
}
if (inline is Span)
foreach (Inline subInline in ((Span) inline).Inlines)
LookupHyperlinks(subInline);
}
示例15: Append
public static Inline Append(this Inline inline, Inline inlineToAdd)
{
Argument.IsNotNull(() => inline);
Argument.IsNotNull(() => inlineToAdd);
var span = new Span(inline);
span.Inlines.Add(inlineToAdd);
return span;
}