Example #1
0
        void SubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null)
            {
                return;
            }
            var form = wrapper.TargetControl.FindForm();

            if (form == null)
            {
                return;
            }
            if (myForm != null)
            {
                if (myForm == form)
                {
                    return;
                }
                UnsubscribeForm(wrapper);
            }

            myForm = form;

            form.LocationChanged += new EventHandler(form_LocationChanged);
            form.ResizeBegin     += new EventHandler(form_LocationChanged);
            form.FormClosing     += new FormClosingEventHandler(form_FormClosing);
            form.LostFocus       += new EventHandler(form_LocationChanged);
        }
Example #2
0
 private void UnsubscribeWrapper(ITextBoxWrapper wrapper, AutocompleteMenu menu)
 {
     wrapper.LostFocus -= menu.control_LostFocus;
     wrapper.Scroll    -= menu.control_Scroll;
     wrapper.KeyDown   -= menu.control_KeyDown;
     wrapper.MouseDown -= menu.control_MouseDown;
 }
Example #3
0
        private void SubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null)
            {
                return;
            }
            Form form = wrapper.TargetControl.FindForm();

            if (form == null)
            {
                return;
            }
            if (myForm != null)
            {
                if (myForm == form)
                {
                    return;
                }
                UnsubscribeForm(wrapper);
            }

            myForm = form;

            form.LocationChanged += form_LocationChanged;
            form.ResizeBegin     += form_LocationChanged;
            form.FormClosing     += form_FormClosing;
            form.LostFocus       += form_LocationChanged;
        }
 public void SetAutocompleteMenu(Control control, AutocompleteMenu menu)
 {
     if (menu != null)
     {
         var wrapper = menu.CreateWrapper(control);
         if (wrapper == null)
         {
             return;
         }
         //
         menu.SubscribeForm(wrapper);
         AutocompleteMenuByControls[control] = this;
         //
         wrapper.LostFocus += menu.control_LostFocus;
         wrapper.Scroll    += menu.control_Scroll;
         wrapper.KeyDown   += menu.control_KeyDown;
         wrapper.MouseDown += menu.control_MouseDown;
     }
     else
     {
         AutocompleteMenuByControls.TryGetValue(control, out menu);
         AutocompleteMenuByControls.Remove(control);
         ITextBoxWrapper wrapper = null;
         WrapperByControls.TryGetValue(control, out wrapper);
         WrapperByControls.Remove(control);
         if (wrapper != null && menu != null)
         {
             wrapper.LostFocus -= menu.control_LostFocus;
             wrapper.Scroll    -= menu.control_Scroll;
             wrapper.KeyDown   -= menu.control_KeyDown;
             wrapper.MouseDown -= menu.control_MouseDown;
         }
     }
 }
Example #5
0
 public EditableTextBox(ITextBoxWrapper input, ISwappableTextboxStrategy swappableTextboxStrategy, EditableStatus regularMode)
 {
     _textBox    = input;
     TrueControl = _textBox.TrueControl;
     _swappableTextboxStrategy = swappableTextboxStrategy;
     _status = regularMode;
     if (_status == EditableStatus.Regular)
     {
         EnterRegularMode();
     }
     else
     {
         EnterEditMode();
     }
 }
Example #6
0
 public void SetCodeSense(Control control, codesense menu)
 {
     if (menu != null)
     {
         if (WrapperByControls.ContainsKey(control))
         {
             return;
         }
         var wrapper = menu.CreateWrapper(control);
         if (wrapper == null)
         {
             return;
         }
         //
         if (control.IsHandleCreated)
         {
             menu.SubscribeForm(wrapper);
         }
         else
         {
             control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper);
         }
         //
         CodeSenseByControls[control] = this;
         //
         wrapper.LostFocus += menu.control_LostFocus;
         wrapper.Scroll    += menu.control_Scroll;
         wrapper.KeyDown   += menu.control_KeyDown;
         wrapper.MouseDown += menu.control_MouseDown;
     }
     else
     {
         CodeSenseByControls.TryGetValue(control, out menu);
         CodeSenseByControls.Remove(control);
         ITextBoxWrapper wrapper = null;
         WrapperByControls.TryGetValue(control, out wrapper);
         WrapperByControls.Remove(control);
         if (wrapper != null && menu != null)
         {
             wrapper.LostFocus -= menu.control_LostFocus;
             wrapper.Scroll    -= menu.control_Scroll;
             wrapper.KeyDown   -= menu.control_KeyDown;
             wrapper.MouseDown -= menu.control_MouseDown;
         }
     }
 }
