Beispiel #1
0
        public virtual bool Select(TextPosition start, TextPosition end)
        {
            if (start == (TextPosition)null && end != (TextPosition)null)
            {
                throw new ArgumentNullException(nameof(start));
            }
            if (object.Equals((object)start, (object)end))
            {
                end = (TextPosition)null;
            }
            if (object.Equals((object)this.SelectionStart, (object)start) && object.Equals((object)this.SelectionEnd, (object)end))
            {
                this.SetCaretPosition();
                return(false);
            }
            bool notify = this.SelectionStart != (TextPosition)null;

            if (notify)
            {
                int length = TextPosition.GetLength(start, end);
                SelectionChangingEventArgs e = new SelectionChangingEventArgs(this.textBoxElement.SelectionStart, this.SelectionLength, end == (TextPosition)null ? (int)start : Math.Min((int)start, (int)end), length);
                this.OnSelectionChanging(e);
                if (e.Cancel)
                {
                    return(false);
                }
            }
            this.selectionStart = start;
            this.selectionEnd   = end;
            this.SelectOverride(notify);
            return(true);
        }
Beispiel #2
0
        protected virtual void OnSelectionChanging(SelectionChangingEventArgs e)
        {
            SelectionChangingEventHandler selectionChanging = this.SelectionChanging;

            if (selectionChanging == null || this.suspendNotificationCount != 0)
            {
                return;
            }
            selectionChanging((object)this, e);
        }
Beispiel #3
0
 private void Navigator_SelectionChanging(object sender, SelectionChangingEventArgs e)
 {
     this.changed = true;
 }