Beispiel #1
0
 public static IConnection Connect(this RadDiagram diagram, IShape a, IShape b, string name = null)
 {
     var c = diagram.AddConnection(a, b);
     if (!string.IsNullOrEmpty(name))
         c.Name = name;
     return c;
 }
Beispiel #2
0
        /// <summary>
        /// Creates a diagram or visual representation of the given incidence structure, returning in addition the association between the graph elements on the one hand
        /// and the visuals on the other.
        /// </summary>
        /// <param name="diagram">The diagram.</param>
        /// <param name="g">The graph to visualize.</param>
        /// <param name="nodeMap">The node map.</param>
        /// <param name="edgeMap">The edge map.</param>
        /// <returns></returns>
        /// <seealso cref="Parse"/>
        public static Graph CreateDiagram(this Telerik.Windows.Controls.RadDiagram diagram, Graph g, out Dictionary<Node, RadDiagramShape> nodeMap, out Dictionary<Edge, RadDiagramConnection> edgeMap, CreateShapeDelegate create, bool randomSize = false)
        {
            if (g == null) throw new ArgumentNullException("g");
            diagram.Clear();

            var dic = new Dictionary<int, RadDiagramShape>();
            nodeMap = new Dictionary<Node, RadDiagramShape>();
            edgeMap = new Dictionary<Edge, RadDiagramConnection>();
            foreach (var node in g.Nodes)
            {
                var shape = create(node, randomSize, null);

                nodeMap.Add(node, shape);
                diagram.AddShape(shape);
                dic.Add(node.Id, shape);
            }
            foreach (Edge link in g.Links)
            {
                var con = diagram.AddConnection(dic[link.Source.Id], dic[link.Sink.Id]) as RadDiagramConnection;
                edgeMap.Add(link, con);
                con.TargetCapType = CapType.Arrow1Filled;
            }
            return g;
        }
Beispiel #3
0
 public static List<RadDiagramShape> CreateDivisionBranch(this RadDiagram diagram, string name)
 {
     var shapes = new List<RadDiagramShape>();
     var director = diagram.CreateShape(name + " director");
     shapes.Add(director);
     var manCount = Rand.Next(2, 4);
     for (var j = 0; j < manCount; j++)
     {
         var man = diagram.CreateShape(name + " manager");
         shapes.Add(man);
         man.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape);
         man.Background = new SolidColorBrush(Colors.Brown);
         var devCount = Rand.Next(3, 6);
         diagram.AddConnection(director, man, ConnectorPosition.Bottom,ConnectorPosition.Top);
         for (var k = 0; k < devCount; k++)
         {
             var dev = diagram.CreateShape("Dev " + k);
             shapes.Add(dev);
             dev.Background = new SolidColorBrush(Colors.LightGray);
             diagram.Connect(man, dev);
         }
     }
     return shapes;
 }
Beispiel #4
0
        /// <summary>
        /// Creates a diagram or visual representation of the given incidence structure.
        /// </summary>
        /// <param name="diagram">The diagram.</param>
        /// <param name="g">The graph structure.</param>
        /// <param name="create">The create.</param>
        /// <returns></returns>
        public static Graph CreateDiagram(this Telerik.Windows.Controls.RadDiagram diagram, Graph g, CreateShapeDelegate create = null, bool randomSize = false)
        {
            if (diagram == null) throw new ArgumentNullException("diagram");
            if (g == null) throw new ArgumentNullException("g");
            diagram.Clear();

            var dic = new Dictionary<int, RadDiagramShape>();
            foreach (var node in g.Nodes)
            {
                var shape = create == null ? CreateShape(node, randomSize) : create(node, randomSize, null);
                diagram.AddShape(shape);
                dic.Add(node.Id, shape);
            }
            foreach (var con in g.Links.Select(link => diagram.AddConnection(dic[link.Source.Id], dic[link.Sink.Id]))) con.TargetCapType = CapType.Arrow1Filled;
            return g;
        }