Example #7
0
        void UnsubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null)
            {
                return;
            }
            var form = wrapper.TargetControl.FindForm();

            if (form == null)
            {
                return;
            }

            form.LocationChanged -= new EventHandler(form_LocationChanged);
            form.ResizeBegin     -= new EventHandler(form_LocationChanged);
            form.FormClosing     -= new FormClosingEventHandler(form_FormClosing);
            form.LostFocus       -= new EventHandler(form_LocationChanged);
        }
Example #8
0
        private void UnsubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null)
            {
                return;
            }
            var form = wrapper.TargetControl.FindForm();

            if (form == null)
            {
                return;
            }

            form.LocationChanged -= form_LocationChanged;
            form.ResizeBegin     -= form_LocationChanged;
            form.FormClosing     -= form_FormClosing;
            form.LostFocus       -= form_LocationChanged;
        }
Example #9
0
        public ITextBoxWrapper SwapTo(ITextBoxWrapper control, bool regularMode)
        {
            ITextBoxWrapper output;

            if (regularMode)
            {
//                control.Enter += OnEnter;
                control.TextChanged -= OnTextChanged;
                output = _propertyApplier.Apply(control, _regularProperties) as ITextBoxWrapper;
                //OnTextChanged(output, null);
            }
            else
            {
//                control.Enter -= OnEnter;
                control.TextChanged += OnTextChanged;
                output = _propertyApplier.Apply(control, _inEditProperties) as ITextBoxWrapper;
            }
            return(output);
        }
Example #10
0
        private Range GetFragment(string searchPattern)
        {
            ITextBoxWrapper tb = TargetControlWrapper;

            if (tb.SelectionLength > 0)
            {
                return(new Range(tb));
            }

            string text   = tb.Text;
            var    regex  = new Regex(searchPattern);
            var    result = new Range(tb);

            int startPos = tb.SelectionStart;
            //go forward
            int i = startPos;

            while (i >= 0 && i < text.Length)
            {
                if (!regex.IsMatch(text[i].ToString()))
                {
                    break;
                }
                i++;
            }
            result.End = i;

            //go backward
            i = startPos;
            while (i > 0 && (i - 1) < text.Length)
            {
                if (!regex.IsMatch(text[i - 1].ToString()))
                {
                    break;
                }
                i--;
            }
            result.Start = i;

            return(result);
        }
Example #11
0
        public override void OnSelected(SelectedEventArgs e)
        {
            ITextBoxWrapper tb = Parent.TargetControlWrapper;

            //
            if (!Text.Contains("^"))
            {
                return;
            }
            string text = tb.Text;

            for (int i = Parent.Fragment.Start; i < text.Length; i++)
            {
                if (text[i] == '^')
                {
                    tb.SelectionStart  = i;
                    tb.SelectionLength = 1;
                    tb.SelectedText    = "";
                    return;
                }
            }
        }
Example #12
0
 public IEditableTextBox Create(ITextBoxWrapper input, ISwappableTextboxStrategy swappableTextboxStrategy,
                                EditableStatus regularMode = EditableStatus.Regular)
 {
     return(new EditableTextBox(input, swappableTextboxStrategy, regularMode));
 }
