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); }
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; }
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; } } }
public EditableTextBox(ITextBoxWrapper input, ISwappableTextboxStrategy swappableTextboxStrategy, EditableStatus regularMode) { _textBox = input; TrueControl = _textBox.TrueControl; _swappableTextboxStrategy = swappableTextboxStrategy; _status = regularMode; if (_status == EditableStatus.Regular) { EnterRegularMode(); } else { EnterEditMode(); } }
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; } } }
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); }
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; }
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); }
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); }
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; } } }
public IEditableTextBox Create(ITextBoxWrapper input, ISwappableTextboxStrategy swappableTextboxStrategy, EditableStatus regularMode = EditableStatus.Regular) { return(new EditableTextBox(input, swappableTextboxStrategy, regularMode)); }
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); } } }
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; }
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); }
public Range(ITextBoxWrapper targetWrapper) { TargetWrapper = targetWrapper; }
public Range(ITextBoxWrapper targetWrapper) { this.TargetWrapper = targetWrapper; }
public void Setup(EditableStatus status) { _textBoxWrapper = A.Fake <ITextBoxWrapper>(); _swappableTextboxStrategy = A.Fake <ISwappableTextboxStrategy>(); _editableTextBox = new EditableTextBox(_textBoxWrapper, _swappableTextboxStrategy, status); }