Esempio n. 1
0
        public CompletionPresenter(IImageMonikerService imageMonikerService, ICompletionSession session, ICompletionTextElementProvider completionTextElementProvider, Lazy <IUIElementProvider <Completion, ICompletionSession>, IOrderableContentTypeMetadata>[] completionUIElementProviders)
        {
            if (imageMonikerService == null)
            {
                throw new ArgumentNullException(nameof(imageMonikerService));
            }
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (completionTextElementProvider == null)
            {
                throw new ArgumentNullException(nameof(completionTextElementProvider));
            }
            if (completionUIElementProviders == null)
            {
                throw new ArgumentNullException(nameof(completionUIElementProviders));
            }
            this.imageMonikerService           = imageMonikerService;
            this.session                       = session;
            this.completionTextElementProvider = completionTextElementProvider;
            this.completionUIElementProviders  = completionUIElementProviders;
            this.control                       = new CompletionPresenterControl {
                DataContext = this
            };
            this.filters          = new List <FilterVM>();
            this.control.MinWidth = defaultMinWidth;
            this.control.completionsListBox.MaxHeight = defaultMaxHeight;
            session.SelectedCompletionSetChanged     += CompletionSession_SelectedCompletionSetChanged;
            session.Dismissed += CompletionSession_Dismissed;
            session.TextView.LostAggregateFocus            += TextView_LostAggregateFocus;
            session.TextView.TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority;
            this.wpfTextView = session.TextView as IWpfTextView;
            Debug.Assert(wpfTextView != null);
            if (wpfTextView != null)
            {
                wpfTextView.VisualElement.PreviewKeyDown += VisualElement_PreviewKeyDown;
            }
            session.TextView.LayoutChanged += TextView_LayoutChanged;
            control.completionsListBox.SelectionChanged += CompletionsListBox_SelectionChanged;
            control.completionsListBox.Loaded           += CompletionsListBox_Loaded;
            control.completionsListBox.PreviewMouseDown += CompletionsListBox_PreviewMouseDown;
            control.completionsListBox.PreviewMouseUp   += CompletionsListBox_PreviewMouseUp;
            control.completionsListBox.MouseLeave       += CompletionsListBox_MouseLeave;
            control.completionsListBox.MouseDoubleClick += CompletionsListBox_MouseDoubleClick;
            control.SizeChanged += Control_SizeChanged;
            control.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(Control_GotKeyboardFocus), true);

            toolTipTimer          = new DispatcherTimer(DispatcherPriority.Background, control.Dispatcher);
            toolTipTimer.Tick    += ToolTipTimer_Tick;
            toolTipTimer.Interval = TimeSpan.FromMilliseconds(toolTipDelayMilliSeconds);

            UpdateSelectedCompletion();
            UpdateFilterCollection();
        }
Esempio n. 2
0
 public CompletionPresenter(IImageManager imageManager, ICompletionSession session, ICompletionTextElementProvider completionTextElementProvider)
 {
     if (imageManager == null)
     {
         throw new ArgumentNullException(nameof(imageManager));
     }
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
     if (completionTextElementProvider == null)
     {
         throw new ArgumentNullException(nameof(completionTextElementProvider));
     }
     this.imageManager = imageManager;
     this.session      = session;
     this.completionTextElementProvider = completionTextElementProvider;
     this.control = new CompletionPresenterControl {
         DataContext = this
     };
     this.filters          = new List <FilterVM>();
     this.control.MinWidth = defaultMinWidth;
     this.control.completionsListBox.MaxHeight    = defaultMaxHeight;
     session.SelectedCompletionCollectionChanged += CompletionSession_SelectedCompletionCollectionChanged;
     session.Dismissed += CompletionSession_Dismissed;
     session.TextView.LostAggregateFocus            += TextView_LostAggregateFocus;
     session.TextView.TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority;
     this.wpfTextView = session.TextView as IWpfTextView;
     Debug.Assert(wpfTextView != null);
     if (wpfTextView != null)
     {
         wpfTextView.VisualElement.PreviewKeyDown += VisualElement_PreviewKeyDown;
     }
     control.completionsListBox.SelectionChanged += CompletionsListBox_SelectionChanged;
     control.completionsListBox.Loaded           += CompletionsListBox_Loaded;
     control.completionsListBox.PreviewMouseDown += CompletionsListBox_PreviewMouseDown;
     control.completionsListBox.PreviewMouseUp   += CompletionsListBox_PreviewMouseUp;
     control.completionsListBox.MouseLeave       += CompletionsListBox_MouseLeave;
     control.SizeChanged += Control_SizeChanged;
     control.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(Control_GotKeyboardFocus), true);
     UpdateSelectedCompletion();
     UpdateFilterCollection();
 }