/// <summary> /// Update from Sim /// </summary> public void OnDataArrival(string dataRefName) { if (this.Visible) { // ATC Arrival Airport if (AirportMgr.HasChanged) { _value1.Text = AirportMgr.Read( ); // update only when changed } // Distance to Destination if (HudBar.AtcFlightPlan.HasFlightPlan) { _value2.Value = HudBar.AtcFlightPlan.RemainingDist_nm( SC.SimConnectClient.Instance.GpsModule.WYP_nextID, SC.SimConnectClient.Instance.GpsModule.WYP_Dist); _value2.ItemForeColor = cGps; } else { // calc straight distance if we don't have an ATC flightplan with waypoints var latLon = new LatLon(SC.SimConnectClient.Instance.HudBarModule.Lat, SC.SimConnectClient.Instance.HudBarModule.Lon); _value2.Value = AirportMgr.ArrDistance_nm(latLon); _value2.ItemForeColor = cInfo; } _value3.Value = (AirportMgr.IsArrAvailable && (AirportMgr.ArrLocation != null)) ? Conversions.Ft_From_M(AirportMgr.ArrLocation.Altitude) : float.NaN; // METAR ToolTip Text and Button Color if (_metar.HasNewData) { // avoiding redraw and flicker for every cycle _toolTip.SetToolTip(this.Label, _metar.Read( )); this.ColorType.ItemBackColor = _metar.ConditionColor; } } }
private void _label_MouseClick(object sender, MouseEventArgs e) { if (!SC.SimConnectClient.Instance.IsConnected) { return; } var TTX = new Config.frmApt( ); // load default if (SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.HasFlightPlan) { // dest from FPLan TTX.DepAptICAO = SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.Departure; TTX.ArrAptICAO = SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.Destination; } else { // no Flightplan if (AirportMgr.IsDepAvailable) { // departure from Mgr (prev entry) TTX.DepAptICAO = AirportMgr.DepAirportICAO; } else { // no preset TTX.DepAptICAO = ""; } if (AirportMgr.IsArrAvailable) { // destination from Mgr (prev entry) TTX.ArrAptICAO = AirportMgr.ArrAirportICAO; } else { // no preset TTX.ArrAptICAO = ""; } } if (TTX.ShowDialog(this) == DialogResult.OK) { // Update DEP if (string.IsNullOrWhiteSpace(TTX.DepAptICAO)) { // empty entry to clear if (SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.HasFlightPlan) { // update with FP destination AirportMgr.UpdateDep(SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.Departure); } else { // clear with N.A. airport AirportMgr.UpdateDep(AirportMgr.AirportNA_Icao); } } else { // user entry - will be checked in the Mgr AirportMgr.UpdateDep(TTX.DepAptICAO); } // Update ARR if (string.IsNullOrWhiteSpace(TTX.ArrAptICAO)) { // empty entry to clear if (SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.HasFlightPlan) { // update with FP destination AirportMgr.UpdateArr(SC.SimConnectClient.Instance.FlightPlanModule.FlightPlan.Destination); } else { // clear with N.A. airport AirportMgr.UpdateArr(AirportMgr.AirportNA_Icao); } } else { // user entry - will be checked in the Mgr AirportMgr.UpdateArr(TTX.ArrAptICAO); } } }