本文整理汇总了C#中System.Windows.Documents.TextElement类的典型用法代码示例。如果您正苦于以下问题:C# TextElement类的具体用法?C# TextElement怎么用?C# TextElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextElement类属于System.Windows.Documents命名空间,在下文中一共展示了TextElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Insert
public void Insert (TextElement element)
{
if (element == null)
throw new ArgumentNullException ("element");
NativeMethods.text_selection_insert (native, element.native);
}
开发者ID:snorp,项目名称:moon,代码行数:7,代码来源:TextSelection.cs
示例2: CreateComponent
public Component CreateComponent(TextElement textElement)
{
var elementType = textElement.GetType();
var title = elementType.Name;
if (elementType == typeof(Paragraph))
{
return new ParagraphComponent(title, textElement as Paragraph);
}
if (elementType == typeof(Volume))
{
return new VolumeComponent(title, textElement as Volume);
}
if (elementType == typeof(Section))
{
return new SectionComponent(title, textElement as Section);
}
if (elementType == typeof(Run))
{
return new RunComponent(title, textElement as Run);
}
throw new NotSupportedException(string.Format("Not supported type {0}.", elementType));
}
开发者ID:ethno2405,项目名称:BrailleTranslator,代码行数:27,代码来源:ComponentFactory.cs
示例3: ApplyFormatToTextElement
public void ApplyFormatToTextElement(TextElement e)
{
e.FontFamily = FontFamily;
e.FontSize = FontSize;
e.FontStyle = FontStyle;
e.FontWeight = FontWeight;
e.FontStretch = FontStretch;
if (ForegroundColor!=Colors.Black) e.Foreground = new SolidColorBrush(ForegroundColor);
if (BackgroundColor!=Colors.White) e.Background = new SolidColorBrush(BackgroundColor);
}
开发者ID:oleholstandersen,项目名称:dtbookImporter,代码行数:10,代码来源:TextFormat.cs
示例4: AddItem
private static void AddItem(TreeViewItem item, TextElement textElement)
{
TreeViewItem childItem;
if (textElement is InlineUIContainer)
{
childItem = new TreeViewItem
{
Header = ((InlineUIContainer) textElement).Child.GetType().Name,
IsExpanded = true
};
item.Items.Add(childItem);
}
else if (textElement is BlockUIContainer)
{
childItem = new TreeViewItem
{
Header = ((BlockUIContainer) textElement).Child.GetType().Name,
IsExpanded = true
};
item.Items.Add(childItem);
}
else if (textElement is Span)
{
AddCollection(item, ((Span) textElement).Inlines);
}
else if (textElement is Paragraph)
{
AddCollection(item, ((Paragraph) textElement).Inlines);
}
else if (textElement is List)
{
AddCollection(item, ((List) textElement).ListItems);
}
else if (textElement is ListItem)
{
AddCollection(item, ((ListItem) textElement).Blocks);
}
else if (textElement is Table)
{
TableTreeView(item, textElement as Table);
}
else if (textElement is AnchoredBlock)
{
var floater = textElement as Floater;
AddCollection(item, ((AnchoredBlock) textElement).Blocks);
}
//The element should be an inline (Run); try to display the text.
else if (textElement is Inline)
{
var range = new TextRange(((Inline) textElement).ContentEnd, ((Inline) textElement).ContentStart);
item.Header = item.Header + " - [" + range.Text + "]";
}
}
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:55,代码来源:TreeViewhelper.cs
示例5: InsertElementClone
// -------------------------------------------------------------------
//
// Internal Methods
//
// -------------------------------------------------------------------
#region Internal Methods
internal static TextElement InsertElementClone(TextPointer start, TextPointer end, TextElement element)
{
TextElement newElement = (TextElement)Activator.CreateInstance(element.GetType());
// Copy properties to the newElement
newElement.TextContainer.SetValues(newElement.ContentStart, element.GetLocalValueEnumerator());
newElement.Reposition(start, end);
return newElement;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:19,代码来源:TextRangeEdit.cs
示例6: FormatText
private static void FormatText(TextElement text, TokenType tokenType)
{
if (tokenType == TokenType.WordForm)
{
FlowDocumentStyles.FormatWordForm(text);
}
else if (tokenType == TokenType.Example)
{
FlowDocumentStyles.FormatExample(text);
}
else
{
FlowDocumentStyles.FormatTranslation(text);
}
}
开发者ID:yu-kopylov,项目名称:cramtool,代码行数:15,代码来源:WordViewPanel.xaml.cs
示例7: CreatePropertyUndoUnit
// Adds a TextTreePropertyUndoUnit to the open parent undo unit, if any.
// Called by TextElement's property change listener.
internal static void CreatePropertyUndoUnit(TextElement element, DependencyPropertyChangedEventArgs e)
{
UndoManager undoManager;
PropertyRecord record;
TextContainer textContainer = element.TextContainer;
undoManager = GetOrClearUndoManager(textContainer);
if (undoManager == null)
return;
record = new PropertyRecord();
record.Property = e.Property;
record.Value = e.OldValueSource == BaseValueSourceInternal.Local ? e.OldValue : DependencyProperty.UnsetValue;
undoManager.Add(new TextTreePropertyUndoUnit(textContainer, element.TextElementNode.GetSymbolOffset(textContainer.Generation) + 1, record));
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:18,代码来源:TextTreeUndo.cs
示例8: TextFormat
public TextFormat(TextElement e)
{
FontFamily = e.FontFamily;
FontSize = e.FontSize;
FontStyle = e.FontStyle;
FontWeight = e.FontWeight;
FontStretch = e.FontStretch;
if (e.Foreground is SolidColorBrush)
{
ForegroundColor = ((SolidColorBrush)e.Foreground).Color;
}
else
{
ForegroundColor = SystemColors.WindowTextColor;
}
if (e.Background is SolidColorBrush)
{
BackgroundColor = ((SolidColorBrush)e.Background).Color;
}
else
{
BackgroundColor = SystemColors.WindowColor;
}
}
开发者ID:oleholstandersen,项目名称:dtbookImporter,代码行数:24,代码来源:TextFormat.cs
示例9: PasteNonMergeableTextFragment
// Helper for PasteTextFragment
private static void PasteNonMergeableTextFragment(TextElement fragment, TextRange range)
{
// We cannot split Hyperlink or other non-splittable inline ancestor.
// Paste text content of fragment in such case.
// Get text content to be pasted.
string fragmentText = TextRangeBase.GetTextInternal(fragment.ElementStart, fragment.ElementEnd);
// Paste text into our empty target range.
//
range.Text = fragmentText;
// Select pasted content
range.Select(range.Start, range.End);
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:16,代码来源:TextRangeSerialization.cs
示例10: PasteTextFragment
private static void PasteTextFragment(TextElement fragment, TextRange range)
{
Invariant.Assert(range.IsEmpty, "range must be empty at this point - emptied by a caller");
Invariant.Assert(fragment is Section || fragment is Span, "The wrapper element must be a Section or Span");
// Define insertion position.
TextPointer insertionPosition = TextRangeEditTables.EnsureInsertionPosition(range.End);
// Check if our insertion position has a non-splittable Inline ancestor such as Hyperlink element.
// Since we cannot split such Inline, we must switch to Text mode for pasting.
// Note that this also has the side effect of converting paragraph breaks to space characters.
if (insertionPosition.HasNonMergeableInlineAncestor)
{
PasteNonMergeableTextFragment(fragment, range);
}
else
{
PasteMergeableTextFragment(fragment, range, insertionPosition);
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:20,代码来源:TextRangeSerialization.cs
示例11: PasteSingleEmbeddedElement
// .............................................................
//
// Pasting
//
// .............................................................
// Handles a special case for pasting a single embedded element -
// needs to choose between BlockUIContainer and InlineUIContainer.
private static bool PasteSingleEmbeddedElement(TextRange range, TextElement fragment)
{
if (fragment.ContentStart.GetOffsetToPosition(fragment.ContentEnd) == 3)
{
TextElement uiContainer = fragment.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
FrameworkElement embeddedElement = null;
if (uiContainer is BlockUIContainer)
{
embeddedElement = ((BlockUIContainer)uiContainer).Child as FrameworkElement;
if (embeddedElement != null)
{
((BlockUIContainer)uiContainer).Child = null;
}
}
else if (uiContainer is InlineUIContainer)
{
embeddedElement = ((InlineUIContainer)uiContainer).Child as FrameworkElement;
if (embeddedElement != null)
{
((InlineUIContainer)uiContainer).Child = null;
}
}
if (embeddedElement != null)
{
range.InsertEmbeddedUIElement(embeddedElement);
return true;
}
}
return false;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:40,代码来源:TextRangeSerialization.cs
示例12: SetStyle
/// <summary>
/// The set style.
/// </summary>
/// <param name="run">
/// The run.
/// </param>
/// <param name="s">
/// The s.
/// </param>
private static void SetStyle(TextElement run, ParagraphStyle s)
{
run.FontFamily = new FontFamily(s.FontFamily);
run.FontSize = s.FontSize;
run.FontWeight = s.Bold ? FontWeights.Bold : FontWeights.Normal;
FontStyle fontStyle = FontStyles.Normal;
if (s.Italic)
{
fontStyle = FontStyles.Italic;
}
run.FontStyle = fontStyle;
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:22,代码来源:FlowDocumentReportWriter.cs
示例13: GetICHFromFlowDocument
//-------------------------------------------------------------------
//
// Private Methods
//
//-------------------------------------------------------------------
#region Private Methods
/// <summary>
/// Given a ContentElement within FlowDocument searches for associated IContentHost.
/// </summary>
/// <param name="contentElement">Content element</param>
/// <param name="flowDocument">FlowDocument hosting ContentElement.</param>
/// <returns>Associated IContentHost with ContentElement.</returns>
private static IContentHost GetICHFromFlowDocument(TextElement contentElement, FlowDocument flowDocument)
{
IContentHost ich = null;
List<DocumentPageView> pageViews;
ITextView textView = flowDocument.StructuralCache.TextContainer.TextView;
if (textView != null)
{
// If FlowDocument is hosted by FlowDocumentScrollViewer, the RenderScope
// is FlowDocumentView object which hosts PageVisual representing the content.
// This PageVisual is also IContentHost for the entire content of DocumentPage.
if (textView.RenderScope is FlowDocumentView) // FlowDocumentScrollViewer
{
if (VisualTreeHelper.GetChildrenCount(textView.RenderScope) > 0)
{
ich = VisualTreeHelper.GetChild(textView.RenderScope, 0) as IContentHost;
}
}
// Our best guess is that FlowDocument is hosted by DocumentViewerBase.
// In this case search the style for all DocumentPageViews.
// Having collection of DocumentPageViews, find for the one which hosts TextElement.
else if (textView.RenderScope is FrameworkElement)
{
pageViews = new List<DocumentPageView>();
FindDocumentPageViews(textView.RenderScope, pageViews);
for (int i = 0; i < pageViews.Count; i++)
{
if (pageViews[i].DocumentPage is FlowDocumentPage)
{
textView = (ITextView)((IServiceProvider)pageViews[i].DocumentPage).GetService(typeof(ITextView));
if (textView != null && textView.IsValid)
{
// Check if the page contains ContentElement. Check Start and End
// position, which will give desired results in most of the cases.
// Having hyperlink spanning more than 2 pages is not very common,
// and this code will not work with it correctly.
if (textView.Contains(contentElement.ContentStart) ||
textView.Contains(contentElement.ContentEnd))
{
ich = pageViews[i].DocumentPage.Visual as IContentHost;
}
}
}
}
}
}
return ich;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:63,代码来源:ContentHostHelper.cs
示例14: FormatTranslation
public static void FormatTranslation(TextElement text)
{
text.Foreground = Brushes.Black;
text.FontStyle = FontStyles.Normal;
text.FontWeight = FontWeights.Normal;
}
开发者ID:yu-kopylov,项目名称:cramtool,代码行数:6,代码来源:FlowDocumentStyles.cs
示例15: AdjustFragmentForTargetRange
// Helper function used to set default value for an indicator requesting to merge last paragraph.
private static void AdjustFragmentForTargetRange(TextElement fragment, TextRange range)
{
if (fragment is Section && ((Section)fragment).HasTrailingParagraphBreakOnPaste)
{
// Explicit indicator is missing, we need to set it by default.
// In a case of TextRange.Xml property assignment we assume that
// user expects to insert as many paragraphs new paragraphs as her pasted xaml contains.
// The expection must be done to the case when the target range is
// extended beyond the last paragraph - then we must merge last paragraph
// to avoid extra paragraph creation at the end (one additional paragraph
// will be created in this case by Pasting code before pasting).
// The other case for exception is when target TextContainer is empty -
// in this case we as well want to merge last paragraph with the following
// one (which will be created as part of paragraph enforcement in pasting operation).
// The both desired conditions - IsAfterLastParagraph and "in empty container"
// can be identified by the following simple test - range.End is not at end-of-doc.
((Section)fragment).HasTrailingParagraphBreakOnPaste = range.End.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None;
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:20,代码来源:TextRangeSerialization.cs
示例16: ApplyFormatTags
public void ApplyFormatTags(TextElement elem)
{
var format = new TextFormat(elem);
if (mFormatMarkupMapping.ContainsKey(format))
{
elem.Tag = mFormatMarkupMapping[format];
}
else
{
foreach (var e in LogicalTreeHelper.GetChildren(elem).OfType<TextElement>()) ApplyFormatTags(e);
}
}
开发者ID:oleholstandersen,项目名称:dtbookImporter,代码行数:12,代码来源:ImportDocumentModel.cs
示例17: SetXmlVirtual
//......................................................
//
// Range Serialization
//
//......................................................
// Worker for Xml property setter; enables extensibility for TextSelection
internal override void SetXmlVirtual(TextElement fragment)
{
TextRangeBase.BeginChange(this);
try
{
base.SetXmlVirtual(fragment);
this.ClearSpringloadFormatting();
}
finally
{
TextRangeBase.EndChange(this);
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:21,代码来源:TextSelection.cs
示例18: PasteTextElement
// Paste flow content into the current text selection
// Returns false if pasting was not successful - assuming that the caller will choose another format for pasting
private static bool PasteTextElement(TextEditor This, TextElement sectionOrSpan)
{
bool success = false;
This.Selection.BeginChange();
try
{
((TextRange)This.Selection).SetXmlVirtual(sectionOrSpan);
// Merge new Lists with surrounding Lists.
TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.Start);
TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.End);
// Merge flow direction of the new content if it matches its surroundings.
TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.Start);
TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.End);
success = true;
}
finally
{
This.Selection.EndChange();
}
return success;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:27,代码来源:TextEditorCopyPaste.cs
示例19: SetXmlVirtual
//......................................................
//
// Range Serialization
//
//......................................................
// Worker for Xml property setter; enables extensibility for TextSelection
internal virtual void SetXmlVirtual(TextElement fragment)
{
if (!this.IsTableCellRange)
{
TextRangeSerialization.PasteXml(this, fragment);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:TextRange.cs
示例20: TryMatch
private bool TryMatch(TextElement element)
{
if (myAction(element))
{
myResults.Add(element);
if (!ContinueAfterMatch)
{
return false;
}
}
return true;
}
开发者ID:JackWangCUMT,项目名称:Plainion,代码行数:14,代码来源:FlowDocumentVisitor.cs
注:本文中的System.Windows.Documents.TextElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论