private void initializeNode(Node node, string type, string text, string fill)
        {
            node.Name = "node_" + DiagramWebControl1.Model.Nodes.Count;
            LabelMargin margin = new LabelMargin(5, 5, 5, 5);
            Label       label  = new Label();

            label.Text       = text;
            label.Name       = node.Name + "_label";
            label.Wrapping   = TextWrapping.NoWrap;
            label.Margin     = margin;
            label.Bold       = true;
            label.FontFamily = "Segoe UI";
            node.Labels.Add(label);
            node.FillColor   = fill;
            node.Visible     = false;
            node.MinWidth    = 50;
            node.MinHeight   = 30;
            node.Constraints = node.Constraints & ~(NodeConstraints.Drag | NodeConstraints.Rotate);
            if (node is NativeNode)
            {
                (node as NativeNode).Scale = ScaleConstraints.Stretch;
            }
            if (type == "root")
            {
                node.Constraints = node.Constraints & ~NodeConstraints.Delete;
            }
            Dictionary <string, object> addInfo = new Dictionary <string, object>();

            addInfo.Add("type", type);
            node.AddInfo = addInfo;

            DiagramWebControl1.Model.Nodes.Add(node);
        }
Example #2
0
        //
        // GET: /Diagram/
        public ActionResult DiagramFeatures()
        {
            DiagramProperties model = new DiagramProperties();

            model.Height = "600px";
            model.Width  = "900px";
            BasicShape newIdea = CreateNode("NewIdea", 150, 60, 300, 60, "New Idea Identified");

            newIdea.Shape    = BasicShapes.Path;
            newIdea.PathData = "M 45 220 L 45 220 A 20 30 0 0 1 45 280 L 45 280 A 20 30 0 0 1 45 220 Z";
            BasicShape  meeting       = CreateNode("Meeting", 150, 60, 300, 150, "Meeting with board");
            BasicShape  boardDecision = CreateNode("BoardDecision", 150, 100, 300, 270, "Board decides \\nwhether to proceed");
            LabelMargin margin        = new LabelMargin(0, 20, 20, 0);

            ((Syncfusion.JavaScript.DataVisualization.Models.Diagram.Label)boardDecision.Labels[0]).Margin = margin;
            boardDecision.Shape  = BasicShapes.Polygon;
            boardDecision.Points = GetDecisionPoints();
            BasicShape project = CreateNode("project", 150, 100, 300, 420, "Find Project manager");

            project.Shape  = BasicShapes.Polygon;
            project.Points = GetDecisionPoints();
            BasicShape end      = CreateNode("End", 120, 60, 300, 545, "Implement\\n and Deliver");
            BasicShape decision = CreateNode("Decision", 250, 60, 550, 60, "Decision Process for new software ideas");
            Collection points   = new Collection();

            points.Add(new DiagramPoint(280, 60));
            points.Add(new DiagramPoint(400, 60));
            points.Add(new DiagramPoint(400, 110));
            points.Add(new DiagramPoint(260, 110));
            points.Add(new DiagramPoint(260, 75));
            decision.Shape       = BasicShapes.Polygon;
            decision.Points      = points;
            decision.FillColor   = "#858585";
            decision.BorderColor = "#1BA0E2";
            BasicShape reject    = CreateNode("Reject", 150, 60, 550, 270, "Reject and write report");
            BasicShape resources = CreateNode("Resources", 150, 60, 550, 420, "Hire new resources");

            ConnectNode(model, newIdea, meeting, "", false);
            ConnectNode(model, meeting, boardDecision, "", false);
            ConnectNode(model, boardDecision, reject, "No", true);
            ConnectNode(model, boardDecision, project, "Yes", true);
            ConnectNode(model, project, resources, "No", true);
            ConnectNode(model, project, end, "No", true);
            model.Nodes.Add(newIdea);
            model.Nodes.Add(meeting);
            model.Nodes.Add(boardDecision);
            model.Nodes.Add(project);
            model.Nodes.Add(end);
            model.Nodes.Add(decision);
            model.Nodes.Add(reject);
            model.Nodes.Add(resources);
            model.EnableContextMenu            = false;
            model.SnapSettings.SnapConstraints = SnapConstraints.ShowLines | SnapConstraints.SnapToLines;
            ViewData["diagramModel"]           = model;
            return(View());
        }
        //
        // GET: /Localization/

        public ActionResult Localization()
        {
            DiagramProperties diagram = new DiagramProperties();

            diagram.Height = "700px";
            diagram.Width  = "100%";
            diagram.PageSettings.ScrollLimit     = ScrollLimit.Diagram;
            diagram.SnapSettings.SnapConstraints = SnapConstraints.All;

            BasicShape newIdea = CreateNode("NewIdea", 150, 60, 300, 60, "Start Terminator");

            newIdea.FillColor = "darkCyan";
            newIdea.Shape     = BasicShapes.Path;
            newIdea.PathData  = "M 45 220 L 45 220 A 20 30 0 0 1 45 280 L 45 280 A 20 30 0 0 1 45 220 Z";
            AddPort(newIdea);
            BasicShape meeting = CreateNode("Meeting", 150, 60, 300, 150, "Progress");

            meeting.FillColor = "darkCyan";
            AddPort(meeting);
            BasicShape boardDecision = CreateNode("BoardDecision", 150, 100, 300, 270, "Decision");

            boardDecision.FillColor = "darkCyan";
            LabelMargin margin = new LabelMargin(0, 20, 20, 0);

            ((Syncfusion.JavaScript.DataVisualization.Models.Diagram.Label)boardDecision.Labels[0]).Margin = margin;
            boardDecision.Shape  = BasicShapes.Polygon;
            boardDecision.Points = GetDecisionPoints();
            AddPort(boardDecision);

            BasicShape project = CreateNode("Data", 150, 100, 300, 420, "Data");

            project.FillColor = "darkCyan";
            project.Shape     = BasicShapes.Polygon;
            project.Points    = GetDecisionPoints();
            AddPort(project);
            BasicShape end = CreateNode("End", 120, 60, 300, 645, "End Terminator");

            end.FillColor = "darkCyan";
            AddPort(end);
            BasicShape document = CreateNode("Document", 150, 60, 300, 545, "Document");

            document.FillColor = "darkCyan";
            document.Shape     = BasicShapes.Path;
            document.PathData  = " M 87.3593 87.8807 L 87.3593 20.0773 L 0 20.0773 L 0 87.8807 C 0 87.8807 25.1638 100 43.6797 87.8807 C 62.1955 75.7614 77.5794 80.942 87.3593 87.8807 Z";
            AddPort(document);
            ConnectNode(diagram, "connector1", newIdea, meeting, "", false, "", "");
            ConnectNode(diagram, "connector2", meeting, boardDecision, "", false, "", "");
            ConnectNode(diagram, "connector3", boardDecision, project, "Yes", true, "", "");
            ConnectNode(diagram, "connector4", project, document, "", true, "", "");
            ConnectNode(diagram, "connector5", document, end, "", true, "", "");
            ConnectNode(diagram, "connector6", boardDecision, meeting, "No", true, "", "");

            diagram.Nodes.Add(newIdea);
            diagram.Nodes.Add(meeting);
            diagram.Nodes.Add(boardDecision);
            diagram.Nodes.Add(project);
            diagram.Nodes.Add(document);
            diagram.Nodes.Add(end);

            diagram.EnableContextMenu = true;
            ViewData["diagramModel"]  = diagram;

            return(View());
        }