示例#1
0
        void ISuperGraphRelationshipFactory.TranscludeNodes(List <Node> nodes, INode map, Point location, Point?oldLocation = null)
        {
            if (nodes.Any())
            {
                var modelChangedEventArgs = new ModelChangedEventArgs <Node, Relationship>();
                var batchTransclusions    = new BatchTranscludeNodesOperation(MapManager);
                foreach (var node in nodes)
                {
                    var newOperation = new TranscludeNodesOperation(MapManager);
                    newOperation.NewMap        = Context.Proxy;
                    newOperation.OriginalMap   = map.Proxy;
                    newOperation.ViewModelNode = node;
                    var oldRelativeLocation = oldLocation != null
                        ? node.Location.Subtract(oldLocation.Value)
                        : node.Location;

                    newOperation.Location = oldRelativeLocation.Add(location);
                    node.IsTranscluded    = true;
                    node.NumTranclusions++;
                    batchTransclusions.AddTranscludeNodeOperation(newOperation);

                    var newNodeViewModel = new Node(node);
                    newNodeViewModel.Location = newOperation.Location;
                    newNodeViewModel.CommitLocation();

                    newNodeViewModel.PropertyChanged += ViewModelNode_PropertyChanged;

                    batchTransclusions.Nodes.Add(new KeyValuePair <Node, ModelOperationType>(newNodeViewModel, ModelOperationType.New));
                }
                batchTransclusions.ExecuteOperation();


                modelChangedEventArgs.Nodes = batchTransclusions.Nodes;
                foreach (Proxy.IRelationship modelRelationship in batchTransclusions.Response.Relationships)
                {
                    if (modelRelationship.RelationshipType != modelRelationship.MapManager.RelationshipTypes["MapContainerRelationship"])
                    {
                        var viewModelRelationship = new Relationship();
                        viewModelRelationship.LoadRelationship(modelRelationship);
                        modelChangedEventArgs.Relationships.Add(new KeyValuePair <Relationship, ModelOperationType>(viewModelRelationship, ModelOperationType.New));
                    }
                }
                ModelChanged(this, modelChangedEventArgs);
            }
        }
示例#2
0
        void ISuperGraphRelationshipFactory.TranscludeNode(List <Node> nodes, INode map, Point newLocation)
        {
            foreach (var node in nodes)
            {
                var transcludeNodeOperation = new TranscludeNodesOperation(MapManager);
                transcludeNodeOperation.NewMap        = Context.Proxy;
                transcludeNodeOperation.OriginalMap   = map.Proxy;
                transcludeNodeOperation.ViewModelNode = node;
                transcludeNodeOperation.Location      = newLocation;
                node.IsTranscluded = true;
                node.NumTranclusions++;

                var newNodeViewModel = new Node(node);
                newNodeViewModel.Location = newLocation;
                newNodeViewModel.CommitLocation();
                newNodeViewModel.PropertyChanged += ViewModelNode_PropertyChanged;
                var modelChangedEventArgs = new ModelChangedEventArgs <Node, Relationship>();
                modelChangedEventArgs.Nodes.Add(new KeyValuePair <Node, ModelOperationType>(newNodeViewModel, ModelOperationType.New));
                ModelChanged(this, modelChangedEventArgs);

                transcludeNodeOperation.ExecuteOperation();
            }
        }