public void SetSpaceReservationManager(ISpaceReservationManager manager) {
				if (manager == null)
					throw new ArgumentNullException(nameof(manager));
				if (SpaceReservationManager != null)
					throw new InvalidOperationException();
				SpaceReservationManager = manager;
			}
 public PopupSpaceReservationAgent(ISpaceReservationManager spaceReservationManager, IWpfTextView wpfTextView, ITrackingSpan visualSpan, PopupStyles style, UIElement content)
 {
     if (spaceReservationManager == null)
     {
         throw new ArgumentNullException(nameof(spaceReservationManager));
     }
     if (visualSpan == null)
     {
         throw new ArgumentNullException(nameof(visualSpan));
     }
     if (content == null)
     {
         throw new ArgumentNullException(nameof(content));
     }
     if ((style & (PopupStyles.DismissOnMouseLeaveText | PopupStyles.DismissOnMouseLeaveTextOrContent)) == (PopupStyles.DismissOnMouseLeaveText | PopupStyles.DismissOnMouseLeaveTextOrContent))
     {
         throw new ArgumentOutOfRangeException(nameof(style));
     }
     this.spaceReservationManager = spaceReservationManager;
     this.wpfTextView             = wpfTextView;
     this.visualSpan = visualSpan;
     this.style      = style;
     this.content    = content;
     this.popup      = new Popup {
         PlacementTarget     = wpfTextView.VisualElement,
         Placement           = PlacementMode.Relative,
         Visibility          = Visibility.Collapsed,
         IsOpen              = false,
         AllowsTransparency  = true,
         UseLayoutRounding   = true,
         SnapsToDevicePixels = true,
     };
 }
Example #3
0
        private void HostSession(IIntellisenseSession session, IPopupIntellisensePresenter popupPresenter)
        {
            // If the Popup presenter doesn't have anything to draw, don't even bother.

            if (popupPresenter.SurfaceElement == null)
            {
                return;
            }

            ISpaceReservationManager manager = _textView.GetSpaceReservationManager(popupPresenter.SpaceReservationManagerName);

            if (manager != null)
            {
                // If this is the first time we've seen this manager, subscribe to its AgentChanged event.

                if (!_reservationManagerIndex.ContainsValue(manager))
                {
                    manager.AgentChanged += this.OnSpaceReservationManager_AgentChanged;
                }

                ISpaceReservationAgent agent = manager.CreatePopupAgent(popupPresenter.PresentationSpan,
                                                                        popupPresenter.PopupStyles,
                                                                        popupPresenter.SurfaceElement);

                // We'll need to hold-on to the manager and agent so that later, when we want to hide this popup, we can clear
                // the agent.

                _reservationManagerIndex[agent] = manager;
                _reservationAgentIndex[session] = agent;

                // When we add this agent to the manager's collection, the popup will become visible.

                manager.AddAgent(agent);
            }
        }
 public void SetSpaceReservationManager(ISpaceReservationManager manager)
 {
     if (SpaceReservationManager is not null)
     {
         throw new InvalidOperationException();
     }
     SpaceReservationManager = manager ?? throw new ArgumentNullException(nameof(manager));
 }
Example #5
0
#pragma warning restore 0169

        public ToolTipProvider(IWpfTextView wpfTextView)
        {
            if (wpfTextView == null)
            {
                throw new ArgumentNullException(nameof(wpfTextView));
            }
            this.wpfTextView             = wpfTextView;
            this.spaceReservationManager = wpfTextView.GetSpaceReservationManager(PredefinedSpaceReservationManagerNames.ToolTip);
        }
Example #6
0
        private void RehostSession(IIntellisenseSession session)
        {
            IPopupIntellisensePresenter popupPresenter = session.Presenter as IPopupIntellisensePresenter;

            if (popupPresenter == null)
            {
                throw new ArgumentException("Expected to rehost a session with presenter of type IPopupIntellisensePresenter",
                                            "session");
            }

            // If the Popup presenter doesn't have anything to draw, don't even bother.

            if (popupPresenter.PresentationSpan == null || popupPresenter.SurfaceElement == null)
            {
                return;
            }

            // We need to re-draw this popup.  This involves tearing down the old agent and re-creating it.  First, we've
            // got to find it.  We'll also want to save-off a reference to it so that we know we're re-hosting this session.  The
            // process of tearing-down and re-adding a space reservation agent is loud and messy.  We don't want to accidentally
            // dismiss this session, thinking that it went out-of-focus.

            _sessionBeingRehosted = session;

            try
            {
                ISpaceReservationAgent oldAgent = null;
                if ((_reservationAgentIndex.TryGetValue(session, out oldAgent)) && (oldAgent != null))
                {
                    ISpaceReservationManager manager = null;
                    if ((_reservationManagerIndex.TryGetValue(oldAgent, out manager)) && (manager != null))
                    {
                        manager.UpdatePopupAgent(oldAgent, popupPresenter.PresentationSpan, popupPresenter.PopupStyles);
                    }
                }
                else
                {
                    // This presenter hasn't yet been hosted in a popup.  Host it for the first time.

                    this.HostSession(session, popupPresenter);
                }
            }
            finally
            {
                // Clear out our state.  We're no longer re-hosting this session.

                _sessionBeingRehosted = null;
            }
        }
Example #7
0
        public PopupAgent(SkiaTextView textView, ISpaceReservationManager manager, ITrackingSpan visualSpan, PopupStyles style, Widget content)
        {
            if (textView == null)
            {
                throw new ArgumentNullException("textView");
            }
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (visualSpan == null)
            {
                throw new ArgumentNullException("visualSpan");
            }
            if (((int)style & ~(0xff)) != 0)        //Union of all the legal style bits.
            {
                throw new ArgumentOutOfRangeException("style");
            }
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if ((style & PopupStyles.DismissOnMouseLeaveText) != 0 && (style & PopupStyles.DismissOnMouseLeaveTextOrContent) != 0)
            {
                throw new ArgumentException("Can't specify both PopupStyles.DismissOnMouseLeaveText and PopupStyles.DismissOnMouseLeaveTextOrContent", "style");
            }

            _textView   = textView;
            _manager    = manager;
            _visualSpan = visualSpan;
            _style      = style;

            var popupCache = textView.Properties.GetOrCreateSingletonProperty <Dictionary <WeakReferenceForDictionaryKey, PopupOrWindowContainer> >(
                () => new Dictionary <WeakReferenceForDictionaryKey, PopupOrWindowContainer>(MaxPopupCacheSize));

            if (!popupCache.TryGetValue(new WeakReferenceForDictionaryKey(content), out _popup))
            {
                // _popup = PopupOrWindowContainer.Create(content, _textView.VisualElement);

                if (popupCache.Count == MaxPopupCacheSize)
                {
                    popupCache.Clear();
                }
                popupCache.Add(new WeakReferenceForDictionaryKey(content), _popup);
            }
        }
Example #8
0
#pragma warning restore 0169

		public ToolTipProvider(IWpfTextView wpfTextView) {
			if (wpfTextView == null)
				throw new ArgumentNullException(nameof(wpfTextView));
			this.wpfTextView = wpfTextView;
			spaceReservationManager = wpfTextView.GetSpaceReservationManager(PredefinedSpaceReservationManagerNames.ToolTip);
		}
Example #9
0
 internal ToolTipProvider(IMdTextView textView)
 {
     _textView = textView;
     _spaceReservationManager = _textView.GetSpaceReservationManager("ToolTip");
     _spaceReservationManager.AgentChanged += OnAgentChanged;
 }