Пример #1
0
        private NodeVM AddNode(String name, double width, double height, double offsetx, double offsety, string shape, String content, Int32 level, string fill)
        {
            NodeVM node = new NodeVM();

            node.HorizontalContentAlignment = HorizontalAlignment.Center;
            node.UnitWidth  = width;
            node.UnitHeight = height;
            node.OffsetX    = offsetx;
            node.OffsetY    = offsety;
            node.Shape      = App.Current.Resources[shape];
            node.Fill       = fill;
            node.Text       = content;

            //To Represent Annotation Properties
            node.Annotations = new ObservableCollection <IAnnotation>()
            {
                new AnnotationEditorViewModel()
                {
                    Content      = content,
                    Mode         = ContentEditorMode.View,
                    ViewTemplate = App.Current.Resources["viewtemplate1"] as DataTemplate,
                    EditTemplate = App.Current.Resources["edittemplate"] as DataTemplate,
                    ReadOnly     = true,
                }
            };
            (Nodes as ObservableCollection <NodeVM>).Add(node);
            return(node);
        }
Пример #2
0
        //Add Connections
        private void Connect(NodeVM headnode, NodeVM tailnode, string label)
        {
            ConnectorViewModel conn = new ConnectorViewModel();

            conn.SourceNode           = tailnode;
            conn.TargetNode           = headnode;
            conn.TargetDecoratorStyle = App.Current.MainWindow.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,
                        Margin = new Thickness(0, 0, 0, 10),
                    }
                };
            }
            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,
                        Margin = new Thickness(0, 10, 0, 0),
                    }
                };
            }
            (Connectors as ObservableCollection <ConnectorViewModel>).Add(conn);
        }
Пример #3
0
        //Create Nodes and Connections
        private void CreateNodes()
        {
            //Create Nodes
            NodeVM NewIdea       = AddNode("NewIdea", 150, 60, 175, 60, "Ellipse", "New idea identified", 1, "#65c7d0");
            NodeVM Meeting       = AddNode("Meeting", 150, 60, 175, 160, "Process", "Meeting with board", 2, "#65c7d0");
            NodeVM BoardDecision = AddNode("BoardDecision", 150, 100, 175, 270, "Decision", "Board decides\nwhether to proceed", 3, "#65c7d0");
            NodeVM project       = AddNode("project", 150, 100, 175, 410, "Decision", "Find project\n manager,write\n specification", 3, "#65c7d0");
            NodeVM End           = AddNode("End", 120, 60, 175, 530, "Process", "Implement and\n Deliver", 4, "#65c7d0");
            NodeVM Decision      = AddNode("Decision", 200, 60, 480, 70, "Card", "Decision process for\n new software ideas", 5, "#858585");
            NodeVM Reject        = AddNode("Reject", 150, 60, 445, 270, "Process", "Reject and write report", 4, "#65c7d0");

            Reject.IsSelected = true;
            NodeVM 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");
        }