예제 #1
0
        public void Sort()
        {
            List <ClassScheduledFlight> sortableList = new List <ClassScheduledFlight>(MyScheduledFlights);

            sortableList.Sort();

            for (int i = 0; i < sortableList.Count; i++)
            {
                MyScheduledFlights.Move(MyScheduledFlights.IndexOf(sortableList[i]), i);
            }
        }
예제 #2
0
 private void Load_Flight_Click(object sender, RoutedEventArgs e)
 {
     #region OpenFileDialog
     Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
     dlg.FileName         = MyUtil.Code + "_FlightS";      // Default file name
     dlg.DefaultExt       = ".xml";                        // Default file extension
     dlg.Filter           = "Text documents (.xml)|*.xml"; // Filter files by extension
     dlg.InitialDirectory = MyManager.WorkPlace;
     Nullable <bool> result = dlg.ShowDialog();
     ObservableCollection <ClassScheduledFlight> vol = new ObservableCollection <ClassScheduledFlight>();
     if (result == true)
     {
         vol = ClassSerializable.LoadFromXMLFormat <ClassScheduledFlight>(dlg.FileName);
     }
     foreach (ClassScheduledFlight t in vol)
     {
         MyScheduledFlights.Add(t);
     }
     Sort();
     List <ClassScheduledFlight> tmp = new List <ClassScheduledFlight>();
     foreach (ClassScheduledFlight item in MyScheduledFlights)
     {
         if (item.Flight.Source == null)
         {
             item.Flight.Source = MyUtil.Code;
         }
         else if (!item.Flight.Source.Equals(MyUtil.Code))
         {
             tmp.Add(item);
         }
     }
     foreach (ClassScheduledFlight item in tmp)
     {
         MyScheduledFlights.Remove(item);
     }
     if (MyScheduledFlights.Count == 0)
     {
         MessageBox.Show("No scheduled flight found for this company !", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     Datagrid_Flights.DataContext = MyScheduledFlights;
     #endregion
 }