Exemple #1
0
 /// <summary>
 /// Constructs a shape type.
 /// </summary>
 public ShapeType(string name, string libraryName,
                  ResourceString categoryTitle,
                  CreateShapeDelegate createShapeDelegate,
                  GetPropertyDefinitionsDelegate getPropertyDefinitionsDelegate)
     : this(name, libraryName, categoryTitle, string.Empty, createShapeDelegate, getPropertyDefinitionsDelegate, null, true)
 {
 }
Exemple #2
0
 /// <summary>
 /// Constructs a shape type.
 /// </summary>
 public ShapeType(string name, string libraryName,
                  ResourceString categoryTitle,
                  CreateShapeDelegate createShapeDelegate,
                  GetPropertyDefinitionsDelegate getPropertyDefinitionsDelegate,
                  Bitmap freehandReferenceImage)
     : this(name, libraryName, categoryTitle, string.Empty, createShapeDelegate, getPropertyDefinitionsDelegate, freehandReferenceImage, true)
 {
 }
Exemple #3
0
 /// <summary>
 /// Constructs a shape type.
 /// </summary>
 public ShapeType(string name, string libraryName,
                  ResourceString categoryTitle,
                  ResourceString description,
                  CreateShapeDelegate createShapeDelegate,
                  GetPropertyDefinitionsDelegate getPropertyDefinitionsDelegate,
                  Bitmap freehandReferenceImage,
                  bool supportsTemplates)
 {
     // Sanity check
     if (name == null)
     {
         throw new ArgumentNullException("Shape type name");
     }
     if (!Project.IsValidName(name))
     {
         throw new ArgumentException(string.Format("'{0}' is not a valid shape type name.", name));
     }
     if (libraryName == null)
     {
         throw new ArgumentNullException("Namespace name");
     }
     if (!Project.IsValidName(libraryName))
     {
         throw new ArgumentException("'{0}' is not a valid library name.", libraryName);
     }
     if (createShapeDelegate == null)
     {
         throw new ArgumentNullException("Shape creation delegate");
     }
     if (getPropertyDefinitionsDelegate == null)
     {
         throw new ArgumentNullException("Property infos");
     }
     //
     this.name                           = name;
     this.libraryName                    = libraryName;
     this.categoryTitle                  = categoryTitle ?? string.Empty;
     this.description                    = description ?? string.Empty;
     this.createShapeDelegate            = createShapeDelegate;
     this.getPropertyDefinitionsDelegate = getPropertyDefinitionsDelegate;
     this.freehandReferenceImage         = freehandReferenceImage;
     this.supportsAutoTemplates          = supportsTemplates;
 }
Exemple #4
0
 public static void CreateGraph(this RadDiagram diagram, GraphGenerationSpecifications specs, CreateShapeDelegate createShape)
 {
     diagram.Clear();
     if (specs.Connections)
     {
         var g = specs.Connected ? GraphExtensions.CreateRandomConnectedGraph(specs.NodeCount, 4, specs.TreeGraph) : GraphExtensions.CreateRandomGraph(specs.NodeCount, 4, specs.TreeGraph);
         diagram.CreateDiagram(g, GraphExtensions.CreateShape, specs.RandomShapeSize);
     }
     else
     {
         for (var i = 0; i < specs.NodeCount; i++)
         {
             var shape = createShape(new Node(i, false), specs.RandomShapeSize, null);
             diagram.AddShape(shape);
         }
     }
 }
Exemple #5
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="structure">The incidence structure.</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, IEnumerable<string> structure, out Dictionary<Node, RadDiagramShape> nodeMap, out Dictionary<Edge, RadDiagramConnection> edgeMap, CreateShapeDelegate create, bool randomSize)
 {
     var g = Telerik.Windows.Diagrams.Core.GraphExtensions.Parse(structure);
     return CreateDiagram(diagram, g, out nodeMap, out edgeMap, create, randomSize);
 }
Exemple #6
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;
        }
Exemple #7
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;
        }
Exemple #8
0
 public static void CreateGraph(this RadDiagram diagram, GraphGenerationSpecifications specs, CreateShapeDelegate createShape)
 {
     diagram.Clear();
     if (specs.Connections)
     {
         var g = specs.Connected ? GraphExtensions.CreateRandomConnectedGraph(specs.NodeCount, 4, specs.TreeGraph) : GraphExtensions.CreateRandomGraph(specs.NodeCount, 4, specs.TreeGraph);
         diagram.CreateDiagram(g, GraphExtensions.CreateShape, specs.RandomShapeSize);
     }
     else
     {
         for (var i = 0; i < specs.NodeCount; i++)
         {
             var shape = createShape(new Node(i, false), specs.RandomShapeSize);
             diagram.AddShape(shape);
         }
     }
 }
Exemple #9
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="structure">The incidence structure.</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, IEnumerable <string> structure, out Dictionary <Node, RadDiagramShape> nodeMap, out Dictionary <Edge, RadDiagramConnection> edgeMap, CreateShapeDelegate create, bool randomSize)
        {
            var g = Telerik.Windows.Diagrams.Core.GraphExtensions.Parse(structure);

            return(CreateDiagram(diagram, g, out nodeMap, out edgeMap, create, randomSize));
        }
Exemple #10
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);


                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);
        }
Exemple #11
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);

                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);
        }
Exemple #12
0
 /// <summary>
 ///     Initialize the plugin and it's name
 /// </summary>
 /// <param name="name">
 ///     The plugin's name
 /// </param>
 public ShapePlugin(string name)
     : base("Shapes", name)
 {
     MethodInfo methodInfo = GetMethod ("CreateShape");
     CreateShape = Delegate.CreateDelegate (typeof(CreateShapeDelegate), methodInfo) as CreateShapeDelegate;
 }