MoonveenLad Posted March 13, 2019 Report Posted March 13, 2019 Hi, I have been working through Paul's tutorials for the last couple of months, which has been a fun learning curve. I have been working on a little application to move my aircraft to different airports. I have followed the aircraft database example and am able to select an airport and get the information back regarding gates, runways and helipads. My question is, once the gate, runways or helipad's are loaded into the combo boxes, how can i select the helipad and move to that location?? just cant seem to be able to get the moveaircraft to work. Can any guide me in the right direction (I'm still Learning) Thanks in Advance, Padraig
Paul Henty Posted March 13, 2019 Report Posted March 13, 2019 Hi Padraig, The easiest way is to get the FsHelipad object for the required helipad. You can either call the MoveAircraftHere() method on that helipad, or pass the helipad directly to FSUIPCConnection.MoveAircraft(). How you get the FsHelipad object depends on how you've populated the combo box. If you've just filled the combo box with the text IDs then you need something like the following code: // 1. Get the airport from the database using the ICAO code... FsAirport airport = FSUIPCConnection.AirportsDatabase["EGLL"]; // 2, Get the selected helipad ID from the combo box string helipadID = this.cbxHelipads.Text; // 3. Check it exists at this airport if (airport.Helipads.Contains(helipadID) { // 4. It does, so get the FsHelipad object using the ID FsHelipad helipad = airport.Helipads[helipadID]; // 5. Pass this to MoveAircraft FSUIPCConnection.MoveAircraft(helipad, true); // move aircraft to helipad and leave paused. // OR call the helper method on the helipad... // helipad.MoveAircraftHere(true); // move aircraft to helipad and leave paused. } If you've populated the combo boxes directly with the FsHelipadCollection then you need to get the fsHelipad from the combo box. Something like this... // 1, Get the selected helipad from the combo box if (this.cbxHelipads.SelectedItem != null) { FsHelipad helipad = (FsHelipad)this.cbxHelipads.SelectedItem; // 2. Pass this to MoveAircraft FSUIPCConnection.MoveAircraft(helipad, true); // move aircraft to helipad and leave paused. // OR call the helper method on the helipad... // helipad.MoveAircraftHere(true); // move aircraft to helipad and leave paused. } If none of that helps, please show me the code that populates one of your combo boxes and I can give you the exact code. Paul
MoonveenLad Posted March 13, 2019 Author Report Posted March 13, 2019 Hi Paul, Thank you very much for getting back to me. Forgot to mention I'm using vb.net. This is the code im using to populate the combo box; Me.selectedAirport = Nothing Dim airports As FsAirportCollection = FSUIPCConnection.AirportsDatabase.Airports Dim airport As FsAirport = airports(Me.txtICAO.Text.ToUpper()) If airport IsNot Nothing Then Me.selectedAirport = airport Me.cbxHeli.Items.AddRange(airport.Helipads.[Select](Function(h) h.ID).ToArray()) If Me.cbxHeli.Items.Count > 0 Then Me.cbxHeli.SelectedIndex = 0 End If End If Thanks for all your help Padraig
Paul Henty Posted March 13, 2019 Report Posted March 13, 2019 Here's the required code in VB with your control names... Dim airports As FsAirportCollection = FSUIPCConnection.AirportsDatabase.Airports ' 1. Get the airport from the database using the ICAO code... Dim airport As FsAirport = airports(Me.txtICAO.Text.ToUpper()) ' 2, Get the selected helipad ID from the combo box Dim helipadID As String = Me.cbxHeli.Text ' 3. Try to get the helipad using the ID Dim helipad As FsHelipad = airport.Helipads(helipadID) ' 4. Make sure we got one back... If (helipad IsNot Nothing) Then ' 5. Pass this to MoveAircraft FSUIPCConnection.MoveAircraft(helipad, True) ' move aircraft To helipad And leave paused. ' Or call the helper method on the helipad... ' helipad.MoveAircraftHere(true) ' move aircraft to helipad And leave paused. End If That should work. You can use the same process with runways and gates. Paul
MoonveenLad Posted March 13, 2019 Author Report Posted March 13, 2019 Hi Paul, I cannot thank you enough for your help. It now works perfectly Thanks yet again, Padraig
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now