Пример #1
0
        //*************************************************************************
        //  Method: VertexToolTipTracker_ShowToolTip()
        //
        /// <summary>
        /// Handles the ShowToolTip event on the m_oVertexToolTipTracker object.
        /// </summary>
        ///
        /// <param name="oSource">
        /// Standard event arguments.
        /// </param>
        ///
        /// <param name="oToolTipTrackerEventArgs">
        /// Standard event arguments.
        /// </param>
        //*************************************************************************
        private void VertexToolTipTracker_ShowToolTip(
            Object oSource,
            ToolTipTrackerEventArgs oToolTipTrackerEventArgs
            )
        {
            AssertValid();

            // Get the vertex that was hovered over.

            Debug.Assert(oToolTipTrackerEventArgs.Object is IVertex);

            IVertex oVertex = (IVertex)oToolTipTrackerEventArgs.Object;

            // Fire a VertexMouseHover event in case the application wants to take
            // additional action.

            FireVertexMouseHover(oVertex);

            if (!m_bShowVertexToolTips)
            {
            // Vertex tooltips aren't being shown, so no additional action is
            // required.

            return;
            }

            // Give PreviewVertexToolTipShown event handlers an opportunity to
            // override the default tooltip.

            VertexToolTipShownEventArgs oVertexToolTipShownEventArgs =
            new VertexToolTipShownEventArgs(oVertex);

            FirePreviewVertexToolTipShown(oVertexToolTipShownEventArgs);

            m_oVertexToolTip = oVertexToolTipShownEventArgs.VertexToolTip;

            if (m_oVertexToolTip == null)
            {
            // There was no default tooltip override.  Does the vertex have a
            // tooltip string stored in its metadata?

            Object oVertexToolTipAsObject;

            if ( !oVertex.TryGetValue(ReservedMetadataKeys.VertexToolTip,
                typeof(String), out oVertexToolTipAsObject) )
            {
                // No.  Nothing needs to be done.

                return;
            }

            // Create a default tooltip.

            m_oVertexToolTip = CreateDefaultVertexToolTip(
                (String)oVertexToolTipAsObject);
            }

            // The tooltip shouldn't zoom.  Compensate for a zoomed graph by
            // scaling the tooltip with the graph zoom's inverse.

            Double dScale = 1.0 / this.ScaleTransformForRender.ScaleX;
            m_oVertexToolTip.RenderTransform = new ScaleTransform(dScale, dScale);

            m_oGraphDrawer.AddVisualOnTopOfGraph(m_oVertexToolTip);

            // If this isn't called, MeasureOverride() may not be called and
            // m_oVertexToolTip won't get sized.

            this.InvalidateMeasure();
        }
Пример #2
0
        //*************************************************************************
        //  Method: VertexToolTipTracker_HideToolTip()
        //
        /// <summary>
        /// Handles the HideToolTip event on the m_oVertexToolTipTracker object.
        /// </summary>
        ///
        /// <param name="oSource">
        /// Standard event arguments.
        /// </param>
        ///
        /// <param name="oToolTipTrackerEventArgs">
        /// Standard event arguments.
        /// </param>
        //*************************************************************************
        private void VertexToolTipTracker_HideToolTip(
            Object oSource,
            ToolTipTrackerEventArgs oToolTipTrackerEventArgs
            )
        {
            AssertValid();

            FireVertexMouseLeave();

            if (m_bShowVertexToolTips)
            {
            RemoveVertexToolTip();
            }
        }