Ejemplo n.º 1
0
 public void Limpar()
 {
     Title = string.Empty;
     Destinations.Clear();
     Body.Clear();
     _mail.To.Clear();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// A method that parses a list of cities into properties used by the solver
        /// </summary>
        /// <param name="cities">The cities to be parsed</param>
        public void OrderData(List <City> cities)
        {
            // Clear any previous information
            Destinations.Clear();
            VisitedCities.Clear();
            DataCleared.Invoke(this, new EventArgs());

            // Set the first city as the start and end
            Origin = cities[0];
            VisitedCities.Add(Origin);
            CityAdded.Invoke(this, new CityAddedEventArgs(Origin, 0));
            VisitedCities.Add(Origin);
            CityAdded.Invoke(this, new CityAddedEventArgs(Origin, 1));

            // Set the next closest node as the second point
            SecondCity = cities[1];

            foreach (City city in cities.Skip(2))
            {
                if (Origin.DistanceTo(city) < Origin.DistanceTo(SecondCity))
                {
                    SecondCity = city;
                }
            }

            VisitedCities.Insert(1, SecondCity);
            CityAdded.Invoke(this, new CityAddedEventArgs(SecondCity, 1));

            // Add the rest of the cities to the destinations list
            Destinations = cities.Where(c => c != Origin && c != SecondCity).ToList();
        }
Ejemplo n.º 3
0
        async Task ExecuteLoadDestinationsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Destinations.Clear();
                var destinations = await DestData.GetDestinationsAsync(true);

                Destinations.ReplaceRange(destinations);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                MessagingCenter.Send(new MessagingCenterAlert
                {
                    Title   = "Error",
                    Message = "Unable to load items.",
                    Cancel  = "OK"
                }, "message");
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 4
0
 public void SetSingleDirectDest(string dest)
 {
     Destinations.Clear();
     Destinations.Add(new DestData()
     {
         Destination = dest
     });
 }
Ejemplo n.º 5
0
        /// <summary>
        /// A method that parses a list of cities into properties used by the solver
        /// </summary>
        /// <param name="cities">The cities to be parsed</param>
        public void OrderData(List <City> cities)
        {
            // Clear any previous information
            PopulationSize = 10;
            Destinations.Clear();

            // Set the first city as the start and end
            Origin = cities[0];

            // Add the rest of the cities to the destinations list
            Destinations = cities.Where(c => c != Origin).ToList();
        }
        public void ClearDestinationBindings()
        {
            lock (Parent)
            {
                foreach (DestinationInfo dInfo in Destinations)
                {
                    dInfo.BindingGroupIds.Remove(Id);
                }

                Destinations.Clear();
                ReconstructFastDestinationArray();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// A method that reads the cities from the current file
        /// </summary>
        private void GetCities()
        {
            // Makes sure the file is valid
            if (CurrentFile != null && !CurrentFile.Exists)
            {
                MessageBox.Show("There is no valid file selected", "No Valid File",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Clear any previous data
            Origin = null;
            Destinations.Clear();

            string[]     temp;
            StreamReader reader = new StreamReader(CurrentFile.FullName);

            // Skip the first four lines
            for (int x = 0; x < 4; x++)
            {
                reader.ReadLine();
            }

            // Get the number of destinations
            temp = reader.ReadLine().Split(' ');
            int cityCount = int.Parse(temp[1]);

            // Skip two more lines
            for (int y = 0; y < 2; y++)
            {
                reader.ReadLine();
            }

            // Read the data for the origin city
            temp   = reader.ReadLine().Split(' ');
            Origin = new City(int.Parse(temp[0]),
                              double.Parse(temp[1]),
                              double.Parse(temp[2]));

            // Read the data for each city
            for (int z = 0; z < cityCount - 1; z++)
            {
                temp = reader.ReadLine().Split(' ');
                Destinations.Add(new City(int.Parse(temp[0]),
                                          double.Parse(temp[1]),
                                          double.Parse(temp[2])));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Check for changes in the database
        /// </summary>
        public void UpdateDestinations()
        {
            //store currently selected destinations
            List <Destination> selected = SelectedDestinations.Select(s => s.Destination).ToList();

            //get rid of old entries
            Destinations.Clear();
            SelectedDestinations.Clear();

            //re-initialize destination list
            InitDestinations();

            //restore previous selections
            Destinations.Where(d => selected.Contains(d.Destination)).ToList().ForEach(d => SelectDestination(d));

            //TODO: improve this messy updating approach...
            //update filtered list
            IoC.CreateTripViewModel.RecalcFilteredDestinations();

            //TODO: currently, deleting destinations from DB is not planned
        }