Example #13
0
 public void SetAutocompleteMenu(Control control, AutocompleteMenu menu)
 {
     if (menu != null)
     {
         if (WrapperByControls.ContainsKey(control))
         {
             var wrapper = WrapperByControls[control];
             if (wrapper == null)
             {
                 return;
             }
             //
             if (control.IsHandleCreated)
             {
                 menu.SubscribeForm(wrapper);
             }
             else
             {
                 control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper);
             }
             //
             AutocompleteMenuByControls[control] = this;
             //
             UnsubscribeWrapper(wrapper, menu);
             SubscribeWrapper(wrapper, menu);
         }
         else
         {
             var wrapper = menu.CreateWrapper(control);
             if (wrapper == null)
             {
                 return;
             }
             //
             if (control.IsHandleCreated)
             {
                 menu.SubscribeForm(wrapper);
             }
             else
             {
                 control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper);
             }
             //
             AutocompleteMenuByControls[control] = this;
             //
             UnsubscribeWrapper(wrapper, menu);
             SubscribeWrapper(wrapper, menu);
         }
     }
     else
     {
         AutocompleteMenuByControls.TryGetValue(control, out menu);
         AutocompleteMenuByControls.Remove(control);
         ITextBoxWrapper wrapper = null;
         WrapperByControls.TryGetValue(control, out wrapper);
         WrapperByControls.Remove(control);
         if (wrapper != null && menu != null)
         {
             UnsubscribeWrapper(wrapper, menu);
         }
     }
 }
Example #14
0
        private void UnsubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null) return;
            Form form = wrapper.TargetControl.FindForm();
            if (form == null) return;

            form.LocationChanged -= form_LocationChanged;
            form.ResizeBegin -= form_LocationChanged;
            form.FormClosing -= form_FormClosing;
            form.LostFocus -= form_LocationChanged;
        }
Example #15
0
        private void SubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null) return;
            Form form = wrapper.TargetControl.FindForm();
            if (form == null) return;
            if (myForm != null)
            {
                if (myForm == form)
                    return;
                UnsubscribeForm(wrapper);
            }

            myForm = form;

            form.LocationChanged += form_LocationChanged;
            form.ResizeBegin += form_LocationChanged;
            form.FormClosing += form_FormClosing;
            form.LostFocus += form_LocationChanged;
        }
        void UnsubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null) return;
            var form = wrapper.TargetControl.FindForm();
            if (form == null) return;

            form.LocationChanged -= new EventHandler(form_LocationChanged);
            form.ResizeBegin -= new EventHandler(form_LocationChanged);
            form.FormClosing -= new FormClosingEventHandler(form_FormClosing);
            form.LostFocus -= new EventHandler(form_LocationChanged);
        }
        void SubscribeForm(ITextBoxWrapper wrapper)
        {
            if (wrapper == null) return;
            var form = wrapper.TargetControl.FindForm();
            if (form == null) return;
            if (myForm != null)
            {
                if (myForm == form)
                    return;
                UnsubscribeForm(wrapper);
            }

            myForm = form;

            form.LocationChanged += new EventHandler(form_LocationChanged);
            form.ResizeBegin += new EventHandler(form_LocationChanged);
            form.FormClosing += new FormClosingEventHandler(form_FormClosing);
            form.LostFocus += new EventHandler(form_LocationChanged);
        }
Example #18
0
 public Range(ITextBoxWrapper targetWrapper)
 {
     TargetWrapper = targetWrapper;
 }
Example #19
0
 public Range(ITextBoxWrapper targetWrapper)
 {
     this.TargetWrapper = targetWrapper;
 }
Example #20
0
 public void Setup(EditableStatus status)
 {
     _textBoxWrapper           = A.Fake <ITextBoxWrapper>();
     _swappableTextboxStrategy = A.Fake <ISwappableTextboxStrategy>();
     _editableTextBox          = new EditableTextBox(_textBoxWrapper, _swappableTextboxStrategy, status);
 }