/// <summary /// If the event ChangedRoute is being triggered it sends info to the ListView and show the information there /// </summary> private void OnChangedRoute(object sender, FlightInfo e) { dynamic strOut = string.Format("\t{0,-40} {1,-40} {2,20}", e.SetFlight, e.SetStatus, e.SetTime); ListView.Items.Add(strOut); }
/// <summary /// Click event, enables and disables buttons and sends information about the flight started to listview later /// </summary> private void startButton_Click(object sender, RoutedEventArgs e) { startButton.IsEnabled = false; landButton.IsEnabled = true; changeRouteBox.IsEnabled = true; string time = DateTime.Now.ToLongTimeString() + ", " + DateTime.Now.ToShortDateString(); //Sets the flightinfo FlightInfo flightInfo = new FlightInfo(this.Title, time, "Started"); OnFlightStart(flightInfo); }
/// <summary /// Constructor with flightInfo object as parameter /// </summary> public ControlTowerWindow(FlightInfo flightInfo) { InitializeComponent(); newFlight = flightInfo; }
/// <summary /// Checks if flightLanded isn't null, if not it sends event /// </summary> private void OnFlightLand(FlightInfo e) { if (FlightLanded != null) { FlightLanded(this, e); } }
/// <summary /// Checks if ChangedRoute isn't null, if not it sends event /// </summary> private void OnChangedRoute(FlightInfo e) { if (ChangedRoute != null) { ChangedRoute(this, e); } }
/// <summary /// Same as before, but this time while clicking "Land" /// </summary> private void landButton_Click(object sender, RoutedEventArgs e) { landButton.IsEnabled = false; changeRouteBox.IsEnabled = false; string time = DateTime.Now.ToShortDateString() + ", " + DateTime.Now.ToLongTimeString(); FlightInfo flightInfo = new FlightInfo(this.Title, time, "Landed"); OnFlightLand(flightInfo); this.Close(); }
/// <summary /// Sends the degree chosen in the ComboBox besides same as before /// </summary> private void changeRouteBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { string time = DateTime.Now.ToLongTimeString() + ", " + DateTime.Now.ToShortDateString(); string deg = ((String)((ComboBoxItem)changeRouteBox.SelectedItem).Content); FlightInfo flightInfo = new FlightInfo(this.Title, time, "Now heading: " + deg); OnChangedRoute(flightInfo); }
/// <summary /// Checks if flightStarted isn't null, if not it sends event /// </summary> public void OnFlightStart(FlightInfo e) { if (FlightStarted != null) { FlightStarted(this, e); } }