/// <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(); } }
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 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 virtual void ConnectNodesAsync(Dictionary <IDescriptorTypeProxy, Guid> nodes, IRelationshipTypeProxy relationshipType, Point location, string originalId) { NodeService.ConnectNodesAsync(DomainId, nodes, relationshipType, location, originalId); }
public void ConnectNodesAsync(Guid domainId, Dictionary <IDescriptorTypeProxy, Guid> nodes, IRelationshipTypeProxy relationshipType, Point location, string originalId) { Dictionary <SoapDescriptorType, Guid> soapNodes = new Dictionary <SoapDescriptorType, Guid>(); foreach (KeyValuePair <IDescriptorTypeProxy, Guid> nodeDetails in nodes) { SoapDescriptorType soapDescriptorType = new SoapDescriptorType() { Id = nodeDetails.Key.Id, Name = nodeDetails.Key.Name }; soapNodes.Add(soapDescriptorType, nodeDetails.Value); } SoapRelationshipType soapRelationship = new SoapRelationshipType() { Id = relationshipType.Id, Name = relationshipType.Name }; Client.ConnectNodesAsync(domainId, soapNodes, soapRelationship, originalId, location); }
public void ConnectNodesAsync(Guid domainId, Dictionary<IDescriptorTypeProxy, Guid> nodes, IRelationshipTypeProxy relationshipType, Point location, string originalId) { Dictionary<SoapDescriptorType, Guid> soapNodes = new Dictionary<SoapDescriptorType, Guid>(); foreach (KeyValuePair<IDescriptorTypeProxy, Guid> nodeDetails in nodes) { SoapDescriptorType soapDescriptorType = new SoapDescriptorType() { Id = nodeDetails.Key.Id, Name = nodeDetails.Key.Name }; soapNodes.Add(soapDescriptorType, nodeDetails.Value); } SoapRelationshipType soapRelationship = new SoapRelationshipType() { Id = relationshipType.Id, Name = relationshipType.Name }; Client.ConnectNodesAsync(domainId, soapNodes, soapRelationship, originalId, location); }
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 ConnectNodesAsync(Dictionary<IDescriptorTypeProxy, Guid> nodes, IRelationshipTypeProxy relationshipType, Point location, string originalId) { NodeService.ConnectNodesAsync(DomainId, nodes, relationshipType, location, originalId); }