//Create Nodes and Connections public void createNode() { //Create Nodes CustomNode NewIdea = addNode("NewIdea", 150, 60, 100, 70, Shapes.FlowChart_Start, "New idea identified", 1, "#65c7d0"); CustomNode Meeting = addNode("Meeting", 150, 60, 100, 155, Shapes.Rectangle, "Meeting with board", 2, "#65c7d0"); CustomNode BoardDecision = addNode("BoardDecision", 150, 100, 100, 260, Shapes.FlowChart_Decision, "Board decides whether to proceed", 3, "#65c7d0"); CustomNode project = addNode("project", 150, 100, 100, 400, Shapes.FlowChart_Decision, "Find Project manager,write specification", 3, "#65c7d0"); CustomNode End = addNode("End", 100, 60, 100, 515, Shapes.Rectangle, "Implement and Deliver", 4, "#65c7d0"); CustomNode Decision = addNode("Decision", 180, 60, 360, 60, Shapes.FlowChart_Card, "Decision process for new software ideas", 5, "#858585"); CustomNode Reject = addNode("Reject", 130, 60, 320, 260, Shapes.Rectangle, "Reject and write report", 4, "#65c7d0"); CustomNode Resources = addNode("Resources", 130, 60, 320, 400, Shapes.Rectangle, "Hire new Resources", 2, "#65c7d0"); //Node Yes2 = addNode("Yes2", 50, 40, 320, 330, Shapes.None, "Yes", 0, null); //Node Yes3 = addNode("Yes3", 50, 40, 320, 460, Shapes.None, "Yes", 0, null); //Node No1 = addNode("No1", 50, 40, 420, 260, Shapes.None, "No", 0, null); //Node No2 = addNode("No2", 50, 40, 420, 380, Shapes.None, "No", 0, null); //Creates the connections for the nodes Connect(Meeting, NewIdea, ""); Connect(BoardDecision, Meeting, ""); Connect(Reject, BoardDecision, "No"); Connect(project, BoardDecision, "Yes"); Connect(Resources, project, "No"); Connect(End, project, "Yes"); }
//Add Nodes private CustomNode addNode(String name, double width, double height, double offsetx, double offsety, Shapes shape, String content, Int32 level, string fill) { CustomNode node = new CustomNode(); node.UnitWidth = width; node.UnitHeight = height; node.OffsetX = offsetx; node.OffsetY = offsety; node.EnumShape = shape; node.Fill = fill; // node.Text = content; node.Annotations = new ObservableCollection <IAnnotation>() { new AnnotationEditorViewModel() { Content = content, UnitWidth = 75, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Center, TextVerticalAlignment = VerticalAlignment.Center, ViewTemplate = this.Resources["viewtemplate"] as DataTemplate, } }; (diagramControl.Nodes as ICollection <CustomNode>).Add(node); return(node); }
//Add Nodes private CustomNode addNode(String name, double width, double height, double offsetx, double offsety, Shapes shape, String content, Int32 level, string fill) { CustomNode node = new CustomNode(); node.UnitWidth = width; node.UnitHeight = height; node.OffsetX = offsetx; node.OffsetY = offsety; node.EnumShape = shape; if (name != "Decision") { node.Fill = "#5B9BD5"; } else { node.Fill = fill; } //node.Text = content; node.Annotations = new ObservableCollection <IAnnotation>() { new AnnotationEditorViewModel() { Content = content, UnitWidth = 75, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = TextAlignment.Center, TextVerticalAlignment = VerticalAlignment.Center, ViewTemplate = XamlReader.Load(FlowDiagramTemplate.vTemplate1) as DataTemplate, } }; (diagramControl.Nodes as ICollection <CustomNode>).Add(node); return(node); }
//Add Connections private void Connect(CustomNode headnode, CustomNode tailnode, string label) { Connector conn = new Connector(); conn.SourceNode = tailnode; conn.TargetNode = headnode; conn.ConnectorGeometryStyle = this.Resources["NormalLine"] as Style; conn.TargetDecoratorStyle = this.Resources["decoratorstyle"] as Style; conn.Foreground = new SolidColorBrush(Colors.Black); //To Represent Annotation Properties conn.Annotations = new ObservableCollection <IAnnotation>() { new AnnotationEditorViewModel() { Content = label, WrapText = TextWrapping.NoWrap, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, ViewTemplate = this.Resources["connectorviewtemplate"] as DataTemplate, //EditTemplate=this.Resources["edittemplate"] as DataTemplate } }; (diagramControl.Connectors as ICollection <Connector>).Add(conn); }