//Add Connections private void Connect(CustomNode headnode, CustomNode tailnode, string label) { ConnectorViewModel conn = new ConnectorViewModel(); conn.SourceNode = tailnode; conn.TargetNode = headnode; conn.TargetDecoratorStyle = this.Resources["connectorstyle"] as Style; if (label == "Yes") { //To Represent Annotation Properties conn.Annotations = new ObservableCollection <IAnnotation>() { new AnnotationEditorViewModel() { Content = label, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, WrapText = TextWrapping.NoWrap, ReadOnly = true, ViewTemplate = App.Current.Resources["viewtemplate"] as DataTemplate, EditTemplate = App.Current.Resources["edittemplate"] as DataTemplate } }; } else if (label == "No") { //To Represent Annotation Properties conn.Annotations = new ObservableCollection <IAnnotation>() { new AnnotationEditorViewModel() { Content = label, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, ReadOnly = true, WrapText = TextWrapping.NoWrap, ViewTemplate = App.Current.Resources["viewtemplate"] as DataTemplate, EditTemplate = App.Current.Resources["edittemplate"] as DataTemplate } }; } (Diagram.Connectors as ICollection <ConnectorViewModel>).Add(conn); }
//Create Nodes and Connections private void CreateNodes() { //Create Nodes CustomNode NewIdea = AddNode("NewIdea", 150, 60, 175, 60, "Ellipse", "New idea identified", 1, "#65c7d0"); CustomNode Meeting = AddNode("Meeting", 150, 60, 175, 160, "Process", "Meeting with board", 2, "#65c7d0"); CustomNode BoardDecision = AddNode("BoardDecision", 150, 100, 175, 270, "Decision", "Board decides\nwhether to proceed", 3, "#65c7d0"); CustomNode project = AddNode("project", 150, 100, 175, 410, "Decision", "Find project\n manager,write\n specification", 3, "#65c7d0"); CustomNode End = AddNode("End", 120, 60, 175, 530, "Process", "Implement and\n Deliver", 4, "#65c7d0"); CustomNode Decision = AddNode("Decision", 200, 60, 480, 70, "Card", "Decision process for\n new software ideas", 5, "#858585"); CustomNode Reject = AddNode("Reject", 150, 60, 445, 270, "Process", "Reject and write report", 4, "#65c7d0"); Reject.IsSelected = true; CustomNode Resources = AddNode("Resources", 150, 60, 445, 410, "Process", "Hire new resources", 2, "#65c7d0"); //Create Connections Connect(Meeting, NewIdea, ""); Connect(BoardDecision, Meeting, ""); Connect(Reject, BoardDecision, "No"); Connect(project, BoardDecision, "Yes"); Connect(Resources, project, "No"); Connect(End, project, "Yes"); }