Ejemplo n.º 1
0
        private void LoadBasicFlowchartNodes()
        {
            diagram.Behavior = Behavior.DrawLinks;
            shapeLibrary.LoadFromXml(@"../../CustomNodes/CustomLibrary/BasicFlowchart.sl");
            NodesFromLib();
            shapeList.SelectedIndex = 0;

            // Process Node (square anchors)
            AnchorPattern squareAnchors = new AnchorPattern(new AnchorPoint[]
            {
                // if you picture the node as a grid, top left is 0,0
                // bottom right is 100,100, center is 50,50, etc...
                // first value is X axis, 2nd is the Y axis
                // yes i had to figure this out myself, no i dont know what true is for but its true
                // what is documentation
                new AnchorPoint(50, 0, true, true),
                new AnchorPoint(100, 50, true, true),
                new AnchorPoint(50, 100, true, true),
                new AnchorPoint(0, 50, true, true)
            });

            // probably should have a better way of doing this instead of hard coding
            // the getItemAt()

            ShapeNode processNode = shapeList.Items.GetItemAt(0) as ShapeNode;

            processNode.Name                  = "processNode";
            processNode.AnchorPattern         = squareAnchors;
            processNode.TextAlignment         = TextAlignment.Center;
            processNode.TextVerticalAlignment = AlignmentY.Center;
            processNode.ResizeToFitText(FitSize.KeepRatio);

            // Start/End Node (same square anchors)
            ShapeNode startEndNode = shapeList.Items.GetItemAt(4) as ShapeNode;

            startEndNode.Name                  = "startEndNode";
            startEndNode.AnchorPattern         = squareAnchors;
            startEndNode.PolygonalTextLayout   = true;
            startEndNode.TextAlignment         = TextAlignment.Center;
            startEndNode.TextVerticalAlignment = AlignmentY.Center;
            startEndNode.ResizeToFitText(FitSize.KeepRatio);

            // Decision Node
            ShapeNode decisionNode = shapeList.Items.GetItemAt(5) as ShapeNode;

            decisionNode.Name                  = "decisionNode";
            decisionNode.AnchorPattern         = squareAnchors;
            decisionNode.PolygonalTextLayout   = true;
            decisionNode.TextAlignment         = TextAlignment.Center;
            decisionNode.TextVerticalAlignment = AlignmentY.Center;
            decisionNode.ResizeToFitText(FitSize.KeepRatio);

            // Data Node
            ShapeNode dataNode = shapeList.Items.GetItemAt(1) as ShapeNode;

            dataNode.Name                  = "dataNode";
            dataNode.AnchorPattern         = squareAnchors;
            dataNode.PolygonalTextLayout   = true;
            dataNode.TextAlignment         = TextAlignment.Center;
            dataNode.TextVerticalAlignment = AlignmentY.Center;
            dataNode.ResizeToFitText(FitSize.KeepRatio);

            // Subprocess Node
            ShapeNode subprocessNode = shapeList.Items.GetItemAt(2) as ShapeNode;

            subprocessNode.Name                  = "subprocessNode";
            subprocessNode.AnchorPattern         = squareAnchors;
            subprocessNode.TextAlignment         = TextAlignment.Center;
            subprocessNode.TextVerticalAlignment = AlignmentY.Center;
            subprocessNode.ResizeToFitText(FitSize.KeepRatio);

            // Document Node
            ShapeNode documentNode = shapeList.Items.GetItemAt(3) as ShapeNode;

            documentNode.Name                  = "documentNode";
            documentNode.AnchorPattern         = squareAnchors;
            documentNode.AnchorPattern         = squareAnchors;
            documentNode.TextAlignment         = TextAlignment.Center;
            documentNode.TextVerticalAlignment = AlignmentY.Center;
            documentNode.ResizeToFitText(FitSize.KeepRatio);

            diagram.LinkHeadShape     = MindFusion.Diagramming.Wpf.ArrowHeads.Circle;
            diagram.LinkHeadShapeSize = 10; // dont ask me what 10 is refering to in this case.
        }