Exemple #1
0
        private void OnGraphSourceChanged()
        {
            if (myGraphVisual.Presentation != null)
            {
                var adornerLayer = AdornerLayer.GetAdornerLayer(myGraphVisual);
                var adorners     = adornerLayer.GetAdorners(myGraphVisual);
                if (adorners != null)
                {
                    var toolTipAdorner = adorners.OfType <ToolTipAdorner>().SingleOrDefault();
                    if (toolTipAdorner != null)
                    {
                        adornerLayer.Remove(toolTipAdorner);
                    }
                }
            }

            myGraphVisual.Presentation = GraphSource;

            if (myGraphVisual.Presentation != null)
            {
                var toolTipModule = GraphSource.GetPropertySetFor <ToolTipContent>();
                if (toolTipModule != null)
                {
                    var adornerLayer = AdornerLayer.GetAdornerLayer(myGraphVisual);
                    var adorner      = new ToolTipAdorner(myGraphVisual, myGraphVisual, toolTipModule);
                    adornerLayer.Add(adorner);
                }
            }

            myZoomSlider.IsEnabled = myGraphVisual.Presentation != null;
        }
        private static void OnGraphSourceChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
        {
            var graphView = ( GraphView )d;

            if( graphView.myGraphVisual.Presentation != null )
            {
                var adornerLayer = AdornerLayer.GetAdornerLayer( graphView.myGraphVisual );
                var adorners = adornerLayer.GetAdorners( graphView.myGraphVisual );
                if( adorners != null )
                {
                    var toolTipAdorner = adorners.OfType<ToolTipAdorner>().SingleOrDefault();
                    if( toolTipAdorner != null )
                    {
                        adornerLayer.Remove( toolTipAdorner );
                    }
                }
            }

            var presentation = ( IGraphPresentation )e.NewValue;
            graphView.myGraphVisual.Presentation = presentation;

            if( graphView.myGraphVisual.Presentation != null )
            {
                var toolTipModule = presentation.GetPropertySetFor<ToolTipContent>();
                if( toolTipModule != null )
                {
                    var adornerLayer = AdornerLayer.GetAdornerLayer( graphView.myGraphVisual );
                    var adorner = new ToolTipAdorner( graphView.myGraphVisual, graphView.myGraphVisual, toolTipModule );
                    adornerLayer.Add( adorner );
                }
            }
        }