Example #1
0
        private void ButAddVcp_Click(object sender, RoutedEventArgs e)
        {
            var rdNum = ShowcaseHelper.Rand.Next(0, 6);
            var vc    = graphArea.VertexList.Values.ToList()[rdNum];
            //create new VCP with container
            var newId = vc.VertexConnectionPointsList.Last().Id + 1;
            var vcp   = new StaticVertexConnectionPoint {
                Id = newId
            };
            var ctrl = new Border {
                Margin = new Thickness(2, 2, 0, 2), Padding = new Thickness(0), Child = vcp
            };

            //add vcp to the root container
            //in order to  be able to use VCPRoot property we must specify container in the XAML template through PART_vcproot name
            vc.VCPRoot.Children.Add(ctrl);
            vc.VertexConnectionPointsList.Add(vcp);
            //update edge to use new connection point
            var ec = graphArea.GetRelatedEdgeControls(vc, EdgesType.Out).First() as EdgeControl;

            if (ec == null)
            {
                ec = graphArea.GetRelatedEdgeControls(vc, EdgesType.In).First() as EdgeControl;
                (ec.Edge as DataEdge).TargetConnectionPointId = newId;
            }
            else
            {
                (ec.Edge as DataEdge).SourceConnectionPointId = newId;
            }
            graphArea.EdgesList[ec.Edge as DataEdge].UpdateEdge();
            //graphArea.UpdateAllEdges(true);
        }
Example #2
0
        void butVCP_Click(object sender, RoutedEventArgs e)
        {
            CreateNewArea();
            dg_Area.VertexList.Values.ToList().ForEach(a => a.SetConnectionPointsVisibility(true));
            dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(6, false);
            var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();
            var edge  = new DataEdge(vlist[0], vlist[1])
            {
                SourceConnectionPointId = 1, TargetConnectionPointId = 1
            };

            dg_Area.LogicCore.Graph.AddEdge(edge);
            edge = new DataEdge(vlist[0], vlist[0])
            {
                SourceConnectionPointId = 1, TargetConnectionPointId = 1
            };
            dg_Area.LogicCore.Graph.AddEdge(edge);



            dg_Area.LogicCore.DefaultLayoutAlgorithm               = LayoutAlgorithmTypeEnum.ISOM;
            dg_Area.LogicCore.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams = dg_Area.LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            dg_Area.LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;

            dg_Area.GenerateGraph(true);
            var vertex = dg_Area.VertexList[edge.Target];

            var newVcp = new StaticVertexConnectionPoint {
                Id = 5, Margin = new Thickness(2, 0, 0, 0)
            };
            var cc = new Border
            {
                Margin  = new Thickness(2, 0, 0, 0),
                Padding = new Thickness(0),
                Child   = newVcp
            };

            edge.TargetConnectionPointId = 5;
            vertex.VCPRoot.Children.Add(cc);
            vertex.VertexConnectionPointsList.Add(newVcp);

            dg_Area.EdgesList[edge].UpdateEdge();
            dg_Area.UpdateAllEdges(true);
        }