public static Vector ToVector(this SiblingDirection siblingDirection) { switch (siblingDirection) { case SiblingDirection.Up: return(new Vector(0, 1)); case SiblingDirection.Right: return(new Vector(1, 0)); case SiblingDirection.Down: return(new Vector(0, -1)); case SiblingDirection.Left: return(new Vector(-1, 0)); case SiblingDirection.UpRight: return(new Vector(1, 1)); case SiblingDirection.DownRight: return(new Vector(1, -1)); case SiblingDirection.DownLeft: return(new Vector(-1, -1)); case SiblingDirection.UpLeft: return(new Vector(-1, 1)); default: return(new Vector(0, 0)); } }
private void NavToSibling(ApplyContentEventArgs ea, SiblingDirection siblingDirection) { LanguageElement methodOrProperty = CodeRush.Source.ActiveMethodOrProperty; if (methodOrProperty == null) return; LanguageElement sibling = methodOrProperty; while (sibling != null) { if (siblingDirection == SiblingDirection.Next) sibling = sibling.NextCodeSibling; else sibling = sibling.PreviousCodeSibling; if (sibling is Method || sibling is Property) break; } if (sibling == null) { string msg; string searchItem; if (methodOrProperty is Property) searchItem = "properties"; else searchItem = "methods"; if (siblingDirection == SiblingDirection.Next) msg = String.Format("No more {0} below this location.", searchItem); // Translate: {0} is the item we're searching for (e.g., "properties" or "methods"). else msg = String.Format("No more {0} above this location.", searchItem); // Translate: {0} is the item we're searching for (e.g., "properties" or "methods"). CodeRush.ApplicationObject.StatusBar.Text = msg; return; } if (_Caret == null) _Caret = ElementLocation.From(methodOrProperty, CodeRush.Caret.SourcePoint); TextView textView = ea.TextView; if (textView == null) return; if (_Anchor == null) if (textView.Selection.Exists) _Anchor = ElementLocation.From(methodOrProperty, textView.Selection.AnchorSourcePoint); Restore(sibling, textView); }
public Pixel GetSibling(Pixel target, SiblingDirection siblingDirection, bool ofSameColorConstraint) { var vector = this.siblingDirectionToVectorMap[(int)siblingDirection]; return(this.GetSibling(target, vector, ofSameColorConstraint)); }
/// <summary> /// Returns a list of the siblings of this entity according to the selected direction. /// </summary> /// <typeparam name="T">Type of real entity</typeparam> /// <param name="references">References to find siblings</param> /// <param name="positionEnd">Determines end position</param> /// <param name="direction">Determines the direction of the search: Right, Left, or Start from the first brother</param> /// <returns>Returns a list of siblings of this entity</returns> public static IEnumerable <EntityItem <T> > Siblings <T>(this IEnumerable <EntityItem <T> > references, int positionEnd, SiblingDirection direction = SiblingDirection.Start) { foreach (var reference in references) { foreach (var item in reference.Siblings(positionEnd, direction)) { yield return(item); } } }
/// <summary> /// Returns a list of the siblings of this entity according to the selected direction. /// </summary> /// <typeparam name="T">Type of real entity</typeparam> /// <param name="references">References to find siblings</param> /// <param name="filter">Action to filter, you can remove what you do not need</param> /// <param name="stop">Action to stop the search when it returns TRUE.</param> /// <param name="direction">Determines the direction of the search: Right, Left, or Start from the first brother</param> /// <param name="positionStart">Determines start position</param> /// <param name="positionEnd">Determines end position</param> /// <returns>Returns a list of siblings of this entity</returns> public static IEnumerable <EntityItem <T> > Siblings <T>(this IEnumerable <EntityItem <T> > references, EntityItemFilterDelegate <T> filter, EntityItemFilterDelegate <T> stop = null, SiblingDirection direction = SiblingDirection.Start, int?positionStart = null, int?positionEnd = null) { foreach (var reference in references) { foreach (var item in reference.Siblings(filter, stop, direction, positionStart, positionEnd)) { yield return(item); } } }
/// <summary> /// Returns a list of the siblings of this entity according to the selected direction until stop /// </summary> /// <typeparam name="T">Type of real entity</typeparam> /// <param name="references">References to find siblings</param> /// <param name="stop">Action to stop the search when it returns TRUE.</param> /// <param name="filter">Action to filter, you can remove what you do not need</param> /// <param name="direction">Determines the direction of the search: Right, Left, or Start from the first brother</param> /// <returns>Returns a list of siblings of this entity</returns> public static IEnumerable <EntityItem <T> > SiblingsUntil <T>(this IEnumerable <EntityItem <T> > references, EntityItemFilterDelegate <T> stop, EntityItemFilterDelegate <T> filter = null, SiblingDirection direction = SiblingDirection.Start) { foreach (var reference in references) { foreach (var item in reference.SiblingsUntil(stop, filter, direction)) { yield return(item); } } }
public static Point ToDirection(this Point point, SiblingDirection direction) { return(point + direction.ToVector()); }