Exemplo n.º 1
0
        public override void Initialize(OptimusMiniSettingsList currentSettings)
        {
            _Bitmap = new Bitmap(96, 96, PixelFormat.Format16bppRgb565);
              _Graphic = Graphics.FromImage(_Bitmap);
              _Data = new WeatherData();
              _DataProvider = new WeatherDataProvider();

              _TitleFont = new Font("Tahoma", 12f, FontStyle.Bold, GraphicsUnit.Pixel);
              _SmallFont = SystemFonts.DefaultFont;

              _DisplayType = -1;

              if (currentSettings["ShowToday"] == "") { _ShowToday = true; }
            else { _ShowToday = (currentSettings["ShowToday"] == "1"); }
              if (currentSettings["ShowTomorrow"] == "") { _ShowTomorrow = true; }
            else { _ShowTomorrow = (currentSettings["ShowTomorrow"] == "1"); }
              if (currentSettings["ShowDayAfterTomorrow"] == "") { _ShowDayAfterTomorrow = true; }
            else { _ShowDayAfterTomorrow = (currentSettings["ShowDayAfterTomorrow"] == "1"); }
              if (currentSettings["ShowWeekend"] == "") { _ShowWeekend = true; }
            else { _ShowWeekend = (currentSettings["ShowWeekend"] == "1"); }

              if (currentSettings["Wait"] != "") { _Wait = int.Parse(currentSettings["Wait"]); } else { _Wait = 30; }
              _LocationCode = currentSettings["LocationCode"];
              _Unit = currentSettings["Unit"];
              if (_Unit == "") { _Unit = "m"; }
              if (_Unit == "m") { _UnitSign = "°"; } else { _UnitSign = "°F"; }

              RequestNextUpdate(new TimeSpan(0, 0, 3)); // Slight delay to display logo once
        }
Exemplo n.º 2
0
        public void Update(WeatherData instance, string locationCode, string unit)
        {
            if (locationCode == "") { return; }
              if (DateTime.Now.Subtract(_LastUpdate).TotalMinutes <= 120) { return; }

              XmlDocument lXml = GetXml(locationCode, unit);

              // ----- Get local time of location
              string lLocalTimeValue = lXml.DocumentElement.SelectSingleNode("loc/tm").InnerText;
              DateTime lLocalTime;
              lLocalTime = DateTime.Parse(lLocalTimeValue, System.Globalization.CultureInfo.GetCultureInfo("en-US").DateTimeFormat);

              // ----- Get date the forecasts are based on
              string lBaseDateValue = lXml.DocumentElement.SelectSingleNode("dayf/lsup").InnerText;
              if (lBaseDateValue.IndexOf("AM") >= 0)
              {
            lBaseDateValue = lBaseDateValue.Substring(0, lBaseDateValue.IndexOf("AM") + 2);
              }
              else if (lBaseDateValue.IndexOf("PM") >= 0)
              {
            lBaseDateValue = lBaseDateValue.Substring(0, lBaseDateValue.IndexOf("PM") + 2);
              }

              DateTime lBaseDate;
              lBaseDate = DateTime.Parse(lBaseDateValue, System.Globalization.CultureInfo.GetCultureInfo("en-US").DateTimeFormat);

              // ----- Parse forecasts
              instance.ClearData();
              foreach (XmlElement lChild in lXml.DocumentElement.SelectNodes("dayf/day"))
              {
            int lIndex = int.Parse(lChild.Attributes["d"].Value);
            if (lIndex >= 0 && lIndex <= 9)
            {
              WeatherCondition lData;
              if (lIndex == 0)
              {
            // Starting with 17:00 (local time of location) the night's data is displayed
            lData = ParseDay(lChild, (lLocalTime.Hour >= 17));
              }
              else
              {
            lData = ParseDay(lChild, false);
              }

              lData.Date = lBaseDate.Date.AddDays(lIndex);
              instance.SetData(lData);
            }
              }

              _LastUpdate = DateTime.Now;
        }
Exemplo n.º 3
0
        public override void Initialize(OptimusMiniSettingsList currentSettings)
        {
            _Bitmap       = new Bitmap(96, 96, PixelFormat.Format16bppRgb565);
            _Graphic      = Graphics.FromImage(_Bitmap);
            _Data         = new WeatherData();
            _DataProvider = new WeatherDataProvider();

            _TitleFont = new Font("Tahoma", 12f, FontStyle.Bold, GraphicsUnit.Pixel);
            _SmallFont = SystemFonts.DefaultFont;

            _DisplayType = -1;

            if (currentSettings["ShowToday"] == "")
            {
                _ShowToday = true;
            }
            else
            {
                _ShowToday = (currentSettings["ShowToday"] == "1");
            }
            if (currentSettings["ShowTomorrow"] == "")
            {
                _ShowTomorrow = true;
            }
            else
            {
                _ShowTomorrow = (currentSettings["ShowTomorrow"] == "1");
            }
            if (currentSettings["ShowDayAfterTomorrow"] == "")
            {
                _ShowDayAfterTomorrow = true;
            }
            else
            {
                _ShowDayAfterTomorrow = (currentSettings["ShowDayAfterTomorrow"] == "1");
            }
            if (currentSettings["ShowWeekend"] == "")
            {
                _ShowWeekend = true;
            }
            else
            {
                _ShowWeekend = (currentSettings["ShowWeekend"] == "1");
            }

            if (currentSettings["Wait"] != "")
            {
                _Wait = int.Parse(currentSettings["Wait"]);
            }
            else
            {
                _Wait = 30;
            }
            _LocationCode = currentSettings["LocationCode"];
            _Unit         = currentSettings["Unit"];
            if (_Unit == "")
            {
                _Unit = "m";
            }
            if (_Unit == "m")
            {
                _UnitSign = "°";
            }
            else
            {
                _UnitSign = "°F";
            }

            RequestNextUpdate(new TimeSpan(0, 0, 3)); // Slight delay to display logo once
        }