示例#1
0
        /// <summary>
        /// Create and return the node.
        /// </summary>
        /// <param name="offsetx">offset-x of the node</param>
        /// <param name="offsety">offset-y of the node.</param>
        /// <param name="height">Height of the node</param>
        /// <param name="text">Text annotation of the node</param>
        /// <returns></returns>
        private CustomNodeVM CreateNodes(double offsetx, double offsety, double height, string text, string name)
        {
            CustomNodeVM node = new CustomNodeVM()
            {
                UnitHeight  = height,
                UnitWidth   = 100,
                OffsetX     = offsetx,
                OffsetY     = offsety,
                Name        = name,
                Shape       = resourceDictionary["RoundedRectangle"],
                Fill        = new SolidColorBrush(Colors.White),
                Annotations = new ObservableCollection <IAnnotation>()
                {
                    new TextAnnotationViewModel()
                    {
                        Text       = text,
                        FontSize   = 13,
                        Foreground = new SolidColorBrush(Colors.Black),
                        FontFamily = new FontFamily("Calibri(Body)"),
                    }
                },
            };

            return(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);
        }
示例#3
0
        /// <summary>
        /// Created the new instances of the <see cref="ConnectorsViewModel"/> class.
        /// </summary>

        public ConnectorsViewModel(DemoControl demo)
        {
            View = demo;
            //Initialize the nodes and connectors collection
            this.Nodes      = new ObservableCollection <CustomNodeVM>();
            this.Connectors = new ObservableCollection <CustomConnectorVM>();

            //Initialize the port visibility as collapse
            this.PortVisibility = PortVisibility.Collapse;

            //Initialize the default connector type.
            this.DefaultConnectorType = ConnectorType.CubicBezier;

            //Enable the routing to the connectors.
            this.Constraints |= GraphConstraints.Routing;

            //Initialize the shape selection command.
            SelectShapeCommand = new DelegateCommand(OnSelectShapeCommandExecute);

            //Initialize the item added command.
            ItemAddedCommand = new DelegateCommand(OnItemAddedCommandExecute);

            //Initialize the view port chnaged command.
            ViewPortChangedCommand = new DelegateCommand(OnViewPortChangedCommandExecute);

            //Create and add nodes
            CustomNodeVM promotion   = CreateNodes(140, 350, 30, "Promotion");
            CustomNodeVM lead        = CreateNodes(300, 350, 70, "Lead");
            CustomNodeVM account     = CreateNodes(500, 270, 30, "Account");
            CustomNodeVM information = CreateNodes(500, 350, 30, "Information");
            CustomNodeVM opportunity = CreateNodes(500, 430, 30, "Opportunity");
            CustomNodeVM template    = CreateNodes(700, 350, 204, "");

            template.ContentTemplate = View.Resources["ConnectorsContentTemplateforNodeContent"] as DataTemplate;

            //Create node ports
            CreateNodePort(promotion, "promotion", 1, 0.5);

            CreateNodePort(lead, "lead1", 0, 0.5);
            CreateNodePort(lead, "lead2", 1, 0.5);
            CreateNodePort(lead, "lead3", 1, 0.75);
            CreateNodePort(lead, "lead4", 1, 0.25);

            CreateNodePort(information, "information1", 0, 0.5);
            CreateNodePort(information, "information2", 1, 0.5);

            CreateNodePort(account, "account1", 0, 0.5);
            CreateNodePort(account, "account2", 1, 0.5);

            CreateNodePort(opportunity, "opportunity1", 0, 0.5);
            CreateNodePort(opportunity, "opportunity2", 1, 0.5);

            CreateNodePort(template, "template1", 0, 0.5);
            CreateNodePort(template, "template2", 0, 0.4);
            CreateNodePort(template, "template3", 0, 0.6);

            //Add nodes to Nodes property of the Diagram
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(promotion);
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(lead);
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(account);
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(information);
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(opportunity);
            (this.Nodes as ObservableCollection <CustomNodeVM>).Add(template);

            //Create and add connectors
            CreateConnectors("promotion", "lead1");
            CreateConnectors("lead4", "account1");
            CreateConnectors("lead2", "information1");
            CreateConnectors("lead3", "opportunity1");
            CreateConnectors("template2", "account2");
            CreateConnectors("template1", "information2");
            CreateConnectors("template3", "opportunity2");
            this.CreateDecoraorsCollection();

            this.SelectedItems = new SelectorViewModel();
            (this.SelectedItems as SelectorViewModel).SelectorConstraints &= ~(SelectorConstraints.QuickCommands);
        }