/// <summary> /// Specifies whether this object can provide its extender properties to the specified object. /// </summary> /// <param name="extendee">The <see cref="T:System.Object" /> to receive the extender properties.</param> /// <returns>true if this object can provide extender properties to the specified object; otherwise, false.</returns> bool IExtenderProvider.CanExtend(object extendee) { //find ZeroitAutocompleteMenu with lowest hashcode if (Container != null) { foreach (object comp in Container.Components) { if (comp is ZeroitAutocompleteMenu) { if (comp.GetHashCode() < GetHashCode()) { return(false); } } } } //we are main autocomplete menu on form ... //check extendee as TextBox if (!(extendee is Control)) { return(false); } var temp = TextBoxWrapper.Create(extendee as Control); return(temp != null); }
/// <summary> /// Handles the <see cref="E:WrapperNeeded" /> event. /// </summary> /// <param name="args">The <see cref="WrapperNeededEventArgs"/> instance containing the event data.</param> protected void OnWrapperNeeded(WrapperNeededEventArgs args) { if (WrapperNeeded != null) { WrapperNeeded(this, args); } if (args.Wrapper == null) { args.Wrapper = TextBoxWrapper.Create(args.TargetControl); } }
/// <summary> /// Creates the specified target control. /// </summary> /// <param name="targetControl">The target control.</param> /// <returns>TextBoxWrapper.</returns> public static TextBoxWrapper Create(Control targetControl) { var result = new TextBoxWrapper(targetControl); if (result.selectedText == null || result.selectionLength == null || result.selectionStart == null || result.getPositionFromCharIndex == null) { return(null); } return(result); }