/// <summary> /// When a relationship is drawn by right clicking on one node and dragging the line to the another node a FromToRelationship /// will be constructed, that is the event that triggers this method. /// </summary> /// <param name="sender">The NodeRelationshipHelper that has detected the connection has been drawn</param> /// <param name="e"></param> private void OnNodesConnected(object sender, EventArgs e) { NodeRelationshipHelper nrh = sender as NodeRelationshipHelper; if (nrh != null) { IDescriptorTypeProxy toDescriptorTypeProxy = _typeManager.GetDescriptorType("To"); IDescriptorTypeProxy fromDescriptorTypeProxy = _typeManager.GetDescriptorType("From"); IDescriptorTypeProxy transMapDescriptorTypeProxy = _typeManager.GetDescriptorType("TransclusionMap"); INodeProxy fromNode = nrh.FromNode.DataContext as INodeProxy; INodeProxy toNode = nrh.ToNode.DataContext as INodeProxy; Dictionary <IDescriptorTypeProxy, Guid> nodes = new Dictionary <IDescriptorTypeProxy, Guid>(); nodes.Add(toDescriptorTypeProxy, toNode.Id); nodes.Add(fromDescriptorTypeProxy, fromNode.Id); IRelationshipTypeProxy relationshipTypeProxy = null; if (fromNode.ParentMapNodeUid != this.Navigator.FocalNodeId || toNode.ParentMapNodeUid != this.Navigator.FocalNodeId) { nodes.Add(transMapDescriptorTypeProxy, this.Navigator.FocalNodeId); relationshipTypeProxy = _typeManager.GetRelationshipType("TransclusionRelationship"); } else { relationshipTypeProxy = _typeManager.GetRelationshipType("FromToRelationship"); } _navigator.ConnectNodesAsync(nodes, relationshipTypeProxy, string.Empty); _navigator.GetCurrentNodesAsync(); } }
public IEnumerable <IDescriptorProxy> GetByDescriptorType(IDescriptorTypeProxy descriptorType) { foreach (IDescriptorProxy descriptor in this) { if (descriptor.DescriptorType == descriptorType) { yield return(descriptor); } } }
private void ConnectNodeToMap(Guid nodeId, Point location) { TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy toDescriptorTypeProxy = typeManager.GetDescriptorType("To"); IDescriptorTypeProxy fromDescriptorTypeProxy = typeManager.GetDescriptorType("From"); Dictionary <IDescriptorTypeProxy, Guid> nodes = new Dictionary <IDescriptorTypeProxy, Guid>(); nodes.Add(toDescriptorTypeProxy, FocalNodeId); nodes.Add(fromDescriptorTypeProxy, nodeId); IRelationshipTypeProxy relationshipTypeProxy = typeManager.GetRelationshipType("MapContainerRelationship"); ConnectNodesAsync(nodes, relationshipTypeProxy, location, string.Empty); }
private void RenderNodeAsChild(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y) { x = 0.0; y = 0.0; IRelationshipProxy mapRelationship = GetMapRelationship(Node); descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("From"); xPosKey.DescriptorTypeUid = descriptorType.Id; yPosKey.DescriptorTypeUid = descriptorType.Id; if (mapRelationship != null) { xPosKey.RelationshipUid = mapRelationship.Id; yPosKey.RelationshipUid = mapRelationship.Id; } GetNodeLocation(xPosKey, yPosKey, out x, out y); }
public void RenameNodeMetadata(MetadataContext key, string newName) { if (HasMetadata(key)) { INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance <INodeService>(); TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy descriptorType = null; if (key.DescriptorTypeUid.HasValue) { descriptorType = typeManager.GetDescriptorType(key.DescriptorTypeUid.Value); } Guid relationshipId = Guid.Empty; if (key.RelationshipUid.HasValue) { relationshipId = key.RelationshipUid.Value; } nodeService.RenameNodeMetadataAsync(Domain, Id, relationshipId, descriptorType, key.MetadataName, newName); } }
private void RenderNodeAsTransclusion(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y) { x = 0.0; y = 0.0; descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("TransclusionMap"); xPosKey.DescriptorTypeUid = descriptorType.Id; yPosKey.DescriptorTypeUid = descriptorType.Id; foreach (IRelationshipProxy relationship in GetTransclusionRelationship(Node)) { xPosKey.RelationshipUid = relationship.Id; yPosKey.RelationshipUid = relationship.Id; if (GetNodeLocation(xPosKey, yPosKey, out x, out y)) { break; } } }
private void pasteMenuItem_Click(object sender, RoutedEventArgs e) { string clipboardText = Clipboard.GetText(); using (XmlReader reader = XmlReader.Create(new StringReader(clipboardText))) { try { // Parse the file and display each of the nodes. while (reader.ReadToFollowing("Node")) { reader.MoveToAttribute("Id"); string nodeId = reader.Value; Guid copiedGuid = Guid.Empty; //if it's a valid Guid do the operation if (Guid.TryParse(nodeId, out copiedGuid)) { //TODO: Do Paste operation which creates a reference copy (shortcut) of the copied node in the same map TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy toDescriptorTypeProxy = typeManager.GetDescriptorType("To"); IDescriptorTypeProxy transMapDescriptorTypeProxy = typeManager.GetDescriptorType("TransclusionMap"); Dictionary <IDescriptorTypeProxy, Guid> nodes = new Dictionary <IDescriptorTypeProxy, Guid>(); nodes.Add(transMapDescriptorTypeProxy, Navigator.FocalNodeId); nodes.Add(toDescriptorTypeProxy, copiedGuid); IRelationshipTypeProxy relationshipTypeProxy = typeManager.GetRelationshipType("TransclusionRelationship"); Navigator.ConnectNodesAsync(nodes, relationshipTypeProxy, Location, string.Empty); } } } catch (XmlException) { //safe to ignore if it's not valid XML } } }
public void SetNodeMetadata(MetadataContext key, string metadataValue, IMetadataTypeProxy metadataType) { if (BaseSoapNode.Metadata != null) { if (HasMetadata(key)) { GetNodeMetadata(key).MetadataValue = metadataValue; } else { BaseSoapNode.Metadata.Add(key, new SoapMetadata() { MetadataName = key.MetadataName, MetadataType = new SoapMetadataType() { Id = metadataType.Id, Name = metadataType.Name }, MetadataValue = metadataValue }); } INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance <INodeService>(); TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy descriptorType = null; if (key.DescriptorTypeUid.HasValue) { descriptorType = typeManager.GetDescriptorType(key.DescriptorTypeUid.Value); } Guid relationshipId = Guid.Empty; if (key.RelationshipUid.HasValue) { relationshipId = key.RelationshipUid.Value; } nodeService.UpdateNodeMetadataAsync(Domain, this.Id, relationshipId, descriptorType, key.MetadataName, metadataValue, metadataType); } }
private void OnConnectNodesCompleted(object sender, ConnectNodesCompletedEventArgs e) { if (e.Error == null) { List <INodeProxy> nodes = new List <INodeProxy>(); ConnectedNodesResult connectResult = e.Result; foreach (SoapNode soapNode in connectResult.Nodes.Values) { if (_cachedNodes.ContainsKey(soapNode.Id)) { _cachedNodes.Remove(soapNode.Id); } NodeProxy node = new NodeProxy(soapNode); _cachedNodes.Add(soapNode.Id, node); nodes.Add(node); } foreach (INodeProxy nodeProxy in nodes) { foreach (IDescriptorProxy descriptorProxy in nodeProxy.Descriptors) { CompleteRelationship(descriptorProxy.Relationship); } } ConnectedNodesEventArgs connectedNodesEventArgs = new ConnectedNodesEventArgs(); connectedNodesEventArgs.Nodes = nodes.ToArray(); connectedNodesEventArgs.Relationship = new RelationshipProxy(e.Result.Relationship); CompleteRelationship(connectedNodesEventArgs.Relationship); //When a node is connected via a MapContainerRelationship the UserState will be the location of the new node //on the map, it can't be stored in the db until the relationship exists since it's the contectual relationship //that determines where it is located in it's view in this map (it may be elsewhere in transclusions) if (e.UserState != null) { INodeProxy nodeProxy = connectedNodesEventArgs.Nodes[1]; Point location = (Point)e.UserState; if (location != null) { TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IDescriptorTypeProxy descriptorType = null; if (e.Result.Relationship.RelationshipType.Name == "TransclusionRelationship") { descriptorType = typeManager.GetDescriptorType("TransclusionMap"); } else { descriptorType = typeManager.GetDescriptorType("From"); } MetadataContext xPositionKey = new MetadataContext() { NodeUid = nodeProxy.Id, RelationshipUid = e.Result.Relationship.Id, DescriptorTypeUid = descriptorType.Id, MetadataName = "XPosition" }; MetadataContext yPositionKey = new MetadataContext() { NodeUid = nodeProxy.Id, RelationshipUid = e.Result.Relationship.Id, DescriptorTypeUid = descriptorType.Id, MetadataName = "YPosition" }; if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(xPositionKey) != null) { nodeProxy.GetNodeMetadata(xPositionKey).MetadataValue = location.X.ToString(); } else { MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy; if (metaDataTypeProxy != null) { SoapMetadata soapMetadata = new SoapMetadata(); soapMetadata.MetadataName = "XPosition"; soapMetadata.MetadataType = metaDataTypeProxy.BaseSoapNodeType; soapMetadata.MetadataValue = location.X.ToString(); nodeProxy.Metadata.Add(xPositionKey, soapMetadata); } } if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(yPositionKey) != null) { nodeProxy.GetNodeMetadata(yPositionKey).MetadataValue = location.Y.ToString(); } else { MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy; if (metaDataTypeProxy != null) { SoapMetadata soapMetadata = new SoapMetadata(); soapMetadata.MetadataName = "YPosition"; soapMetadata.MetadataType = metaDataTypeProxy.BaseSoapNodeType; soapMetadata.MetadataValue = location.Y.ToString(); nodeProxy.Metadata.Add(yPositionKey, soapMetadata); } } } } if (ConnectNodesCompleted != null) { ConnectNodesCompleted.Invoke(this, connectedNodesEventArgs); } } }
public void RenameNodeMetadataAsync(Guid domainId, Guid nodeId, Guid relationshipId, IDescriptorTypeProxy descriptorTypeProxy, string originalMetadataName, string newMetadataName) { Guid soapRelationshipId = Guid.Empty; if (relationshipId != Guid.Empty) { soapRelationshipId = relationshipId; } SoapDescriptorType soapDescriptorType = null; if (descriptorTypeProxy != null) { soapDescriptorType = new SoapDescriptorType() { Id = descriptorTypeProxy.Id, Name = descriptorTypeProxy.Name }; } Client.RenameNodeMetadataAsync(domainId, nodeId, soapRelationshipId, soapDescriptorType, originalMetadataName, newMetadataName); }
private void RenderNodeAsTransclusion(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y) { x = 0.0; y = 0.0; descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>().GetDescriptorType("TransclusionMap"); xPosKey.DescriptorTypeUid = descriptorType.Id; yPosKey.DescriptorTypeUid = descriptorType.Id; foreach (IRelationshipProxy relationship in GetTransclusionRelationship(Node)) { xPosKey.RelationshipUid = relationship.Id; yPosKey.RelationshipUid = relationship.Id; if (GetNodeLocation(xPosKey, yPosKey, out x, out y)) { break; } } }
private void OnConnectNodesCompletedNodeArgs(object sender, ConnectedNodesEventArgs e) { List <INodeProxy> nodes = new List <INodeProxy>(); TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>(); IMetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double"); if (e.Relationship.RelationshipType.Name == "TransclusionRelationship") { foreach (IDescriptorProxy descriptorProxy in e.Relationship.Descriptors.GetByDescriptorTypeName("To")) { nodes.Add(descriptorProxy.Node); } if (e.Nodes.Length == 2) //TODO: Fix this, currently checking if it's just a transcluded node to map relationship { IDescriptorTypeProxy transclusionMapDesc = typeManager.GetDescriptorType("TransclusionMap"); MetadataContext xPositionKey = new MetadataContext() { NodeUid = e.Nodes[1].Id, MetadataName = "XPosition", RelationshipUid = e.Relationship.Id, DescriptorTypeUid = transclusionMapDesc.Id }; MetadataContext yPositionKey = new MetadataContext() { NodeUid = e.Nodes[1].Id, MetadataName = "YPosition", RelationshipUid = e.Relationship.Id, DescriptorTypeUid = transclusionMapDesc.Id }; //it'll be the second node that is the added node, the first node is the map - this is unsafe to assume so needs to be fixed UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, transclusionMapDesc, "XPosition", e.Nodes[1].GetNodeMetadata(xPositionKey).MetadataValue, metaDataTypeProxy); UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, transclusionMapDesc, "YPosition", e.Nodes[1].GetNodeMetadata(yPositionKey).MetadataValue, metaDataTypeProxy); } } else if (e.Relationship.RelationshipType.Name == "MapContainerRelationship") { //if it's a MapContainerRelationship update the positioning based on the context of this map it's being added to IDescriptorTypeProxy fromDescriptorTypeProxy = null; if (e.Relationship != null) { fromDescriptorTypeProxy = typeManager.GetDescriptorType("From"); MetadataContext xPositionKey = new MetadataContext() { NodeUid = e.Nodes[1].Id, MetadataName = "XPosition", RelationshipUid = e.Relationship.Id, DescriptorTypeUid = fromDescriptorTypeProxy.Id }; MetadataContext yPositionKey = new MetadataContext() { NodeUid = e.Nodes[1].Id, MetadataName = "YPosition", RelationshipUid = e.Relationship.Id, DescriptorTypeUid = fromDescriptorTypeProxy.Id }; //it'll be the second node that is the added node, the first node is the map - this is unsafe to assume so needs to be fixed UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, fromDescriptorTypeProxy, "XPosition", e.Nodes[1].GetNodeMetadata(xPositionKey).MetadataValue, metaDataTypeProxy); UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, fromDescriptorTypeProxy, "YPosition", e.Nodes[1].GetNodeMetadata(yPositionKey).MetadataValue, metaDataTypeProxy); nodes.Add(e.Nodes[1]); } } else { foreach (INodeProxy nodeProxy in e.Nodes) { nodes.Add(nodeProxy); } } NodesEventArgs nodesEventArgs = new NodesEventArgs(null, null, nodes.ToArray()); if (ConnectNodesCompleted != null) { ConnectNodesCompleted.Invoke(this, nodesEventArgs); } }
public void UpdateNodeMetadataAsync(Guid domainId, Guid nodeId, Guid relationshipId, IDescriptorTypeProxy descriptorTypeProxy, string metadataName, string metadataValue, IMetadataTypeProxy metadataType) { Guid soapRelationshipId = Guid.Empty; if (relationshipId != Guid.Empty) { soapRelationshipId = relationshipId; } SoapDescriptorType soapDescriptorType = null; if (descriptorTypeProxy != null) { soapDescriptorType = new SoapDescriptorType() { Id = descriptorTypeProxy.Id, Name = descriptorTypeProxy.Name }; } SoapMetadataType soapMetadataType = null; if (metadataType != null) { soapMetadataType = new SoapMetadataType() { Id = metadataType.Id, Name = metadataType.Name }; } Client.UpdateNodeMetadataAsync(domainId, nodeId, soapRelationshipId, soapDescriptorType, metadataName, metadataValue, soapMetadataType); }
private void RenderNodeAsChild(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y) { x = 0.0; y = 0.0; IRelationshipProxy mapRelationship = GetMapRelationship(Node); descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>().GetDescriptorType("From"); xPosKey.DescriptorTypeUid = descriptorType.Id; yPosKey.DescriptorTypeUid = descriptorType.Id; if (mapRelationship != null) { xPosKey.RelationshipUid = mapRelationship.Id; yPosKey.RelationshipUid = mapRelationship.Id; } GetNodeLocation(xPosKey, yPosKey, out x, out y); }
private void CompendiumMapDepthMap_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { _isLeftMouseButtonDown = false; INodeRenderer nr = ViewManager.GetNodeRenderer(_currentMousePosition); NodeRelationshipHelper nrh = IoC.IoCContainer.GetInjectionInstance().GetInstance <NodeRelationshipHelper>(); if (nrh != null) { if (nrh.IsEditting) { if (nr != null) { IRelationshipProxy originalRelationship = nrh.Relationship.DataContext as IRelationshipProxy; _nodeService.DeleteRelationship(Navigator.DomainId, originalRelationship.Id); IDescriptorTypeProxy toDescriptorTypeProxy = _typeManager.GetDescriptorType("To"); IDescriptorTypeProxy fromDescriptorTypeProxy = _typeManager.GetDescriptorType("From"); IDescriptorTypeProxy transMapDescriptorTypeProxy = _typeManager.GetDescriptorType("TransclusionMap"); Dictionary <IDescriptorTypeProxy, Guid> nodes = new Dictionary <IDescriptorTypeProxy, Guid>(); INodeProxy fromNode = null, toNode = null; switch (nrh.EdittingSide) { case RelationshipSide.From: fromNode = nr.Node; toNode = originalRelationship.Descriptors.GetByDescriptorTypeName("To").First().Node; break; case RelationshipSide.To: fromNode = originalRelationship.Descriptors.GetByDescriptorTypeName("From").First().Node; toNode = nr.Node; break; default: break; } nodes.Add(toDescriptorTypeProxy, toNode.Id); nodes.Add(fromDescriptorTypeProxy, fromNode.Id); IRelationshipTypeProxy relationshipTypeProxy = null; if (fromNode.ParentMapNodeUid != this.Navigator.FocalNodeId || toNode.ParentMapNodeUid != this.Navigator.FocalNodeId) { nodes.Add(transMapDescriptorTypeProxy, this.Navigator.FocalNodeId); relationshipTypeProxy = _typeManager.GetRelationshipType("TransclusionRelationship"); } else { relationshipTypeProxy = _typeManager.GetRelationshipType("FromToRelationship"); } _navigator.ConnectNodesAsync(nodes, relationshipTypeProxy, originalRelationship.Id.ToString()); _navigator.GetCurrentNodesAsync(); } else { nrh.Relationship.UpdateArrow(); } } nrh.IsEditting = false; } if (_selectionRectangle != null) { this.uxMapSurface.Children.Remove(_selectionRectangle); double topLeftX = (double)_selectionRectangle.GetValue(Canvas.LeftProperty); double topLeftY = (double)_selectionRectangle.GetValue(Canvas.TopProperty); double bottomRightX = _selectionRectangle.Width + topLeftX; double bottomRightY = _selectionRectangle.Height + topLeftY; _selectionRectangle = null; if (!(Double.IsNaN(bottomRightX) && Double.IsNaN(bottomRightY))) { ViewManager.SelectAllWithinBounds(new Point(topLeftX, topLeftY), new Point(bottomRightX, bottomRightY)); } else { ViewManager.UnselectAllNodes(); ViewManager.UnselectAllRelationships(); } } }
public virtual void UpdateNodeMetadataAsync(INodeProxy node, Guid relationshipId, IDescriptorTypeProxy descriptorType, string metadataName, string metadataValue, IMetadataTypeProxy metadataType) { NodeService.UpdateNodeMetadataAsync(DomainId, node.Id, relationshipId, descriptorType, metadataName, metadataValue, metadataType); }