public void AdjustPositionForContainerInMove(IContainerNode node, SizeF offset) { if (!checkAdjustabilityAndRefreshPorts()) { return; } NeighborLink neighborLinkToContainerInMove = null; NeighborLink neighborLinkToOtherContainer = null; if (node.ContainsChildNode(FirstNeighbor, true)) { neighborLinkToContainerInMove = _neighbor1Link; neighborLinkToOtherContainer = _neighbor2Link; } if (node.ContainsChildNode(SecondNeighbor, true)) { neighborLinkToContainerInMove = _neighbor2Link; neighborLinkToOtherContainer = _neighbor1Link; } if (neighborLinkToContainerInMove == null) { return; } Location = mean(neighborLinkToOtherContainer.ToArrowEndPoint, neighborLinkToContainerInMove.ToArrowEndPoint + offset); }
private void addNeighborLink(NeighborLink neighborLink) { var portNode = new PortNode(neighborLink); _portNodes.Add(neighborLink, portNode); InsertBefore(null, portNode); }
public void Initialize(NeighborLink neighborLink, MoleculeNode moleculeNode) { _neighborLink = neighborLink; _moleculeNode = moleculeNode; _moleculeNode.AddLink(this); var simpleContainerNode = (SimpleContainerNode)ContainerNode; simpleContainerNode.AddTransportLink(this); simpleContainerNode.Add(this); }
public PortNode(NeighborLink neighborLink) { Port = new PortNodePort(); NeighborLink = neighborLink; Port.AddSourceLink(neighborLink); IsVisible = true; LocationFixed = false; UserFlags = NodeLayoutType.NEIGHBORHOOD_PORT; AutoResizes = false; Text = string.Empty; Label.FontSize = 8; Label.TextColor = SuiteColors.Gray; LabelSpot = MiddleTop; Shape = new GoEllipse(); InsertBefore(Shape, Port); Shape.Size = new SizeF(15, 10); Port.Size = new SizeF(1, 1); }
public void RefreshPort(NeighborLink neighborLink) { if (!_portNodes.ContainsKey(neighborLink)) { return; } var portNode = _portNodes[neighborLink]; var otherContainerNode = neighborLink.NeighborhoodNode.GetOtherContainerNode(this); // set name string name = ""; var otherContainerParentNode = otherContainerNode.GetParent() as IContainerNode; if (otherContainerParentNode != null) { name += otherContainerParentNode.Name + "/"; } name += otherContainerNode.Name; portNode.Name = name; // set position if (portNode.LocationFixed) { return; } PointF borderPosition; RectangleF bounds = ComputeInsideMargins(null); // find points in both containers near to each other float bx = 10; float by = 10; float otherX, otherY, otherWidth, otherHeight; if (neighborLink.NeighborhoodNode.LocationFixed) { otherX = neighborLink.NeighborhoodNode.Location.X; otherY = neighborLink.NeighborhoodNode.Location.Y; otherWidth = bx; otherHeight = by; } else { otherX = otherContainerNode.Center.X; otherY = otherContainerNode.Center.Y; otherWidth = otherContainerNode.Size.Width; otherHeight = otherContainerNode.Size.Height; } float xo = nearestValueFromIntervalCS(otherX, otherWidth, bx, Center.X); float yo = nearestValueFromIntervalCS(otherY, otherHeight, by, Center.Y); float x = nearestValueFromInterval(bounds.Left, bounds.Right, bx, otherX); float y = nearestValueFromInterval(bounds.Top, bounds.Bottom, by, otherY); bool pointExists = GoObject.GetNearestIntersectionPoint(bounds, new PointF(xo, yo), new PointF(x, y), out borderPosition); //Correct by difference between location and center if (pointExists) { var newLocation = borderPosition + new SizeF(portNode.Location.X - portNode.Center.X, portNode.Location.Y - portNode.Center.Y); if (Math.Abs(newLocation.X - portNode.Location.X) > 0.1 || Math.Abs(newLocation.Y - portNode.Location.Y) > 0.1) { portNode.Location = newLocation; foreach (var link in portNode.Links) { ((GoLink)link).UpdateRoute(); } } } }