Inheritance: INodeQueryable, INodeManager
Ejemplo n.º 1
0
 void INodeManager.UnionWith(NodeSet nodes)
 {
     if (this != nodes)
     {
         Connections.UnionWith(nodes.Connections);
     }
 }
Ejemplo n.º 2
0
        private void LoadNodesCompleted(object sender, Proxy.NodesEventArgs eventArgs)
        {
            if (eventArgs.State != Context.Proxy)
            {
                throw new UnexpectedMapException("The state of the event doesn't match with this controller.");
            }

            Proxy.RelationshipSet contextRelationships = Context.Proxy.Relationships;

            if (Context.Proxy.Status != Proxy.LoadState.Full)
            {
                throw new UnexpectedMapException("The relationships were not loaded for the context of this map.");
            }

            var mapChildrenRelationships = contextRelationships.FindRelationships(MapManager.ConnectionTypes["To"], MapManager.RelationshipTypes["MapContainerRelationship"]);

            var modelChangedNodesEventArgs         = new ModelChangedEventArgs <Node, Relationship>();
            var modelChangedRelationshipsEventArgs = new ModelChangedEventArgs <Node, Relationship>();

            foreach (Proxy.IRelationship relationship in mapChildrenRelationships)
            {
                Proxy.NodeSet allRelationshipNodes = relationship.Nodes;

                IEnumerable <Proxy.INode> connectedNodes = allRelationshipNodes.FindNodes(MapManager.ConnectionTypes["From"], true);

                if (connectedNodes == null)
                {
                    continue;
                }

                foreach (Proxy.INode modelNode in connectedNodes)
                {
                    var viewModelNode = new Node(MapManager);
                    viewModelNode.LoadNode(relationship, modelNode);
                    ThemeManager.DressNode(viewModelNode);

                    viewModelNode.PropertyChanged += ViewModelNode_PropertyChanged;
                    viewModelNode.LocationChanged += ViewModelNode_LocationChanged;

                    viewModelNode.VideoInfo = VideoController.CreateVideoInfoViewModel(viewModelNode);


                    var fromToRelationships =
                        modelNode.Relationships.FindRelationships(MapManager.RelationshipTypes["FromToRelationship"]);
                    var transclusionRelationships =
                        modelNode.Relationships.FindRelationships(
                            MapManager.RelationshipTypes["TransclusionFromToRelationship"]);

                    foreach (
                        KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> modelRelationshipPair in
                        fromToRelationships)
                    {
                        var viewModelRelationship = new Relationship();
                        viewModelRelationship.LoadRelationship(modelRelationshipPair.Value);

                        modelChangedRelationshipsEventArgs.Relationships.Add(
                            new KeyValuePair <Relationship, ModelOperationType>(viewModelRelationship,
                                                                                ModelOperationType.New));
                    }

                    foreach (
                        KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> transclusionRelationshipPair in
                        transclusionRelationships)
                    {
                        var nodes =
                            transclusionRelationshipPair.Value.Nodes.FindNodes(
                                MapManager.ConnectionTypes["TransclusionMap"]);

                        if (nodes != null)
                        {
                            foreach (Proxy.INode node in nodes)
                            {
                                if (node.Id == Context.Proxy.Id)
                                {
                                    var viewModelRelationship = new Relationship();
                                    viewModelRelationship.LoadRelationship(transclusionRelationshipPair.Value);

                                    modelChangedRelationshipsEventArgs.Relationships.Add(
                                        new KeyValuePair <Relationship, ModelOperationType>(viewModelRelationship,
                                                                                            ModelOperationType.New));
                                    break;
                                }
                            }
                        }
                    }

                    modelChangedNodesEventArgs.Nodes.Add(new KeyValuePair <Node, ModelOperationType>(viewModelNode,
                                                                                                     ModelOperationType.New));


                    ActiveModel.Nodes[viewModelNode.Id] = viewModelNode;
                }
            }

            ModelChanged(this, modelChangedNodesEventArgs);
            ModelChanged(this, modelChangedRelationshipsEventArgs);
            if (MapLoadCompleted != null)
            {
                MapLoadCompleted(this, new EventArgs());
            }
        }