/// <summary> /// on send button click Flight Window is created and subscribers defined /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, RoutedEventArgs e) { var flightNumber = txtFlightNumber.Text; // FlightWindow flightWindowObj = new FlightWindow(flightNumber); // declare and create Flight Window object (publisher) flightWindowObj.Show(); flightWindowObj.ChangesHandler += OnChangesHandler; // add subscriber flightWindowObj.LandedHandler += OnChangesHandler; // add subscriber flightWindowObj.LandedHandler += arrivalWindowObj.OnArrivalHandler; // add subscriber }
/// <summary> /// Click event for "Start new flight" button /// </summary> /// <param name="sender">the object sending the event</param> /// <param name="e">event arguments</param> private void StartNewFlightBtn_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(CheckFormatOfFlightCode(FlightCodeTextBox.Text))) { FlightWindow flight = new FlightWindow(FlightCodeTextBox.Text); flight.Show(); SubscribeToTheEventsOfFlightWindow(flight); } else if (!string.IsNullOrEmpty(FlightCodeTextBox.Text) && string.IsNullOrEmpty(CheckFormatOfFlightCode(FlightCodeTextBox.Text))) { MessageBox.Show("Please supply a flight code in the form ABC AB123 (in the case of SAS: SAS, American Airlines: AAL, Lufthansa: DLH))", "Take note"); } else { MessageBox.Show("Please supply a flight code", "Take note"); } }