public void ShowPopup(string query, ICannedTextLookupHandler alternativeHandler) { ClosePopup(); Point pt = _textEditor.GetRichTextBox().GetPositionFromCharIndex(_textEditor.GetRichTextBox().SelectionStart); _handlerInUse = alternativeHandler ?? _defaultLookupHandler; _lookup = new CannedTextInplaceLookupControl(_handlerInUse); _lookup.Cancelled += _lookup_Cancelled; _lookup.Committed += _lookup_Committed; if (!string.IsNullOrEmpty(query)) _handlerInUse.SuggestionProvider.SetQuery(query); _popup = new PopupForm(_lookup, _textEditor.GetRichTextBox(), _textEditor.GetRichTextBox().PointToScreen(pt)); _popup.ShowPopup(); }
private void ClosePopup() { if (_popup != null) { _popup.ClosePopup(); _popup = null; } if (_lookup != null) { _lookup.Cancelled -= _lookup_Cancelled; _lookup.Committed -= _lookup_Committed; _lookup = null; } }