Пример #1
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            LayoutData.Title = "Groups Factory";
            LayoutData.Info  = "Factory setting is a way to customize how groups (models) are created when the user uses the shortcut. " +
                               "Try to group nodes using CTRL+ALT+G now.";
            LayoutData.DataChanged();

            diagram.Options.Groups.Enabled = true;
            diagram.Options.Groups.Factory = (diagram, children) =>
            {
                var group = new GroupModel(children, 25);
                group.AddPort(PortAlignment.Top);
                group.AddPort(PortAlignment.Bottom);
                group.AddPort(PortAlignment.Right);
                group.AddPort(PortAlignment.Left);
                return(group);
            };

            var node1 = NewNode(50, 50);
            var node2 = NewNode(250, 250);
            var node3 = NewNode(500, 100);

            diagram.Nodes.Add(new[] { node1, node2, node3 });

            diagram.Links.Add(new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)));
        }