public void drawGate(Graphics g, Color color, Gate gate, String name)
        {
            Pen pen = new Pen(color, 2);

            int x1 = (int)(gate.nodeConnections[0].location[0] * drawingScale + 10);
            int y1 = (int)(gate.nodeConnections[0].location[1] * drawingScale + 10);
            int y2 = (int)(gate.nodeConnections[1].location[1] * drawingScale + 10);
            int x2 = (int)(gate.nodeConnections[1].location[0] * drawingScale + 10);

            g.DrawLine(pen, x1, y1, x2, y2);

            if (showLabels)
            {
                int textWidth = (int)g.MeasureString(gate.name, SystemFonts.DefaultFont).Width;
                if (y1 > y2)
                {
                    g.DrawString(name, SystemFonts.DefaultFont, Brushes.Black, x1 - textWidth / 2, y2 - 15);
                }
                else
                {
                    g.DrawString(name, SystemFonts.DefaultFont, Brushes.Black, x1 - textWidth / 2, y1 + 15);
                }
            }

            g.FillEllipse(Brushes.Gray, x1 - 3, y1 - 3, 6, 6);
        }
Пример #2
0
        public void getWays(List<Node> nodeList, List<Runway> runWayList, List<Taxiway> taxiWayList, List<Gateway> gateWayList, List<Gate> gateList)
        {
            AirportDocument.Load(@"Simulation\airportlayout.xml");
            XmlNodeList xmlNodes = AirportDocument.SelectNodes("//node");
            List<int> directions = new List<int>();
            List<string> names = new List<string>();
            List<Node[]> runwayNodes = getNodeMatch("runway", directions, AirportDocument, nodeList, names);
            int i = 0;
            foreach (Node[] nodeMatch in runwayNodes)
            {
                Runway runWay = new Runway(nodeMatch[0], nodeMatch[1], directions[i], names[i]);
                runWayList.Add(runWay);
                i++;
            }

            List<Node[]> taxiwayNodes = getNodeMatch("taxiway", directions, AirportDocument, nodeList, names);
            i = 0;
            foreach (Node[] nodeMatch in taxiwayNodes)
            {
                Taxiway taxiWay = new Taxiway(nodeMatch[0], nodeMatch[1], directions[i], names[i]);
                taxiWayList.Add(taxiWay);
                i++;
            }

            List<Node[]> gateNodes = getNodeMatch("gate", directions, AirportDocument, nodeList, names);
            i = 0;
            foreach (Node[] nodeMatch in gateNodes)
            {
                Gate gate = new Gate(nodeMatch[0], nodeMatch[1], directions[i], names[i]);
                gateList.Add(gate);
                i++;
            }

            List<Node[]> gatewayNodes = getNodeMatch("gateway", directions, AirportDocument, nodeList, names);
            i = 0;
            foreach (Node[] nodeMatch in gatewayNodes)
            {
                Gateway gateWay = new Gateway(nodeMatch[0], nodeMatch[1], directions[i], names[i]);
                gateWayList.Add(gateWay);
                i++;
            }
        }