private void SearchBtn_Click(object sender, RoutedEventArgs e)
 {
     if (searchLocationTB.Text != string.Empty)
     {
         string   response  = new AsynchronousClient().SendMessage(11000, "get_location:" + searchLocationTB.Text);
         string[] cityArray = response.Split(';');
         City     foundCity = new City()
         {
             Name      = cityArray[0],
             Latitude  = double.Parse(cityArray[1]),
             Longitude = double.Parse(cityArray[2])
         };
         //new BingMap().GeocodeByAddress(searchLocationTB.Text);
         searchLocationTB.Text = foundCity.Name;
         ClearPinsOnMap();
         Pushpin pin = new Pushpin();
         pin.Location     = new Location(foundCity.Latitude, foundCity.Longitude);
         selectedLocation = pin.Location;
         bingMap.Children.Add(pin);
         bingMap.Center = selectedLocation;
     }
 }
        private async void PowerRangeBtn_Click(object sender, RoutedEventArgs e)
        {
            DarkSkyResponse res;

            CheckDates();
            if (previousSelectedLocation == null || (previousSelectedLocation.Latitude != selectedLocation.Latitude ||
                                                     previousSelectedLocation.Longitude != selectedLocation.Longitude) ||
                (prevEndDate != endDate || prevStartDate != startDate))
            {
                if (CheckSelectedRegionForBingMap() && CheckDates())
                {
                    string   responce = new AsynchronousClient().SendMessage(11000, "get_location:" + selectedLocation.Latitude.ToString().Replace(",", ".") + "," + selectedLocation.Longitude.ToString().Replace(",", "."));
                    string[] city     = responce.Split(';');
                    City     bingArea = new City()
                    {
                        Name      = city[0],
                        Latitude  = double.Parse(city[1]),
                        Longitude = double.Parse(city[2])
                    };

                    OptionalParameters optionalParameters = new OptionalParameters()
                    {
                        MeasurementUnits    = "si",
                        DataBlocksToExclude = new List <ExclusionBlock>()
                        {
                            ExclusionBlock.Minutely
                        }
                    };
                    weatherListDaily.Clear();
                    weatherListHourly.Clear();
                    ProgressBarWindow progressBar = new ProgressBarWindow();
                    progressBar.Show();
                    progressBar.progress.Minimum = 0;
                    progressBar.progress.Maximum = (endDate - startDate).Days;
                    for (DateTime i = startDate; i <= endDate; i = i.AddDays(1))
                    {
                        progressBar.progress.Value++;
                        optionalParameters.ForecastDateTime = i;
                        res = await weather.darkSky.GetForecast(selectedLocation.Latitude, selectedLocation.Longitude, optionalParameters);

                        forecast = res.Response;
                        if (forecast.Daily != null || forecast.Hourly != null)
                        {
                            if (forecast.Daily.Data != null)
                            {
                                weatherListDaily.AddRange(weather.GetWindSpeed(forecast.Daily.Data, bingArea));
                            }
                            if (forecast.Hourly.Data != null)
                            {
                                weatherListHourly.AddRange(weather.GetWindSpeed(forecast.Hourly.Data, bingArea));
                            }
                        }
                    }
                    if (weatherListHourly.Count > 0)
                    {
                        ExtrapolateWeatherListForMissingDates();
                    }
                    progressBar.Close();
                    GetChartWindow();
                }
            }
            else
            {
                GetChartWindow();
            }
        }