OnSelected() public method

This method is called after item was inserted into text
public OnSelected ( SelectedEventArgs e ) : void
e SelectedEventArgs
return void
Exemplo n.º 1
0
        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;

                if (item is IAutoCompleteMenuItemCustomReplace customReplace)
                {
                    fragment       = new Range(TargetControlWrapper);
                    fragment.Start = TargetControlWrapper.SelectionStart + TargetControlWrapper.SelectionLength - customReplace.ReplaceLength;
                    fragment.End   = fragment.Start + customReplace.ReplaceLength;
                }

                ApplyAutocomplete(item, fragment);
            }

            Close();
            //
            var args2 = new SelectedEventArgs
            {
                Item    = item,
                Control = TargetControlWrapper.TargetControl
            };

            item.OnSelected(args2);
            OnSelected(args2);
        }
Exemplo n.º 2
0
        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(TargetControl, item, fragment);
            }

            Close();
            //
            var args2 = new SelectedEventArgs
            {
                Item    = item,
                Control = TargetControl
            };

            item.OnSelected(args2);
            OnSelected(args2);
        }