예제 #1
0
 protected virtual void NotifyTextChanged(
     string text,
     int caretPosition,
     TextBoxChangeAction action)
 {
     this.OnTextChanged((EventArgs) new TextBoxChangedEventArgs(text, caretPosition, action));
 }
예제 #2
0
        protected virtual bool NotifyTextChanging(
            int startPosition,
            int length,
            string oldText,
            string newText,
            TextBoxChangeAction action)
        {
            TextBoxChangingEventArgs changingEventArgs = new TextBoxChangingEventArgs(startPosition, length, oldText, newText, action);

            this.OnTextChanging((TextChangingEventArgs)changingEventArgs);
            return(!changingEventArgs.Cancel);
        }
예제 #3
0
 public TextBoxChangingEventArgs(
     int startPosition,
     int length,
     string oldText,
     string newText,
     TextBoxChangeAction action)
     : base(oldText, newText)
 {
     this.startPosition = startPosition;
     this.length        = length;
     this.action        = action;
 }
예제 #4
0
 public virtual void EndEditUpdate(
     bool notify,
     string newText,
     int caretPosition,
     TextBoxChangeAction action)
 {
     if (this.editingCount <= 0)
     {
         return;
     }
     --this.editingCount;
     if (!notify)
     {
         return;
     }
     this.NotifyTextChanged(newText, caretPosition, action);
 }
예제 #5
0
        public bool Replace(TextPosition startPosition, TextPosition endPosition, string text)
        {
            TextPosition.Swap(ref startPosition, ref endPosition);
            if (endPosition == (TextPosition)null && string.IsNullOrEmpty(text))
            {
                return(false);
            }
            TextBoxChangeAction action = TextBoxChangeAction.TextEdit;
            int    length    = TextPosition.GetLength(startPosition, endPosition);
            string textRange = this.GetTextRange(startPosition, endPosition);

            if (textRange == text || !this.NotifyTextChanging((int)startPosition, length, textRange, text, action))
            {
                return(false);
            }
            int caretPosition = (int)startPosition + (string.IsNullOrEmpty(text) ? 0 : text.Length);

            this.BeginEditUpdate();
            this.ReplaceOverride(startPosition, endPosition, text);
            this.InvalidateLayout();
            this.Invalidate();
            this.EndEditUpdate(true, text, caretPosition, action);
            return(true);
        }
예제 #6
0
 public TextBoxChangedEventArgs(string text, int caretPosition, TextBoxChangeAction action)
 {
     this.text          = text;
     this.action        = action;
     this.caretPosition = caretPosition;
 }