Exemple #1
0
        void QuickInfoSession_Disposed(object sender, EventArgs e)
        {
            var session = (QuickInfoSession)sender;

            session.Disposed -= QuickInfoSession_Disposed;
            if (session == currentQuickInfoSession)
            {
                currentQuickInfoSession = null;
            }
        }
Exemple #2
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            var qiSession = QuickInfoSession.TryGetSession(session);

            if (qiSession == null)
            {
                // Mouse hovered over something and the default quick info controller created
                // a quick info session.

                if (session.Properties.ContainsProperty(hasTriggeredQuickInfoKey))
                {
                    return;
                }
                session.Properties.AddProperty(hasTriggeredQuickInfoKey, null);

                var point = session.GetTriggerPoint(session.TextView.TextSnapshot);
                if (point != null)
                {
                    quickInfoTriggerServiceProvider.Create(session.TextView).TryTrigger(point.Value, session.TrackMouse);
                }
                return;
            }

            // The item has been fetched async, now show it to the user
            // It's possible for another quick info session to already be active, eg. when
            // hovering over a url in a string, so close it.
            quickInfoTriggerServiceProvider.CloseOtherSessions(session);

            var item = qiSession.Item;

            Debug.Assert(item != null);
            if (item == null)
            {
                return;
            }
            var info = qiSession.State;

            Debug.Assert(item.TextSpan.End <= info.Snapshot.Length);
            if (item.TextSpan.End > info.Snapshot.Length)
            {
                return;
            }

            applicableToSpan = info.Snapshot.CreateTrackingSpan(item.TextSpan.ToSpan(), SpanTrackingMode.EdgeInclusive);
            foreach (var o in quickInfoContentCreatorProvider.Create(session.TextView).Create(item))
            {
                quickInfoContent.Add(o);
            }
        }
		public bool TryTrigger(SnapshotPoint point, bool trackMouse) {
			if (point.Snapshot == null)
				throw new ArgumentException();
			var info = QuickInfoState.Create(point.Snapshot);
			if (info == null)
				return false;

			currentQuickInfoSession?.Dispose();
			currentQuickInfoSession = new QuickInfoSession(info.Value, point, trackMouse, quickInfoBroker, textView);
			currentQuickInfoSession.Disposed += QuickInfoSession_Disposed;
			currentQuickInfoSession.Start();

			return true;
		}
Exemple #4
0
        public bool TryTrigger(SnapshotPoint point, bool trackMouse)
        {
            if (point.Snapshot == null)
            {
                throw new ArgumentException();
            }
            var info = QuickInfoState.Create(point.Snapshot);

            if (info == null)
            {
                return(false);
            }

            currentQuickInfoSession?.Dispose();
            currentQuickInfoSession           = new QuickInfoSession(info.Value, point, trackMouse, quickInfoBroker, textView);
            currentQuickInfoSession.Disposed += QuickInfoSession_Disposed;
            currentQuickInfoSession.Start();

            return(true);
        }
		void QuickInfoSession_Disposed(object sender, EventArgs e) {
			var session = (QuickInfoSession)sender;
			session.Disposed -= QuickInfoSession_Disposed;
			if (session == currentQuickInfoSession)
				currentQuickInfoSession = null;
		}