Example #1
0
 private static void saveConfig(GeoLocation location)
 {
     System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(location.GetType());
     using (var xml = new XmlTextWriter("config", Encoding.UTF8))
     {
         s.Serialize(xml, location);
     }
 }
Example #2
0
        private void linkSetup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            using (SetupForm f = new SetupForm())
            {
                f.CurrentLocation = currentLocation;
                f.ShowDialog();
                currentLocation = f.CurrentLocation;
            }

            renderWeather(Weather.Parse(getWeather(currentLocation)));
        }
Example #3
0
        private XDocument getWeather(GeoLocation currentLocation)
        {
            if (currentLocation == null) return null;

            try
            {
                XDocument xdoc = XDocument.Load(string.Format(WEATHERAPI,
                                                              currentLocation.WOEID,
                                                              currentLocation.Scale.ToString().ToLower()
                                                             )
                                                );

                return xdoc;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Example #4
0
        private void lbLocations_SelectedIndexChanged(object sender, EventArgs e)
        {
            var o = lbLocations.SelectedItem;
            if (o is GeoLocation)
            {
                var location = (GeoLocation)o;
                Debug.WriteLine("Location: " + location.Name + " > WOEID: " + location.WOEID);

                //lblCurrentLocation.Text = location.ToString();
                saveConfig(location);
                CurrentLocation = location;
                cbTempScale.SelectedItem = CurrentLocation.Scale;
                cbTempScale.Visible = true;
                //renderWeather(Weather.Parse(getWeather(currentLocation)));
            }
        }
Example #5
0
        private void loadConfig()
        {
            System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(GeoLocation));
            try
            {
                using (var xml = new XmlTextReader("config"))
                {
                    currentLocation = (GeoLocation)s.Deserialize(xml);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (currentLocation != null)
            {
                lblCurrentLocation.Text = currentLocation.ToString();
            }
        }
Example #6
0
        private void renderTrayWeather(Weather weather, GeoLocation currentLocation)
        {
            notifyIconWeather.Text = weather.GetTemperature() + " - " + currentLocation.Name;
            notifyIconWeather.BalloonTipText = weather.ToString();
            notifyIconWeather.BalloonTipTitle = "Weather";

            notifyIconWeather.Icon = renderIcon(weather.Temperature);
        }