本文整理汇总了C#中System.Windows.Documents.StaticTextPointer类的典型用法代码示例。如果您正苦于以下问题:C# StaticTextPointer类的具体用法?C# StaticTextPointer怎么用?C# StaticTextPointer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticTextPointer类属于System.Windows.Documents命名空间,在下文中一共展示了StaticTextPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例6: return
object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
{
return ((ITextPointer)position.Handle0).GetAdjacentElement(direction);
}
示例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);
}
示例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;
}
示例9: StaticTextPointer
StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
{
return new StaticTextPointer(this, ((ITextPointer)position.Handle0).GetNextContextPosition(direction));
}
示例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;
}
示例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);
}
示例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;
}
示例13:
int ITextPointer.CompareTo(StaticTextPointer position)
{
// There is single position in the container.
return 0;
}
示例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);
}
示例15:
DependencyObject ITextContainer.GetParent(StaticTextPointer position)
{
return null;
}