void ReleaseDesignerOutlets()
        {
            if (DescriptionText != null)
            {
                DescriptionText.Dispose();
                DescriptionText = null;
            }

            if (ForecastsTableView != null)
            {
                ForecastsTableView.Dispose();
                ForecastsTableView = null;
            }

            if (IconImage != null)
            {
                IconImage.Dispose();
                IconImage = null;
            }

            if (LocationText != null)
            {
                LocationText.Dispose();
                LocationText = null;
            }

            if (TempText != null)
            {
                TempText.Dispose();
                TempText = null;
            }
        }
Ejemplo n.º 2
0
 private void LocationText_Enter(object sender, EventArgs e)
 {
     BeginInvoke((Action) delegate
     {
         LocationText.SelectAll();
     });
 }
Ejemplo n.º 3
0
        //the button to click once your location is entered!
        private void GoGet_Click(object sender, RoutedEventArgs e)
        {
            String location = LocationText.GetLineText(0);

            MyLocationMain.Text = (LocationText.GetLineText(0));


            // Get the weather information from the API
            string         url     = $"https://api.openweathermap.org/data/2.5/weather?q={Uri.EscapeDataString(location)}&appid={APIKEY}";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            // Process the weather information
                            string json = reader.ReadToEnd();

                            var jss  = new JavaScriptSerializer();
                            var dict = jss.Deserialize <Dictionary <string, dynamic> >(json);

                            // Print out the current weather conditions
                            ConditionsInfo.Text  = ($"Conditions:  {dict["weather"][0]["main"]}");
                            TemperatureInfo.Text = ($"Temperature: {Math.Round(Convert.ToDouble(dict["main"]["temp"]) - 273.15)}°C");
                            HumidityInfo.Text    = ($"Humidity:    {dict["main"]["humidity"]}%");
                            PressureInfo.Text    = ($"Pressure:    {dict["main"]["pressure"]} hpa");
                            VisibilityInfo.Text  = ($"Visibility:  {Convert.ToInt16(dict["visibility"]) / 1000}km");
                            WindInfo.Text        = ($"Wind:        {dict["wind"]["speed"]} m/s {DegreesToDirection(Convert.ToInt16(dict["wind"]["deg"]))}");
                        }
            }
            catch (Exception error)
            {
                // Oops... there was an error. Display the problem to the user
                Console.WriteLine("Unable to retrieve data:");
                Console.WriteLine(error.Message);
            }
        }
Ejemplo n.º 4
0
        void ReleaseDesignerOutlets()
        {
            if (LocationText != null)
            {
                LocationText.Dispose();
                LocationText = null;
            }

            if (PhotoImageView != null)
            {
                PhotoImageView.Dispose();
                PhotoImageView = null;
            }

            if (ShareAppnet != null)
            {
                ShareAppnet.Dispose();
                ShareAppnet = null;
            }

            if (ShareFacebook != null)
            {
                ShareFacebook.Dispose();
                ShareFacebook = null;
            }

            if (ShareFlickr != null)
            {
                ShareFlickr.Dispose();
                ShareFlickr = null;
            }

            if (ShareTwitter != null)
            {
                ShareTwitter.Dispose();
                ShareTwitter = null;
            }
        }