private void addToGroundList(AIPlaneInfo plane) { var database = FSUIPCConnection.AirportsDatabase; // Add this plane to the list // Create a new list item ListViewItem newItem = new ListViewItem(); // ATC Callsign newItem.Text = $"{plane.Airline} {plane.FlightNumber}"; // status newItem.SubItems.Add(plane.State.ToString()); if (plane.State.ToString() == "TaxiingIn") { newItem.SubItems[1].Text = $"Taxiing in to {plane.GateInfo.ID}"; } if (plane.State.ToString() == "TaxiingOut") { newItem.SubItems[1].Text = $"Taxiing out to {plane.RunwayAssigned.ToString()}"; } // aircraft type newItem.SubItems.Add($"{plane.AircraftType} {plane.AircraftModel}"); newItem.SubItems.Add(plane.DistanceFeet.ToString("F0")); // from ICAO newItem.SubItems.Add(plane.DepartureICAO); // to ICAO newItem.SubItems.Add(plane.ArrivalICAO); if (plane.IsAtGate == true) { newItem.SubItems.Add(plane.GateInfo.ID); } else if (plane.IsOnRunway == true) { newItem.SubItems.Add(plane.RunwayAssigned.ToString()); } else { foreach (FsAirport airport in database.Airports) { foreach (FsTaxiway taxiway in airport.Taxiways) { foreach (FsTaxiwaySegment segment in taxiway.Segments) { if (segment.Bounds.ContainsPoint(plane.Location)) { newItem.SubItems.Add($" taxi way {taxiway.Name}"); } } } // Loop through taxiways. } } // Add to the list this.lvGround.Items.Add(newItem); }
private void addToAirbornList(AIPlaneInfo plane) { // Add this plane to the list // Create a new list item ListViewItem newItem = new ListViewItem(); // ATC Callsign newItem.Text = $"{plane.Airline} {plane.FlightNumber}"; // status newItem.SubItems.Add(plane.State.ToString()); // distance in Nautical Miles newItem.SubItems.Add(plane.DistanceNM.ToString("F0")); // from ICAO // newItem.SubItems.Add(plane.DepartureICAO); // to ICAO // newItem.SubItems.Add(plane.ArrivalICAO); // altitude newItem.SubItems.Add(plane.AltitudeFeet.ToString("F0")); // Add to the list this.lvAirborn.Items.Add(newItem); }
private void drawTarget(Graphics graphics, double scale, Point centre, AIPlaneInfo plane) { // We are going to use some of the info from the plane object to draw the target. // Lots more info is avilable for other application. // See the reference manual or Intellisense for details. // Work out the range of the target in pixels by multiplying by the scale double distancePixels = plane.DistanceNM / scale; // Work out the position from the centre using this distance and the bearing double dx = Math.Cos(degreeToRadian(plane.BearingTo)) * distancePixels; double dy = Math.Sin(degreeToRadian(plane.BearingTo)) * distancePixels; PointF target = new PointF((float)centre.X + (float)dx, (float)centre.Y + (float)dy); // Draw the target circle around this point oriented to the plane's heading graphics.DrawEllipse(Pens.LightGreen, target.X - 4f, target.Y - 4f, 8f, 8f); // Draw a line from the circle to indicate heading double tailHeading = 180d + plane.HeadingDegrees; dx = Math.Cos(degreeToRadian(tailHeading)) * 12; dy = Math.Sin(degreeToRadian(tailHeading)) * 12; PointF tailEnd = new PointF(target.X + (float)dx, target.Y + (float)dy); graphics.DrawLine(new Pen(new LinearGradientBrush(target, tailEnd, Color.LightGreen, Color.DarkGreen)), target, tailEnd); // Work out the position of the data block PointF dataBlock = new PointF(target.X + 20, target.Y - 20); // Draw the line to the datablock graphics.DrawLine(Pens.LightGreen, new PointF(target.X + 5, target.Y - 5), new PointF(dataBlock.X - 5, dataBlock.Y + 7)); // Draw the data block // Line 1 - the Callsign graphics.DrawString(plane.ATCIdentifier, this.radaATC.Font, Brushes.LightGreen, dataBlock); // Line 2 - the Altitude (hundreds of feet) and speed string line2 = ""; line2 += ((int)(plane.AltitudeFeet / 100d)).ToString("d3"); // Put a +,- or = depending on if the plane is decending, climbing or level if (plane.VirticalSpeedFeet < 0) { line2 += "-"; } else if (plane.VirticalSpeedFeet > 0) { line2 += "+"; } else { line2 += "="; } graphics.DrawString(line2, this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 12)); // Line 3 - origin, destination and assigned runway graphics.DrawString(plane.DepartureICAO + "->" + plane.DestinationICAO + " " + plane.RunwayAssigned.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 24)); graphics.DrawString(plane.AircraftModel.ToString() + plane.AircraftTitle.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 36)); graphics.DrawString(plane.PitchDegrees.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 48)); graphics.DrawString(plane.FlightNumber.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 60)); graphics.DrawString(plane.Com1String.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 72)); graphics.DrawString(plane.AircraftModel.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 84)); graphics.DrawString(plane.Heading.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 24)); graphics.DrawString(plane.AircraftType.ToString(), this.radaATC.Font, Brushes.LightGreen, new PointF(dataBlock.X, dataBlock.Y + 36)); graphics.DrawString(plane.Airline.ToString(), this.radaATC.Font, Brushes.Red, new PointF(dataBlock.X, dataBlock.Y + 48)); graphics.DrawString(plane.ATCIdentifier.ToString(), this.radaATC.Font, Brushes.Red, new PointF(dataBlock.X, dataBlock.Y + 60)); }