本文整理汇总了C#中LogicalDirection类的典型用法代码示例。如果您正苦于以下问题:C# LogicalDirection类的具体用法?C# LogicalDirection怎么用?C# LogicalDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogicalDirection类属于命名空间,在下文中一共展示了LogicalDirection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IncrementalSearch
public IncrementalSearch(TextArea textArea, LogicalDirection direction)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
this.textArea = textArea;
this.direction = direction;
}
示例2: GetPositionAtWordBoundary
/// <summary>
/// 1. When wordBreakDirection = Forward, returns a position at the end of the word,
/// i.e. a position with a wordBreak character (space) following it.
/// 2. When wordBreakDirection = Backward, returns a position at the start of the word,
/// i.e. a position with a wordBreak character (space) preceeding it.
/// 3. Returns null when there is no workbreak in the requested direction.
/// </summary>
private static TextPointer GetPositionAtWordBoundary(TextPointer position, LogicalDirection wordBreakDirection)
{
if (!position.IsAtInsertionPosition)
{
position = position.GetInsertionPosition(wordBreakDirection);
}
TextPointer navigator = position;
while (navigator != null && !IsPositionNextToWordBreak(navigator, wordBreakDirection))
{
navigator = navigator.GetNextInsertionPosition(wordBreakDirection);
}
return navigator;
}
示例3: 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;
}
示例4: IsPositionNextToWordBreak
// Helper for GetPositionAtWordBoundary.
// Returns true when passed TextPointer is next to a wordBreak in requested direction.
private static bool IsPositionNextToWordBreak(TextPointer position, LogicalDirection wordBreakDirection)
{
bool isAtWordBoundary = false;
// Skip over any formatting.
if (position.GetPointerContext(wordBreakDirection) != TextPointerContext.Text)
{
position = position.GetInsertionPosition(wordBreakDirection);
}
if (position.GetPointerContext(wordBreakDirection) == TextPointerContext.Text)
{
LogicalDirection oppositeDirection = (wordBreakDirection == LogicalDirection.Forward) ?
LogicalDirection.Backward : LogicalDirection.Forward;
char[] runBuffer = new char[1];
char[] oppositeRunBuffer = new char[1];
position.GetTextInRun(wordBreakDirection, runBuffer, /*startIndex*/0, /*count*/1);
position.GetTextInRun(oppositeDirection, oppositeRunBuffer, /*startIndex*/0, /*count*/1);
if (runBuffer[0] == ' ' && !(oppositeRunBuffer[0] == ' '))
{
isAtWordBoundary = true;
}
}
else
{
// If we're not adjacent to text then we always want to consider this position a "word break".
// In practice, we're most likely next to an embedded object or a block boundary.
isAtWordBoundary = true;
}
return isAtWordBoundary;
}
示例5: VerifyDirection
// Throws an ArgumentException if direction is not a valid enum.
internal static void VerifyDirection(LogicalDirection direction, string argumentName)
{
if (direction != LogicalDirection.Forward &&
direction != LogicalDirection.Backward)
{
throw new InvalidEnumArgumentException(argumentName, (int)direction, typeof(LogicalDirection));
}
}
示例6: BplReferenceValue
/// <summary>Creates a new <see cref="BplReferenceValue"/> instance.</summary>
public BplReferenceValue(LogicalDirection direction, BplReferenceKind kind, string property, object reference) {
Direction = direction;
Kind = kind;
Property = property;
if (reference.IsA<BplObject>()) {
Path = new BplPropertyPath(reference).ToString();
}
}
示例7: GetNextCaretPosition
/// <inheritdoc/>
public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode)
{
int textOffset = parentVisualLine.StartOffset + this.RelativeTextOffset;
int pos = TextUtilities.GetNextCaretPosition(parentVisualLine.Document, textOffset + visualColumn - this.VisualColumn, direction, mode);
if (pos < textOffset || pos > textOffset + this.DocumentLength)
return -1;
else
return this.VisualColumn + pos - textOffset;
}
示例8: 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;
}
示例9: PasswordTextPointer
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
#region Constructors
// Creates a new PasswordTextPointer instance.
internal PasswordTextPointer(PasswordTextContainer container, LogicalDirection gravity, int offset)
{
Debug.Assert(offset >= 0 && offset <= container.SymbolCount, "Bad PasswordTextPointer offset!");
_container = container;
_gravity = gravity;
_offset = offset;
container.AddPosition(this);
}
示例10: GetNextCaretPosition
public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode)
{
// only place a caret stop before the newline, no caret stop after it
if (visualColumn > this.VisualColumn && direction == LogicalDirection.Backward ||
visualColumn < this.VisualColumn && direction == LogicalDirection.Forward)
{
return this.VisualColumn;
} else {
return -1;
}
}
示例11: GetTextInRun
// Worker for GetText, accepts any ITextPointer.
internal static string GetTextInRun(ITextPointer position, LogicalDirection direction)
{
char[] text;
int textLength;
int getTextLength;
textLength = position.GetTextRunLength(direction);
text = new char[textLength];
getTextLength = position.GetTextInRun(direction, text, 0, textLength);
Invariant.Assert(getTextLength == textLength, "textLengths returned from GetTextRunLength and GetTextInRun are innconsistent");
return new string(text);
}
示例12: TextGlyph
/// <summary>Creates a new <see cref="TextGlyph"/> instance from the given parameters.</summary>
public TextGlyph(string text, Font font, TextOverflow textOverflow, LogicalDirection textOverflowDirection, Vector sharpnessVector) {
Text = text;
Font = font;
TextOverflow = textOverflow;
TextOverflowDirection = textOverflowDirection;
SharpnessVector = sharpnessVector;
_prepareVisualText(Text);
var result = _buildGlyph(false, Double.PositiveInfinity);
if (result != null) {
_fullRun = result.GlyphRun;
Size = new Size(result.Width, result.Height);
Baseline = result.Baseline;
}
}
示例13: 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;
}
示例14: 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;
}
示例15:
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
/// <summary>
/// <see cref="ITextPointer.SetLogicalDirection"/>
/// </summary>
void ITextPointer.SetLogicalDirection(LogicalDirection direction)
{
Debug.Assert(!_isFrozen, "Can't reposition a frozen pointer!");
if (direction != _gravity)
{
// We need to remove the position from the container since we're
// going to change its gravity, which changes its internal sort order.
this.Container.RemovePosition(this);
_gravity = direction;
// Now start tracking the position again, at it's new sort order.
this.Container.AddPosition(this);
}
}