本文整理汇总了C#中System.Windows.Documents.StaticTextPointer类的典型用法代码示例。如果您正苦于以下问题:C# StaticTextPointer类的具体用法?C# StaticTextPointer怎么用?C# StaticTextPointer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticTextPointer类属于System.Windows.Documents命名空间,在下文中一共展示了StaticTextPointer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IsContentHighlighted
// Returns true iff the indicated content has scoping highlights.
internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction)
{
int segmentCount;
TextSegment textSegment;
// No highlight when the selection is for interim character.
if (_selection.IsInterimSelection)
{
return false;
}
// Check all segments of selection
List<TextSegment> textSegments = _selection.TextSegments;
segmentCount = textSegments.Count;
for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++)
{
textSegment = textSegments[segmentIndex];
if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || //
(direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0))
{
return true;
}
}
return false;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:28,代码来源:TextSelectionHighlightLayer.cs
示例2: GetNextChangePosition
// Returns the position of the next highlight start or end in an
// indicated direction, or null if there is no such position.
internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
{
StaticTextPointer transitionPosition;
AttributeRange attributeRange;
int i;
transitionPosition = StaticTextPointer.Null;
// Use a simple iterative search since we don't ever have
// more than a handful of attributes in a composition.
if (direction == LogicalDirection.Forward)
{
for (i = 0; i < _attributeRanges.Count; i++)
{
attributeRange = (AttributeRange)_attributeRanges[i];
if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
{
if (textPosition.CompareTo(attributeRange.Start) < 0)
{
transitionPosition = attributeRange.Start.CreateStaticPointer();
break;
}
else if (textPosition.CompareTo(attributeRange.End) < 0)
{
transitionPosition = attributeRange.End.CreateStaticPointer();
break;
}
}
}
}
else
{
for (i = _attributeRanges.Count - 1; i >= 0; i--)
{
attributeRange = (AttributeRange)_attributeRanges[i];
if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
{
if (textPosition.CompareTo(attributeRange.End) > 0)
{
transitionPosition = attributeRange.End.CreateStaticPointer();
break;
}
else if (textPosition.CompareTo(attributeRange.Start) > 0)
{
transitionPosition = attributeRange.Start.CreateStaticPointer();
break;
}
}
}
}
return transitionPosition;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:58,代码来源:DisplayAttributeHighlightLayer.cs
示例3: GetHighlightValue
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
// Returns the value of a property stored on scoping highlight, if any.
//
// If no property value is set, returns DependencyProperty.UnsetValue.
internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction)
{
AttributeRange attributeRange;
object value;
value = DependencyProperty.UnsetValue;
attributeRange = GetRangeAtPosition(textPosition, direction);
if (attributeRange != null)
{
value = attributeRange.TextDecorations;
}
return value;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:DisplayAttributeHighlightLayer.cs
示例4: GetHighlightValue
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
// Returns the value of a property stored on scoping highlight, if any.
//
// If no property value is set, returns DependencyProperty.UnsetValue.
internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction)
{
object value;
if (IsContentHighlighted(textPosition, direction))
{
value = _selectedValue;
}
else
{
value = DependencyProperty.UnsetValue;
}
return value;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:TextSelectionHighlightLayer.cs
示例5: GetHighlightValue
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
/// <summary>
/// Returns the value of a property stored on scoping highlight, if any.
/// </summary>
/// <param name="textPosition">
/// Position to query.
/// </param>
/// <param name="direction">
/// Direction of content to query.
/// </param>
/// <param name="highlightLayerOwnerType">
/// Type of the matching highlight layer owner.
/// </param>
/// <returns>
/// The highlight value if set on any scoping highlight. If no property
/// value is set, returns DependencyProperty.UnsetValue.
/// </returns>
internal virtual object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction, Type highlightLayerOwnerType)
{
int layerIndex;
object value;
HighlightLayer layer;
value = DependencyProperty.UnsetValue;
// Take the value on the closest layer. "Closest" == added first.
for (layerIndex = 0; layerIndex < this.LayerCount; layerIndex++)
{
layer = GetLayer(layerIndex);
if (layer.OwnerType == highlightLayerOwnerType)
{
value = layer.GetHighlightValue(textPosition, direction);
if (value != DependencyProperty.UnsetValue)
break;
}
}
return value;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:47,代码来源:Highlights.cs
示例6: return
object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
{
return ((ITextPointer)position.Handle0).GetAdjacentElement(direction);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:FixedTextContainer.cs
示例7: IsContentHighlighted
// Returns whether or not this text pointer has a highlight on it. Determines this by checking
// the highlights of the DocumentSequence.
internal override bool IsContentHighlighted(StaticTextPointer staticTextPointer, LogicalDirection direction)
{
return this._docSeqContainer.Highlights.IsContentHighlighted(staticTextPointer, direction);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:6,代码来源:DocumentSequenceHighlightLayer.cs
示例8: GetRun
// Returns the type and end of the Run intersecting position.
internal bool GetRun(StaticTextPointer position, LogicalDirection direction, out RunType runType, out StaticTextPointer end)
{
int index = FindIndex(position, direction);
runType = RunType.Clean;
end = StaticTextPointer.Null;
if (index < 0)
{
return false;
}
Run run = GetRun(index);
runType = run.RunType;
end = (direction == LogicalDirection.Forward) ? GetRunEndPosition(index) : run.Position.CreateStaticPointer();
return true;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:20,代码来源:SpellerStatusTable.cs
示例9: StaticTextPointer
StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
{
return new StaticTextPointer(this, ((ITextPointer)position.Handle0).GetNextContextPosition(direction));
}
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:FixedTextContainer.cs
示例10: GetNextErrorTransition
// Returns the position of the next error start or end in an
// indicated direction, or null if there is no such position.
// Called by the SpellerHighlightLayer.
internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction)
{
StaticTextPointer transitionPosition;
int index;
int i;
transitionPosition = StaticTextPointer.Null;
index = FindIndex(textPosition, direction);
if (index == -1)
{
// textPosition is at the document edge.
// leave transitionPosition null.
}
else if (direction == LogicalDirection.Forward)
{
if (IsErrorRun(index))
{
transitionPosition = GetRunEndPosition(index);
}
else
{
for (i = index+1; i < _runList.Count; i++)
{
if (IsErrorRun(i))
{
transitionPosition = GetRun(i).Position.CreateStaticPointer();
break;
}
}
}
}
else // direction == LogicalDirection.Backward
{
if (IsErrorRun(index))
{
transitionPosition = GetRun(index).Position.CreateStaticPointer();
}
else
{
for (i = index - 1; i > 0; i--)
{
if (IsErrorRun(i))
{
transitionPosition = GetRunEndPosition(i);
break;
}
}
}
}
// If we ever had two consecuative errors (with touching borders)
// we could return a transitionPosition == textPosition, which is illegal.
// We rely on the fact that consecutive errors are always separated
// by a word break to avoid this.
//
Invariant.Assert(transitionPosition.IsNull || textPosition.CompareTo(transitionPosition) != 0);
return transitionPosition;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:64,代码来源:SpellerStatusTable.cs
示例11: GetError
// Returns the position and suggested replacement list of an error covering
// the specified content.
// If no error exists, return false.
internal bool GetError(StaticTextPointer textPosition, LogicalDirection direction,
out ITextPointer start, out ITextPointer end)
{
int index;
start = null;
end = null;
index = GetErrorIndex(textPosition, direction);
if (index >= 0)
{
start = GetRun(index).Position;
end = GetRunEndPositionDynamic(index);
}
return (start != null);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:SpellerStatusTable.cs
示例12: IsRunType
// Returns true if the specified character is part of a run of the specified type.
internal bool IsRunType(StaticTextPointer textPosition, LogicalDirection direction, RunType runType)
{
int index = FindIndex(textPosition, direction);
if (index < 0)
{
return false;
}
return GetRun(index).RunType == runType;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:SpellerStatusTable.cs
示例13:
int ITextPointer.CompareTo(StaticTextPointer position)
{
// There is single position in the container.
return 0;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:5,代码来源:nulltextnavigator.cs
示例14: GetNextChangePosition
// Returns the next change position starting from the passed in StaticTextPointer. Determines this by checking
// the highlights of the DocumentSequence.
internal override StaticTextPointer GetNextChangePosition(StaticTextPointer staticTextPointer, LogicalDirection direction)
{
return this._docSeqContainer.Highlights.GetNextHighlightChangePosition(staticTextPointer, direction);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:6,代码来源:DocumentSequenceHighlightLayer.cs
示例15:
DependencyObject ITextContainer.GetParent(StaticTextPointer position)
{
return null;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:FixedTextContainer.cs
示例16: GetErrorIndex
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
// Returns the index in _runList of an error covering the specified
// content, or -1 if no such error exists.
private int GetErrorIndex(StaticTextPointer textPosition, LogicalDirection direction)
{
int index;
Run run;
index = FindIndex(textPosition, direction);
if (index >= 0)
{
run = GetRun(index);
if (run.RunType == RunType.Clean || run.RunType == RunType.Dirty)
{
index = -1;
}
}
return index;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:29,代码来源:SpellerStatusTable.cs
示例17: FindIndex
// Finds the index of a run containing the specified content.
// Returns -1 if there is no run in the indicated direction -- when
// position is at the document edge pointing to nothing.
private int FindIndex(StaticTextPointer position, LogicalDirection direction)
{
Run run;
int index;
int minIndex;
int maxIndex;
index = -1;
minIndex = 0;
maxIndex = _runList.Count;
while (minIndex < maxIndex)
{
index = (minIndex + maxIndex) / 2;
run = GetRun(index);
if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 ||
direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0)
{
// Search to the left.
maxIndex = index;
}
else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 ||
direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0)
{
// Search to the right.
minIndex = index + 1;
}
else
{
// Got a match.
break;
}
}
if (minIndex >= maxIndex)
{
// We walked off the document edge searching.
// position is at document start or end, and direction
// points off into space, so there's no associated run.
index = -1;
}
return index;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:49,代码来源:SpellerStatusTable.cs
示例18: HandleElementStartEdge
/// <summary>
/// Return next TextRun at element edge start position
/// </summary>
/// <param name="position">
/// Current position in text array
/// </param>
protected TextRun HandleElementStartEdge(StaticTextPointer position)
{
Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");
//
TextRun run = null;
TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");
Invariant.Assert(!(element is Block), "We do not expect any Blocks inside Paragraphs");
// Treat figure and floaters as special hidden runs.
if (element is Figure || element is Floater)
{
// Get the length of the element
int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
// Create special hidden run.
run = new FloatingRun(cch, element is Figure);
if (element is Figure)
{
_hasFigures = true;
}
else
{
_hasFloaters = true;
}
}
else if (element is LineBreak)
{
int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
run = new LineBreakRun(cch, PTS.FSFLRES.fsflrSoftBreak);
}
else if (element.IsEmpty)
{
// Empty TextElement should affect line metrics.
// TextFormatter does not support this feature right now, so as workaround
// TextRun with ZERO WIDTH SPACE is used.
TextProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */);
char[] textBuffer = new char[_elementEdgeCharacterLength * 2];
// Assert that _elementEdgeCharacterLength is 1 before we use hard-coded indices
Invariant.Assert(_elementEdgeCharacterLength == 1, "Expected value of _elementEdgeCharacterLength is 1");
textBuffer[0] = (char)0x200B;
textBuffer[1] = (char)0x200B;
run = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps);
}
else
{
Inline inline = (Inline) element;
DependencyObject parent = inline.Parent;
FlowDirection inlineFlowDirection = inline.FlowDirection;
FlowDirection parentFlowDirection = inlineFlowDirection;
TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);
if(parent != null)
{
parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
}
if (inlineFlowDirection != parentFlowDirection)
{
// Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction
if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
{
run = new TextSpanModifier(
_elementEdgeCharacterLength,
null,
null,
inlineFlowDirection
);
}
else
{
run = new TextSpanModifier(
_elementEdgeCharacterLength,
inlineTextDecorations,
inline.Foreground,
inlineFlowDirection
);
}
}
else
{
if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
{
run = new TextHidden(_elementEdgeCharacterLength);
}
else
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:linebase.cs
示例19: GetNextChangePosition
// Returns the position of the next highlight start or end in an
// indicated direction, or null if there is no such position.
internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
{
StaticTextPointer transitionPosition;
transitionPosition = StaticTextPointer.Null;
if (!IsTextRangeEmpty(_selection) && !_selection.IsInterimSelection)
{
int segmentCount;
List<TextSegment> textSegments = _selection.TextSegments;
TextSegment textSegment;
segmentCount = textSegments.Count;
if (direction == LogicalDirection.Forward)
{
for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++)
{
textSegment = textSegments[segmentIndex];
// Ignore empty segments.
//
if (textSegment.Start.CompareTo(textSegment.End) != 0)
{
if (textPosition.CompareTo(textSegment.Start) < 0)
{
transitionPosition = textSegment.Start.CreateStaticPointer();
break;
}
else if (textPosition.CompareTo(textSegment.End) < 0)
{
transitionPosition = textSegment.End.CreateStaticPointer();
break;
}
}
}
}
else
{
for (int segmentIndex = segmentCount - 1; segmentIndex >= 0; segmentIndex--)
{
textSegment = textSegments[segmentIndex];
if (textSegment.Start.CompareTo(textSegment.End) != 0)
{
if (textPosition.CompareTo(textSegment.End) > 0)
{
transitionPosition = textSegment.End.CreateStaticPointer();
break;
}
else if (textPosition.CompareTo(textSegment.Start) > 0)
{
transitionPosition = textSegment.Start.CreateStaticPointer();
break;
}
}
}
}
}
return transitionPosition;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:76,代码来源:TextSelectionHighlightLayer.cs
示例20: HandleEmbeddedObject
/// <summary>
/// Fetch the next run at embedded object position.
/// </summary>
/// <param name="dcp">
/// Character offset of this run.
/// </param>
/// <param name="position">
/// Current position in the text array.
/// </param>
protected TextRun HandleEmbeddedObject(int dcp, StaticTextPointer position)
{
Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");
TextRun run = null;
DependencyObject embeddedObject = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
if (embeddedObject is UIElement)
{
// Extract the aggregated properties into something that the textrun can use.
TextRunProperties textProps = new TextProperties(embeddedObject, position, true /* inline objects */, true /* get background */);
// Create inline object run.
run = new InlineObjectRun(TextContainerHelper.EmbeddedObjectLength, (UIElement)embeddedObject, textProps, _paraClient.Paragraph as TextParagraph);
}
else
{
// If the embedded object is of an unknown type, treat it as hidden content.
run = new TextHidden(TextContainerHelper.EmbeddedObjectLength);
}
return run;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:30,代码来源:linebase.cs
注:本文中的System.Windows.Documents.StaticTextPointer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论