예제 #1
0
        public MainWindow()
        {
            InitializeComponent();
            CompanieAeriana.NumeFisierSerializare = "CompanieAeriana.txt";
            if (File.Exists(Properties.Settings.Default.SerializationFilesPath + CompanieAeriana.NumeFisierSerializare))
            {
                AirMoldova = CompanieAeriana.Deserialize();
            }
            else
            {
                AirMoldova = new CompanieAeriana("Air", "Chisinau", "0789856356", "*****@*****.**");
            }
            AirMoldova.GraphRute = new AdjacencyGraph <Aeroport, Edge <Aeroport> >();
            ThreadPool.SetMaxThreads(2, 2);
            ThreadPool.QueueUserWorkItem(obj => { Aeroport.LoadAeroporturi(); });
            ThreadPool.QueueUserWorkItem(obj => { AirMoldova.DeserializeazaDiscounturi(); });
            LoadRoutes();

            CurrentMainWindow = this;
            //Action LoadAeropAsync = new Action(Aeroport.LoadAeroporturi);
            //LoadAeropAsync.BeginInvoke(new AsyncCallback(result =>
            //{
            //    (result.AsyncState as Action).EndInvoke(result);

            //}), LoadAeropAsync);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (this.GetHashCode() != obj.GetHashCode())
            {
                return(false);
            }
            //System.Diagnostics.Debug.Assert(base.GetType() != typeof(object)); // check base.Equals() if base overides Equals()
            //if (!base.Equals(obj))
            //    return false;
            Aeroport aeroport = obj as Aeroport;

            return(this.Nume.Equals(aeroport.Nume) && this.Tara.Equals(aeroport.Tara) &&
                   this.Oras.Equals(aeroport.Oras) && this.IATA.Equals(aeroport.IATA) &&
                   this.ICAO.Equals(aeroport.ICAO));
        }
예제 #3
0
 public static void LoadAeroporturi()
 {
     if (Aeroport.aeroporturi == null)
     {
         Aeroport.aeroporturi = new SortedDictionary <string, SortedDictionary <string, IList <Aeroport> > >();
     }
     string[] aeroporturi = File.ReadAllLines(Properties.Settings.Default.DataFilesPath + "Airports.txt");
     foreach (var aeroport in aeroporturi)
     {
         string[] atribute = aeroport.Split(',');
         try
         {
             var aeroportNou = new Aeroport(atribute[0], atribute[1], atribute[2],
                                            atribute[3], atribute[4]);
             if (Aeroporturi.ContainsKey(aeroportNou.Tara) == false)
             {
                 Aeroporturi.Add(aeroportNou.Tara, new SortedDictionary <string, IList <Aeroport> >());
                 Aeroporturi[aeroportNou.Tara].Add(aeroportNou.Oras, new List <Aeroport>());
             }
             else if (Aeroporturi[aeroportNou.Tara].ContainsKey(aeroportNou.Oras) == false)
             {
                 Aeroporturi[aeroportNou.Tara].Add(aeroportNou.Oras, new List <Aeroport>());
             }
             Aeroporturi[aeroportNou.Tara][aeroportNou.Oras].Add(aeroportNou);
         }
         catch (ArgumentNullException)
         {
         }
         catch (FormatException)
         {
         }
     }
 }
예제 #4
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            Aeroport aeroport = obj as Aeroport;

            if (obj != null)
            {
                if (this.Nume.CompareTo(aeroport.Nume) == 1)
                {
                    return(1);
                }
                else if (this.Nume.CompareTo(aeroport.Nume) == -1)
                {
                    return(-1);
                }
                else
                {
                    return(this.IATA.CompareTo(aeroport.IATA));
                }
            }
            else
            {
                throw new ArgumentException("Object is not a " + this.GetType().ToString());
            }
        }
예제 #5
0
 public RutaAeriana(RutaAeriana ruta)
 {
     AeroportDecolare  = (Aeroport)ruta.AeroportDecolare.Clone();
     AeroportAterizare = (Aeroport)ruta.AeroportAterizare.Clone();
 }
예제 #6
0
 public RutaAeriana(Aeroport decolare, Aeroport aterizare)
 {
     AeroportDecolare  = decolare;
     AeroportAterizare = aterizare;
 }