Ejemplo n.º 1
0
			/// <summary> Gets the box the caret can move to from the glyph run next to the box composition to move into. </summary>
			private static BoxViewModel getBoxInto(InputCommandParameter caretState, bool boxesTraversalDirection)
			{
				//Contract.Assert(caretState.CurrentBox.Elements[caretState.Caret.position.ElementIndex] == caretState.GlyphRun);

				ElementIndex boxCompositionIndex = caretState.Caret.position.ElementIndex + (boxesTraversalDirection ? 1 : -1);				//update 2-June-15:
				if (boxCompositionIndex < 0 || boxCompositionIndex >= caretState.CaretBox.Elements.ElementCount)							//these two requirements can probably be performed by the new
					return null;																											//CanExecuteRequirements (CaretAtBoxCompositionStart/End)
																																			//
				BoxCompositionViewModel boxComposition = caretState.CaretBox.Elements[boxCompositionIndex] as BoxCompositionViewModel;		//But this works, so why change it now...
				if (boxComposition == null)																									//
					return null;																											//

				return GetPreferredBoxes(boxComposition, boxesTraversalDirection ? 0 : (boxComposition.Count - 1), boxesTraversalDirection).FirstOrDefault(box => box.Modifiable);
			}
Ejemplo n.º 2
0
			/// <summary> Gets the box the caret can move to from an adjacent box in the same box composition. </summary>
			private static BoxViewModel getAdjacentBox(InputCommandParameter caretState, bool boxesTraversalDirection)
			{
				//Contract.Assert(caretState.CurrentBox.Elements[caretState.Caret.position.ElementIndex] == caretState.GlyphRun);

				var boxComposition = caretState.CaretBox.BoxParent;
				Contract.Assert(boxComposition != null);

				var result = GetPreferredBoxes(boxComposition, boxComposition.Boxes.IndexOf(caretState.CaretBox), boxesTraversalDirection).Skip(1/*skips current box*/).FirstOrDefault(box => box.Modifiable);
				return result;
			}
Ejemplo n.º 3
0
			/// <summary> Focuses on the box parent in the specified direction. </summary>
			/// <param name="caretState"> The box parent of the box composition this glyphrun is in, will be focused on. </param>
			/// <param name="traversalDirection"> The direction in which the caret moves out of the box (true for right, false for left). </param>
			private static void boxOut(InputCommandParameter caretState, bool traversalDirection)
			{
				Contract.Requires(!caretState.CaretBox.IsRoot);
				Contract.Requires(caretState.CaretBox.BoxParent != null);

				BoxCompositionViewModel parentBoxComposition = caretState.CaretBox.BoxParent;
				BoxViewModel parentBox = parentBoxComposition.Box;

				ExplicitIndex newCaretIndex = new ExplicitIndex(parentBoxComposition, traversalDirection ? InternalIndex.Last : InternalIndex.First);
				parentBox.Focus(newCaretIndex);
			}