Exemplo n.º 1
0
        public void HighlightTriggerEventHandler(object sender, HighlightTriggeredEventArgs args)
        {
            if (Graph == null || HighlightAlgorithm == null)
            {
                return;
            }

            if (args.OriginalSource is VertexControl)
            {
                var vc     = (VertexControl)args.OriginalSource;
                var vertex = vc.Vertex as TVertex;
                if (vertex == null || !Graph.ContainsVertex(vertex))
                {
                    return;
                }

                if (args.IsPositiveTrigger)
                {
                    HighlightAlgorithm.OnVertexHighlighting(vertex);
                }
                else
                {
                    HighlightAlgorithm.OnVertexHighlightRemoving(vertex);
                }
            }
            else if (args.OriginalSource is EdgeControl)
            {
                var   ec   = (EdgeControl)args.OriginalSource;
                TEdge edge = default(TEdge);
                try
                {
                    edge = (TEdge)ec.Edge;
                }
                catch
                {
                }

                if (Equals(edge, default(TEdge)) || !Graph.ContainsEdge(edge))
                {
                    return;
                }

                if (args.IsPositiveTrigger)
                {
                    HighlightAlgorithm.OnEdgeHighlighting(edge);
                }
                else
                {
                    HighlightAlgorithm.OnEdgeHighlightRemoving(edge);
                }
            }
        }