/// <summary> /// 新输入 /// </summary> /// <param name="insertion"></param> /// <returns></returns> public override bool Insert(string insertion) { RegExpMaskManagerState state; MaskManagerStated.StateChangeType changeType = ((insertion.Length == 0) && base.IsSelection) ? MaskManagerStated.StateChangeType.Delete : MaskManagerStated.StateChangeType.Insert; string head = GetCurrentEditText().Substring(0, base.DisplaySelectionStart); string replaced = GetCurrentEditText().Substring(base.DisplaySelectionStart, base.DisplaySelectionLength); string tail = GetCurrentEditText().Substring(base.DisplaySelectionEnd); MaskLogicResult result = _logic.GetReplaceResult(head, replaced, tail, insertion); if (result == null) { return(false); } if (_reverseDfa) { state = new RegExpMaskManagerState(result.EditText, base.DisplaySelectionStart, base.DisplaySelectionStart); } else if ((_isOptimistic && (changeType == MaskManagerStated.StateChangeType.Insert)) && (tail.Length == 0)) { string editText = _logic.OptimisticallyExpand(result.EditText); state = new RegExpMaskManagerState(editText, result.CursorPosition, editText.Length); } else { state = new RegExpMaskManagerState(result.EditText, result.CursorPosition, result.CursorPosition); } return(base.Apply(state, changeType)); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <param name="changeType"></param> /// <returns></returns> protected bool Apply(MaskLogicResult result, MaskManagerStated.StateChangeType changeType) { if (result == null) { return(false); } return(base.Apply(new RegExpMaskManagerState(result.EditText, result.CursorPosition, result.CursorPosition), changeType)); }
/// <summary> /// /// </summary> /// <param name="editText"></param> /// <param name="cursorPosition"></param> /// <param name="selectionAnchor"></param> /// <param name="changeType"></param> /// <returns></returns> protected bool Apply(string editText, int cursorPosition, int selectionAnchor, MaskManagerStated.StateChangeType changeType) { return(base.Apply(new RegExpMaskManagerState(editText, cursorPosition, selectionAnchor), changeType)); }