private void ApplyAutocomplete(AutocompleteItem item, Range fragment) { string newText = item.GetTextForReplace(); //replace text of fragment fragment.Text = newText; fragment.TargetWrapper.TargetControl.Focus(); }
public void AddItem(AutocompleteItem item) { if (sourceItems == null) { sourceItems = new List <AutocompleteItem>(); } if (sourceItems is IList) { (sourceItems as IList).Add(item); } else { throw new Exception("Current autocomplete items does not support adding"); } }
internal virtual void OnSelecting() { if (SelectedItemIndex < 0 || SelectedItemIndex >= VisibleItems.Count) { return; } AutocompleteItem item = VisibleItems[SelectedItemIndex]; var args = new SelectingEventArgs { Item = item, SelectedIndex = SelectedItemIndex }; OnSelecting(args); if (args.Cancel) { SelectedItemIndex = args.SelectedIndex; (Host.ListView as Control).Invalidate(true); return; } if (!args.Handled) { Range fragment = Fragment; ApplyAutocomplete(item, fragment); } Close(); var args2 = new SelectedEventArgs { Item = item, Control = TargetControlWrapper.TargetControl }; item.OnSelected(args2); OnSelected(args2); }
public void SetToolTip(AutocompleteItem autocompleteItem) { string title = autocompleteItem.ToolTipTitle; string text = autocompleteItem.ToolTipText; if (string.IsNullOrEmpty(title)) { toolTip.ToolTipTitle = null; toolTip.SetToolTip(this, null); return; } if (string.IsNullOrEmpty(text)) { toolTip.ToolTipTitle = null; toolTip.Show(title, this, Width + 3, 0, ToolTipDuration); } else { toolTip.ToolTipTitle = title; toolTip.Show(text, this, Width + 3, 0, ToolTipDuration); } }
public int CompareTo(object obj) { AutocompleteItem info = obj as AutocompleteItem; return(this.SortIndex.CompareTo(info.SortIndex)); }