internal void setupControl(Subnetwork up) { ProcessStartInfo startInfo = new ProcessStartInfo("ControlCCRC.exe"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; this.ControlPort = PortAggregation.CcRcPort; startInfo.Arguments = this.ControlPort + " " + name + " " + up.ControlPort; this.ProcessHandle = Process.Start(startInfo); Thread.Sleep(50); Program.SwitchToThisWindow(Process.GetCurrentProcess().MainWindowHandle, true); }
internal Node addNetwork(Point point) { foreach (Node node in nodeList) { if (node.Position.Equals(point)) { mainWindow.errorMessage("There is already node in that position."); return(null); } } Address a; Node network; Domain d = checkWhatDomain(point); if (d == null) { a = new Address(false, 0, 0, networkNodesNumber); network = new Node(point, Node.NodeType.NETWORK, a.getName(), 8500 + networkNodesNumber, MANAGPORT, 0); } else { List <Subnetwork> temporaryListOfSubnetworks = checkWhatSubnetwork(point); Subnetwork up = default(Subnetwork); if (temporaryListOfSubnetworks.Any()) { up = temporaryListOfSubnetworks.ElementAt(0); foreach (Subnetwork s in temporaryListOfSubnetworks) { if (s.Size.Height < up.Size.Height && s.Size.Width < up.Size.Width) { up = s; } } } d.NumberOfNodes++; if (up == default(Subnetwork)) { a = new Address(false, d.Name, 0, d.NumberOfNodes); network = new Node(point, Node.NodeType.NETWORK, a.getName(), 8500 + networkNodesNumber, d.ManagementPort, d.ControlPort); } else { a = new Address(false, d.Name, up.Name - 100, d.NumberOfNodes); network = new Node(point, Node.NodeType.NETWORK, a.getName(), 8500 + networkNodesNumber, d.ManagementPort, up.ControlPort); } } ++networkNodesNumber; nodeList.Add(network); mainWindow.addNodeToTable(network); mainWindow.addNode(network); return(network); }
private void checkSubnetworkContent(Subnetwork domain) { Rectangle domainRect = new Rectangle(domain.getPointStart(), domain.Size); foreach (Node n in nodeList) { if (domainRect.Contains(n.Position)) { mainWindow.errorMessage(n.Name + " is in Subnetwork."); } } }
internal Node addClient(Point point) { foreach (Node node in nodeList) { if (node.Position.Equals(point)) { mainWindow.errorMessage("There is already node in that position."); return(null); } } Address a; Node client; Domain d = checkWhatDomain(point); if (d == null) { a = new Address(true, 0, 0, clientNodesNumber); client = new Node(point, Node.NodeType.CLIENT, a.getName(), 8000 + clientNodesNumber, 0, 0); } else { List <Subnetwork> temporaryListOfSubnetworks = checkWhatSubnetwork(point); Subnetwork up = default(Subnetwork); if (temporaryListOfSubnetworks.Any()) { up = temporaryListOfSubnetworks.ElementAt(0); foreach (Subnetwork s in temporaryListOfSubnetworks) { if (s.Size.Height < up.Size.Height && s.Size.Width < up.Size.Width) { up = s; } } } d.NumberOfNodes++; if (up == default(Subnetwork)) { a = new Address(true, d.Name, 0, d.NumberOfNodes); } else { a = new Address(true, d.Name, up.Name - 100, d.NumberOfNodes); } client = new Node(point, Node.NodeType.CLIENT, a.getName(), 8000 + clientNodesNumber, d.ManagementPort, 0, d.NccPort); } ++clientNodesNumber; nodeList.Add(client); mainWindow.addNodeToTable(client); mainWindow.addNode(client); return(client); }
public bool crossingOtherSubnetwork(Subnetwork other) { if (pointFrom.X > other.pointFrom.X && pointTo.X < other.pointTo.X && pointFrom.Y > other.pointFrom.Y && pointTo.Y < other.pointTo.Y) { return(false); } else if (pointFrom.X < other.pointTo.X && pointTo.X > other.pointFrom.X && pointFrom.Y < other.pointTo.Y && pointTo.Y > other.pointFrom.Y) { return(true); } else { return(false); } }
internal Boolean addSubnetworkToQueue(Point subFrom, Point subTo) { bool add = true; Domain subnetworkStart = checkWhatDomain(subFrom); Domain subnetworkStop = checkWhatDomain(subTo); if (subnetworkStart == null || subnetworkStop == null) { return(false); } if (subnetworkStart.Name != subnetworkStop.Name) { add = false; } List <Subnetwork> tempListOfSubnetworks = checkWhatSubnetwork(subFrom, new Point(subFrom.X, subTo.Y), subTo, new Point(subTo.X, subFrom.Y)); if (tempListOfSubnetworks == null) { add = false; } Size tempSize = new Size(Math.Abs(subFrom.X - subTo.X), Math.Abs(subFrom.Y - subTo.Y)); if (tempSize.Width < MainWindow.GAP || tempSize.Height < MainWindow.GAP) { add = false; } if (add) { ++subNumber; Subnetwork toAdd = new Subnetwork(subFrom, subTo, subnetworkStart.Name * 100 + subNumber); checkSubnetworkContent(toAdd); Subnetwork up = default(Subnetwork); if (tempListOfSubnetworks.Any()) { up = tempListOfSubnetworks.ElementAt(0); foreach (Subnetwork s in tempListOfSubnetworks) { if (s.Size.Height < up.Size.Height && s.Size.Width < up.Size.Width) { up = s; } } } if (up == default(Subnetwork)) { toAdd.setupControl(subnetworkStart); } else { toAdd.setupControl(up); } subnetworkList.Add(toAdd); mainWindow.consoleWriter("Subnetwork added " + toAdd.Name); return(true); } else { mainWindow.errorMessage("Subnetwork can't cross each others or domain too small for rendering."); return(false); } }
public Subnetwork(Subnetwork d) : this(d.PointTo, d.PointFrom, d.name) { }