Beispiel #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            grdMain.Background = DataUtilities.ChooseBackground(); //Randomly select background

            NameCityDict = CityUtilities.getNameCityDict();        // Get dictionary of City Name to City objects
            txtCity.Focus();
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (user.UserType == UserType.GeneralUser)
            {
                btnAddForecast.Visibility = Visibility.Hidden;
            }

            populateFavouriteCityIds();                     // Get favourite city IDs from file
            codeCityDict = CityUtilities.getCityCodeDict(); // Get dictionary of City Codes to City objects

            createButtonsForCities();

            // If there is no favourites, show placeholders that tell users to add favourites
            if (stckpnlFavourites.Children.Count > 0)
            {
                //By default show forecast for first favourite city
                string firstId = ((Button)stckpnlFavourites.Children[0]).Name.Substring(6);
                showForecast(firstId);
            }
            else
            {
                showPlaceholders();
            }

            Console.WriteLine();
        }
Beispiel #3
0
 //Search cities when text is changed
 private void TxtCity_TextChanged(object sender, TextChangedEventArgs e)
 {
     lstCities.Items.Clear();
     if (!txtCity.Text.Equals(""))
     {
         List <City> matchedCities = CityUtilities.SearchCities(txtCity.Text);
         foreach (var city in matchedCities)
         {
             lstCities.Items.Add(city);
         }
     }
 }
 // Populate list box with cities
 private void populateListBox()
 {
     lstCities.Items.Clear();
     List<City> cities = new List<City>();
     //Get all cities with forecasts, repeats allowed
     foreach (var forecast in forecasts)
     {
         cities.Add(CityUtilities.getCityCodeDict()[forecast.CityID]);
     }
     //Get distinct cities to add to listbox, no repeats
     List<City> distinctCities = cities.Distinct().OrderBy(o => o.name).ToList();
     foreach (var city in distinctCities)
     {
         lstCities.Items.Add(city);
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (user.UserType == UserType.GeneralUser)
            {
                btnAddForecast.Visibility = Visibility.Hidden;
            }

            grdMain.Background = DataUtilities.ChooseBackground(); //Randomly select background
            codeCityDict = CityUtilities.getCityCodeDict(); //Get dictionary of City Codes to City Objects
            forecasts = DataUtilities.GetForecastsFromDB(); //Get forecasts from file
            populateListBox(); //Populate list box with cities

            //Set defaults
            lstCities.SelectedIndex = 0;
            dtpFrom.SelectedDate = DateTime.Now;
            dtpTo.SelectedDate = DateTime.Now;
        }
Beispiel #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            grdMain.Background = DataUtilities.ChooseBackground(); //Randomly select background
            NameCityDict       = CityUtilities.getNameCityDict();  //Get dictionary of City Names to City Objects
            cityCodeDict       = CityUtilities.getCityCodeDict();  //Get dictionary of City IDs to City Objects
            txtCity.Focus();

            //Pre load fields with values supplied from loaded forecast object
            txtCity.Text            = cityCodeDict[loadedForecast.CityID].ToString();
            lstCities.SelectedItem  = cityCodeDict[loadedForecast.CityID];
            lstCities.SelectedIndex = 0;
            dtpDate.SelectedDate    = loadedForecast.ForecastDate;
            sldMin.Value            = loadedForecast.MinimumTemp;
            sldMax.Value            = loadedForecast.MaximumTemp;
            sldWind.Value           = loadedForecast.WindSpeed;
            sldHumidity.Value       = loadedForecast.Humidity;
            sldPrecip.Value         = loadedForecast.Precipitation;
        }