private protected virtual string GetFocusedStringContent(IFocusStringContentFocus textCellFocus) { IFocusStringContentFocusableCellView CellView = textCellFocus.CellView; Node Node = CellView.StateView.State.Node; string PropertyName = CellView.PropertyName; return(NodeTreeHelper.GetString(Node, PropertyName)); }
/// <summary> /// Changes the value of a text. The caret position is also moved for this view and other views where the caret is at the same focus and position. /// </summary> /// <param name="newText">The new text.</param> /// <param name="newCaretPosition">The new caret position.</param> /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param> public virtual void ChangeFocusedText(string newText, int newCaretPosition, bool changeCaretBeforeText) { Debug.Assert(Focus is IFocusTextFocus); bool IsHandled = false; IFocusNodeState State = Focus.CellView.StateView.State; IFocusIndex ParentIndex = State.ParentIndex; int OldCaretPosition = CaretPosition; if (Focus is IFocusStringContentFocus AsStringContentFocus) { IFocusStringContentFocusableCellView CellView = AsStringContentFocus.CellView; IFocusTextValueFrame Frame = CellView.Frame as IFocusTextValueFrame; Debug.Assert(Frame != null); if (Frame.AutoFormat) { switch (AutoFormatMode) { case AutoFormatModes.None: IsHandled = true; break; case AutoFormatModes.FirstOnly: newText = StringHelper.FirstOnlyFormattedText(newText); IsHandled = true; break; case AutoFormatModes.FirstOrAll: newText = StringHelper.FirstOrAllFormattedText(newText); IsHandled = true; break; case AutoFormatModes.AllLowercase: newText = StringHelper.AllLowercaseFormattedText(newText); IsHandled = true; break; } } else { IsHandled = true; } Controller.ChangeTextAndCaretPosition(ParentIndex, AsStringContentFocus.CellView.PropertyName, newText, OldCaretPosition, newCaretPosition, changeCaretBeforeText); } else if (Focus is IFocusCommentFocus AsCommentFocus) { Controller.ChangeCommentAndCaretPosition(ParentIndex, newText, OldCaretPosition, newCaretPosition, changeCaretBeforeText); IsHandled = true; } Debug.Assert(IsHandled); }
private protected virtual void SetTextFullSelection(IFocusTextFocus textFocus) { bool IsHandled = false; if (textFocus is IFocusStringContentFocus AsStringContentFocus) { string Text = GetFocusedStringContent(AsStringContentFocus); IFocusStringContentFocusableCellView CellView = AsStringContentFocus.CellView; SelectStringContent(CellView.StateView, CellView.PropertyName, 0, Text.Length); IsHandled = true; } else if (textFocus is IFocusCommentFocus AsCommentFocus) { string Text = GetFocusedCommentText(AsCommentFocus); IFocusCommentCellView CellView = AsCommentFocus.CellView; SelectComment(CellView.StateView, 0, Text.Length); IsHandled = true; } Debug.Assert(IsHandled); }
private protected virtual void SetTextSelection(IFocusTextFocus textFocus) { bool IsHandled = false; int Start = CaretAnchorPosition >= 0 ? CaretAnchorPosition : 0; int End = CaretPosition; if (textFocus is IFocusStringContentFocus AsStringContentFocus) { IFocusStringContentFocusableCellView CellView = AsStringContentFocus.CellView; SelectStringContent(CellView.StateView, CellView.PropertyName, Start, End); IsHandled = true; } else if (textFocus is IFocusCommentFocus AsCommentFocus) { IFocusCommentCellView CellView = AsCommentFocus.CellView; SelectComment(CellView.StateView, Start, End); IsHandled = true; } Debug.Assert(IsHandled); }
/// <summary> /// Initializes a new instance of the <see cref="FocusStringContentFocus"/> class. /// </summary> public FocusStringContentFocus(IFocusStringContentFocusableCellView cellView) : base(cellView) { }
private protected virtual bool IsNewItemInsertableAtStringContentCellView(IFocusNodeState state, IFocusStringContentFocusableCellView cellView, out IFocusCollectionInner inner, out IFocusInsertionCollectionNodeIndex index) { inner = null; index = null; bool Result = false; if (CaretPosition == 0) { Result = IsListExtremumItem(state, cellView, IsFirstFocusableCellView, InsertAbove, out inner, out index); } else if (CaretPosition == MaxCaretPosition) { Result = IsListExtremumItem(state, cellView, IsLastFocusableCellView, InsertBelow, out inner, out index); } return(Result); }