Пример #1
0
 private void SetUpLookup()
 {
     _lookup = Mock.Of <IExtendedLookup>();
     Mock.Get(_lookup).Setup(l => l.DisplayedItems).Returns(LookupItemsMockUtils.MockLookupItemList(3));
     _mockLookupWindowManager = new Mock <IExtendedLookupWindowManager>();
     _mockLookupWindowManager.Setup(m => m.CurrentLookup).Returns(_lookup);
 }
 private void UnregisterFromLookupEvents(IExtendedLookup lookup)
 {
     lookup.BeforeShownItemsUpdated -= OnBeforeShownItemsUpdated;
     lookup.CurrentItemChanged      -= HandleCurrentItemChanged;
     lookup.Closed        -= HandleClosed;
     lookup.ItemCompleted -= HandleItemCompleted;
     lookup.MouseDown     -= HandleMouseDown;
 }
        private void OnBeforeLookupShown(object sender, EventArgs e)
        {
            FinishLifecycle();

            _currentLookup = _lookupWindowManager.CurrentLookup;
            _initialPrefix = _currentLookup.Prefix;
            _currentPrefix = _initialPrefix;
            OnTriggered(_initialPrefix, _currentLookup.DisplayedItems);
            RegisterToLookupEvents(_currentLookup);
        }
 private void FinishLifecycle()
 {
     _delayedCancelAction.RunNow();
     if (_currentLookup != null)
     {
         UnregisterFromLookupEvents(_currentLookup);
         _currentLookup = null;
     }
     _terminationTrigger = null;
 }
        private void RegisterToLookupEvents(IExtendedLookup lookup)
        {
            // Event handlers are registered in order of the actual events's occurence.

            lookup.BeforeShownItemsUpdated += OnBeforeShownItemsUpdated;
            lookup.CurrentItemChanged      += HandleCurrentItemChanged;

            // R# actions that lead to the completion being finished
            RegisterAction("ForceCompleteItem", () => _terminationTrigger = EventTrigger.Typing);
            RegisterAction(TextControlActions.ENTER_ACTION_ID, () => _terminationTrigger = EventTrigger.Shortcut);
            RegisterAction(TextControlActions.TAB_ACTION_ID, () => _terminationTrigger   = EventTrigger.Shortcut);
            lookup.MouseDown += HandleMouseDown;

            lookup.Closed        += HandleClosed;
            lookup.ItemCompleted += HandleItemCompleted;
        }