예제 #1
0
        public DiagramVM()
        {
            Nodes      = new NodeCollection();
            Connectors = new ConnectorCollection();

            PortVisibility = PortVisibility.Visible;

            anno = new NodePortViewModel()
            {
                UnitHeight = 10, UnitWidth = 10,
            };

            NodeViewModel node = new NodeViewModel()
            {
                OffsetX    = 500,
                OffsetY    = 250,
                UnitHeight = 100,
                UnitWidth  = 100,
                Ports      = new PortCollection()
                {
                    anno,
                },
            };

            (Nodes as NodeCollection).Add(node);
        }
예제 #2
0
        /// <summary>
        /// Create the node ports
        /// </summary>
        /// <param name="node1">Node</param>
        /// <param name="id">Port ID</param>
        /// <param name="nodeoffsetx">Node offset-x value.</param>
        /// <param name="nodeoffsety">Node offset-y value.</param>
        private void CreateNodePort(CustomNodeVM node1, string id, double nodeoffsetx, double nodeoffsety)
        {
            NodePortViewModel nodePort = new NodePortViewModel()
            {
                ID          = id,
                NodeOffsetX = nodeoffsetx,
                NodeOffsetY = nodeoffsety,
            };

            (node1.Ports as PortCollection).Add(nodePort);
        }
        private void CreateNodePort(NodeViewModel node1, string id, double nodeoffsetx, double nodeoffsety)
        {
            NodePortViewModel nodePort = new NodePortViewModel()
            {
                ID             = id,
                NodeOffsetX    = nodeoffsetx,
                NodeOffsetY    = nodeoffsety,
                PortVisibility = PortVisibility.Visible,
            };

            (node1.Ports as PortCollection).Add(nodePort);
        }
예제 #4
0
        private NodePortViewModel CreatePort(NodeViewModel node, double offx, double offy)
        {
            NodePortViewModel port = new NodePortViewModel()
            {
                Node        = node,
                NodeOffsetX = offx,
                NodeOffsetY = offy,
            };

            (node.Ports as PortCollection).Add(port);

            return(port);
        }
예제 #5
0
        /// <summary>
        /// Method to create NodePort
        /// </summary>
        /// <param name="node1">Parent for the created nodeport</param>
        /// <param name="id">NodePort ID</param>
        /// <param name="nodeoffsetx">NodePort's OffsetX</param>
        /// <param name="nodeoffsety">NodePort's OffsetY</param>
        /// <param name="porttype">Port Type</param>
        private void CreateNodePort(NodeViewModel node1, string id, double nodeoffsetx, double nodeoffsety)
        {
            NodePortViewModel nodePort = new NodePortViewModel()
            {
                ID             = id,
                NodeOffsetX    = nodeoffsetx,
                NodeOffsetY    = nodeoffsety,
                Shape          = resourceDictionary["Ellipse"],
                Constraints    = PortConstraints.Default & ~PortConstraints.InheritPortVisibility,
                PortVisibility = PortVisibility.Collapse,
            };

            (node1.Ports as PortCollection).Add(nodePort);
        }
예제 #6
0
        public static NodePortView FindNodePortView <T>(FrameworkElement rootVisual, Guid guid, string portName) where T : NodePortView
        {
            NodeView nodeView = FindNodeView(rootVisual, guid);

            List <T> portViews = new List <T>();

            FindChildren(nodeView, portViews);

            foreach (var portView in portViews)
            {
                NodePortViewModel portVM = portView.DataContext as NodePortViewModel;
                if (portVM.Model.Name == portName)
                {
                    return(portView);
                }
            }

            return(null);
        }
예제 #7
0
        private void InitializeDiagram()
        {
            SwimlaneViewModel swimLane = new SwimlaneViewModel();

            swimLane.Orientation = Orientation.Horizontal;
            swimLane.OffsetX     = 400;
            swimLane.OffsetY     = 300;
            swimLane.UnitWidth   = 650;
            swimLane.UnitHeight  = 500;

            swimLane.Header = new SwimlaneHeaderViewModel()
            {
                UnitHeight = 50,
                Annotation = new AnnotationEditorViewModel()
                {
                    Content = "SALES PROCESS FLOW CHART"
                },
            };
            PhaseViewModel nn1 = CreatePhaseViewModel(true, "Phase1", 0);

            nn1.UnitWidth = 760;

            swimLane.Phases = new ObservableCollection <PhaseViewModel>()
            {
                nn1
            };

            LaneViewModel ll1 = CreateLaneViewModel(true, "Consumer", 270);
            NodeViewModel n1  = ChildElement(ll1, "Rectangle", "Consumer learns of product", 130, 55);
            NodeViewModel n2  = ChildElement(ll1, "Decision", "Does Consumer \n want the product", 320, 55);
            NodeViewModel n3  = ChildElement(ll1, "Flow", "No sales lead", 520, 55);
            NodeViewModel n4  = ChildElement(ll1, "Rectangle", "Sell to consumer", 680, 55);


            LaneViewModel ll2 = CreateLaneViewModel(true, "Marketing", 270);
            NodeViewModel n5  = ChildElement(ll2, "Rectangle", "Create marketing campaigns", 130, 55);
            NodeViewModel n6  = ChildElement(ll2, "Rectangle", "Marketing finds sales leads", 320, 55);


            LaneViewModel ll3 = CreateLaneViewModel(true, "Sales", 270);
            NodeViewModel n7  = ChildElement(ll3, "Rectangle", "Sales receives lead", 320, 60);

            LaneViewModel ll4 = CreateLaneViewModel(true, "Success", 270);
            NodeViewModel n8  = ChildElement(ll4, "Rectangle", "Success helps retain consumer as a customer", 680, 55);

            ll1.UnitHeight = 115;
            ll2.UnitHeight = 115;
            ll3.UnitHeight = 115;
            ll4.UnitHeight = 115;
            swimLane.Lanes = new ObservableCollection <LaneViewModel>()
            {
                ll1, ll2, ll3, ll4
            };

            (this.Swimlanes as ObservableCollection <SwimlaneViewModel>).Add(swimLane);



            CreateConnection(n1, n2);
            ConnectorViewModel noconnector = CreateConnection(n2, n3);

            noconnector.Annotations = new ObservableCollection <IAnnotation>()
            {
                new AnnotationEditorViewModel()
                {
                    Content = "No"
                }
            };
            CreateConnection(n4, n8);
            ConnectorViewModel yesconnector = CreateConnection(n2, n6);

            yesconnector.Annotations = new ObservableCollection <IAnnotation>()
            {
                new AnnotationEditorViewModel()
                {
                    Content = "Yes", RotationReference = RotationReference.Page, Length = 0.4
                }
            };
            CreateConnection(n5, n1);
            CreateConnection(n6, n7);
            ConnectorViewModel con   = CreateConnection(n4, n7);
            NodePortViewModel  port  = CreatePort(n4, 0, 0.5);
            NodePortViewModel  port1 = CreatePort(n7, 1, 0.5);

            con.SourcePort = port;
            con.TargetPort = port1;
        }