Ejemplo n.º 1
0
        private void UpdateNightImage()
        {
            SolarData day1Data = (yesterdaysData == null) ? todaysData : yesterdaysData;
            SolarData day2Data = (yesterdaysData == null) ? tomorrowsData : todaysData;

            TimeSpan nightTime = day2Data.SunriseTime - day1Data.SunsetTime;

            if (ThemeManager.currentTheme != null)
            {
                TimeSpan timerLength = new TimeSpan(nightTime.Ticks / nightImages.Length);
                int      imageNumber = GetImageNumber(day1Data.SunsetTime, timerLength);

                if (imageNumber >= nightImages.Length)
                {
                    UpdateDayImage();
                    return;
                }

                StartTimer(day1Data.SunsetTime.Ticks + timerLength.Ticks * (imageNumber + 1)
                           - DateTime.Now.Ticks, timerLength);

                if (nightImages[imageNumber] != lastImageId)
                {
                    SetWallpaper(nightImages[imageNumber]);
                }
            }
            else
            {
                StartTimer(day2Data.SunriseTime.Ticks - DateTime.Now.Ticks, nightTime);
            }
        }
Ejemplo n.º 2
0
        private SolarData GetSolarData(DateTime date)
        {
            SolarData data = SunriseSunsetService.GetSolarData(
                JsonConfig.settings.latitude, JsonConfig.settings.longitude, date);

            return(data);
        }
Ejemplo n.º 3
0
 private static DaySegment GetDaySegment(SolarData data, DateTimeTZ time)
 {
     if (data.polarPeriod == PolarPeriod.PolarDay)
     {
         return(DaySegment.AllDay);
     }
     else if (data.polarPeriod == PolarPeriod.PolarNight)
     {
         return(DaySegment.AllNight);
     }
     else if (data.solarTimes[0].Time <= time.Time && time.Time < data.solarTimes[1].Time)
     {
         return(DaySegment.Sunrise);
     }
     else if (data.solarTimes[1].Time <= time.Time && time.Time < data.solarTimes[2].Time)
     {
         return(DaySegment.Day);
     }
     else if (data.solarTimes[2].Time <= time.Time && time.Time < data.solarTimes[3].Time)
     {
         return(DaySegment.Sunset);
     }
     else
     {
         return(DaySegment.Night);
     }
 }
Ejemplo n.º 4
0
 private DaySegment GetCurrentDaySegment(SolarData data)
 {
     if (data.polarPeriod == PolarPeriod.PolarDay)
     {
         return(DaySegment.AllDay);
     }
     else if (data.polarPeriod == PolarPeriod.PolarNight)
     {
         return(DaySegment.AllNight);
     }
     else if (data.solarTimes[0] <= DateTime.Now && DateTime.Now < data.solarTimes[1])
     {
         return(DaySegment.Sunrise);
     }
     else if (data.solarTimes[1] <= DateTime.Now && DateTime.Now < data.solarTimes[2])
     {
         return(DaySegment.Day);
     }
     else if (data.solarTimes[2] <= DateTime.Now && DateTime.Now < data.solarTimes[3])
     {
         return(DaySegment.Sunset);
     }
     else
     {
         return(DaySegment.Night);
     }
 }
        private void imageListView1_SelectionChanged(object sender, EventArgs e)
        {
            if (imageListView1.SelectedItems.Count > 0)
            {
                selectedIndex = imageListView1.SelectedItems[0].Index;
                int imageNumber = 1;

                if (selectedIndex > 0)
                {
                    string themeId = (string)imageListView1.Items[selectedIndex].Tag;
                    selectedIndex = ThemeManager.themeSettings.FindIndex(
                        t => t.themeId == themeId) + 1;

                    SolarData   solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                    ThemeConfig theme     = ThemeManager.themeSettings[selectedIndex - 1];
                    imageNumber = GetImageList(theme).IndexOf(
                        AppContext.wpEngine.GetImageData(solarData, theme,
                                                         darkModeCheckbox.Checked).Item1) + 1;
                }

                creditsLabel.Text = GetCreditsText();
                maxImageNumber    = GetMaxImageNumber();
                LoadPreviewImage(imageNumber);

                applyButton.Enabled = true;
            }
            else
            {
                applyButton.Enabled = false;
            }
        }
Ejemplo n.º 6
0
        public void RunScheduler(bool forceImageUpdate = false)
        {
            if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady())
            {
                return;
            }

            schedulerTimer.Stop();

            SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today);

            isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime);
            DateTime?nextImageUpdateTime = null;

            if (ThemeManager.currentTheme != null)
            {
                if (forceImageUpdate)
                {
                    lastImagePath = null;
                }

                WallpaperShuffler.MaybeShuffleWallpaper();
                SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme);
                SetWallpaper(imageData.imageId);
                nextImageUpdateTime = new DateTime(imageData.nextUpdateTicks);
            }

            SystemThemeChanger.TryUpdateSystemTheme();

            if (data.polarPeriod != PolarPeriod.None)
            {
                nextUpdateTime = DateTime.Today.AddDays(1);
            }
            else if (isSunUp)
            {
                nextUpdateTime = data.sunsetTime;
            }
            else if (DateTime.Now < data.solarTimes[0])
            {
                nextUpdateTime = data.sunriseTime;
            }
            else
            {
                SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                    DateTime.Today.AddDays(1));
                nextUpdateTime = tomorrowsData.sunriseTime;
            }

            if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value)
            {
                nextUpdateTime = nextImageUpdateTime;
            }

            StartTimer(nextUpdateTime.Value);
        }
        private async void okButton_Click(object sender, EventArgs e)
        {
            okButton.Enabled = false;

            if (!locationCheckBox.Checked)
            {
                LocationIQData data = LocationIQService.GetLocationData(inputBox.Text);

                if (data != null)
                {
                    JsonConfig.settings.location  = inputBox.Text;
                    JsonConfig.settings.latitude  = data.lat;
                    JsonConfig.settings.longitude = data.lon;
                    SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);

                    DialogResult result = MessageBox.Show(string.Format(_("Is this location " +
                                                                          "correct?\n\n{0}\nSunrise: {1}, Sunset: {2}"), data.display_name,
                                                                        solarData.sunriseTime.ToShortTimeString(),
                                                                        solarData.sunsetTime.ToShortTimeString()), _("Question"),
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        AppContext.wpEngine.RunScheduler();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(_("The location you entered was invalid, or you are not " +
                                      "connected to the Internet. Check your Internet connection and try a " +
                                      "different location. You can use a complete address or just the name of " +
                                      "your city/region."), _("Error"), MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
            else
            {
                bool locationUpdated = await UwpLocation.UpdateGeoposition();

                if (locationUpdated)
                {
                    AppContext.wpEngine.RunScheduler();
                    this.Close();
                }
                else
                {
                    MessageBox.Show(_("Failed to get location from Windows location service."),
                                    _("Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            okButton.Enabled = true;
        }
Ejemplo n.º 8
0
        public static SolarData GetSolarData(DateTime date)
        {
            if (JsonConfig.settings.dontUseLocation)
            {
                return(GetUserProvidedSolarData(date));
            }

            double    latitude  = double.Parse(JsonConfig.settings.latitude, CultureInfo.InvariantCulture);
            double    longitude = double.Parse(JsonConfig.settings.longitude, CultureInfo.InvariantCulture);
            var       sunPhases = GetSunPhases(date, latitude, longitude);
            SolarData data      = new SolarData();

            data.sunriseTime = GetSolarTime(sunPhases, SunPhaseName.Sunrise);
            data.sunsetTime  = GetSolarTime(sunPhases, SunPhaseName.Sunset);
            data.solarTimes  = new DateTime[4]
            {
                GetSolarTime(sunPhases, SunPhaseName.Dawn),
                GetSolarTime(sunPhases, SunPhaseName.GoldenHourEnd),
                GetSolarTime(sunPhases, SunPhaseName.GoldenHour),
                GetSolarTime(sunPhases, SunPhaseName.Dusk)
            };

            // Assume polar day/night if sunrise/sunset time are undefined
            if (data.sunriseTime == DateTime.MinValue || data.sunsetTime == DateTime.MinValue)
            {
                DateTime solarNoon   = GetSolarTime(sunPhases, SunPhaseName.SolarNoon);
                double   sunAltitude = SunCalcNet.SunCalc.GetSunPosition(solarNoon.ToUniversalTime(), latitude,
                                                                         longitude).Altitude;

                if (sunAltitude > 0)
                {
                    data.polarPeriod = PolarPeriod.PolarDay;
                }
                else
                {
                    data.polarPeriod = PolarPeriod.PolarNight;
                }
            }
            // Skip night segment if dawn/dusk are undefined
            else if (data.solarTimes[0] == DateTime.MinValue && data.solarTimes[3] == DateTime.MinValue)
            {
                data.solarTimes[0] = data.sunriseTime.Date;
                data.solarTimes[3] = data.sunsetTime.Date.AddDays(1).AddTicks(-1);
            }
            // Skip day segment if golden hour (end) are undefined
            else if (data.solarTimes[1] == DateTime.MinValue && data.solarTimes[2] == DateTime.MinValue)
            {
                DateTime midDay = new DateTime((data.solarTimes[0].Ticks + data.solarTimes[3].Ticks) / 2);
                data.solarTimes[1] = midDay;
                data.solarTimes[2] = midDay;
            }

            return(data);
        }
Ejemplo n.º 9
0
        public void RunScheduler(bool forceImageUpdate = false)
        {
            if (!LaunchSequence.IsLocationReady() || !ThemeManager.filesVerified)
            {
                return;
            }

            schedulerTimer.Stop();

            SolarData data = SunriseSunsetService.GetSolarData(DateTime.Today);

            isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime);
            DateTime?nextImageUpdateTime = null;

            if (ThemeManager.currentTheme != null)
            {
                if (forceImageUpdate)
                {
                    lastImagePath = null;
                }

                Tuple <int, long> imageData = GetImageData(data, ThemeManager.currentTheme,
                                                           JsonConfig.settings.darkMode);
                SetWallpaper(imageData.Item1);
                nextImageUpdateTime = new DateTime(imageData.Item2);
            }

            SystemThemeChanger.TryUpdateSystemTheme();

            if (isSunUp)
            {
                nextUpdateTime = data.sunsetTime;
            }
            else if (DateTime.Now < data.solarTimes[0])
            {
                nextUpdateTime = data.sunriseTime;
            }
            else
            {
                SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                    DateTime.Today.AddDays(1));
                nextUpdateTime = tomorrowsData.sunriseTime;
            }

            if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value)
            {
                nextUpdateTime = nextImageUpdateTime;
            }

            StartTimer(nextUpdateTime.Value);
        }
Ejemplo n.º 10
0
        public static SolarData GetSolarData(string lat, string lon, DateTime date)
        {
            double latitude  = double.Parse(lat, CultureInfo.InvariantCulture);
            double longitude = double.Parse(lon, CultureInfo.InvariantCulture);

            SolarTimes solarTimes = new SolarTimes(date, latitude, longitude);

            SolarData data = new SolarData();

            data.SunriseTime = solarTimes.Sunrise;
            data.SunsetTime  = solarTimes.Sunset;

            return(data);
        }
Ejemplo n.º 11
0
        private static void HandleLocationSuccess(LocationIQData data, ScheduleDialog dialog)
        {
            JsonConfig.settings.latitude  = data.lat;
            JsonConfig.settings.longitude = data.lon;
            SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);

            DialogResult result = MessageDialog.ShowQuestion(string.Format(_("Is this location correct?\n\n{0}\n{1}"),
                                                                           data.display_name, SunriseSunsetService.GetSunriseSunsetString(solarData)), _("Question"), true);

            if (result == DialogResult.Yes)
            {
                dialog.Invoke(new Action(() => dialog.HandleScheduleChange()));
            }
        }
Ejemplo n.º 12
0
        public static string GeneratePreviewHtml(ThemeConfig theme)
        {
            string htmlText = Properties.Resources.preview_html;
            Dictionary <string, string> replacers = new Dictionary <string, string>();

            replacers.Add("basePath", new Uri(Environment.CurrentDirectory).AbsoluteUri);

            if (theme != null)
            {
                replacers.Add("themeName", ThemeManager.GetThemeName(theme));
                replacers.Add("themeAuthor", ThemeManager.GetThemeAuthor(theme));
                replacers.Add("previewMessage", string.Format(_("Previewing {0}"), "<span id=\"previewText\"></span>"));

                SolarData      solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                SchedulerState wpState   = AppContext.wpEngine.GetImageData(solarData, theme);

                if (ThemeManager.IsThemeDownloaded(theme))
                {
                    // TODO Why are images flickering?
                    ThemeImageData imageData   = GetThemeImageData(theme);
                    int            activeImage = imageData.FindIndex(entry => entry.Item2 == wpState.daySegment4) +
                                                 wpState.imageNumber;

                    replacers.Add("downloadMessage", "");
                    replacers.Add("carouselIndicators", GetCarouselIndicators(imageData.Count, activeImage));
                    replacers.Add("carouselItems", GetCarouselItems(imageData, activeImage, theme));
                }
                else
                {
                    replacers.Add("downloadMessage", string.Format("<div id=\"bottomCenterPanel\">{0}</div>",
                                                                   _("Theme is not downloaded. Click Download button to enable full preview.")));
                    replacers.Add("carouselIndicators", "");
                    replacers.Add("carouselItems", GetCarouselItems(wpState, theme));
                }
            }
            else
            {
                replacers.Add("themeAuthor", "Microsoft");

                int    startCarouselIndex = htmlText.IndexOf("<!--");
                int    endCarouselIndex   = htmlText.LastIndexOf("-->") + 3;
                string imageTag           = string.Format("<img src=\"{0}\">",
                                                          (new Uri(ThemeThumbLoader.GetWindowsWallpaper())).AbsoluteUri);

                htmlText = htmlText.Substring(0, startCarouselIndex) + imageTag +
                           htmlText.Substring(endCarouselIndex + 1);
            }

            return(RenderTemplate(htmlText, replacers));
        }
Ejemplo n.º 13
0
        public static string GetSunriseSunsetString(SolarData solarData)
        {
            switch (solarData.polarPeriod)
            {
            case PolarPeriod.PolarDay:
                return(_("Sunrise/Sunset: Up all day"));

            case PolarPeriod.PolarNight:
                return(_("Sunrise/Sunset: Down all day"));

            default:
                return(string.Format(_("Sunrise: {0}, Sunset: {1}"), solarData.sunriseTime.ToShortTimeString(),
                                     solarData.sunsetTime.ToShortTimeString()));
            }
        }
Ejemplo n.º 14
0
        public void RunScheduler()
        {
            if (ThemeManager.currentTheme == null)
            {
                return;
            }

            wallpaperTimer.Stop();

            DateTime today = DateTime.Today;

            todaysData = GetSolarData(today);

            if (DateTime.Now < todaysData.SunriseTime + timerError)
            {
                // Before sunrise
                yesterdaysData = GetSolarData(today.AddDays(-1));
                tomorrowsData  = null;
            }
            else if (DateTime.Now >= todaysData.SunsetTime - timerError)
            {
                // After sunset
                yesterdaysData = null;
                tomorrowsData  = GetSolarData(today.AddDays(1));
            }
            else
            {
                // Between sunrise and sunset
                yesterdaysData = null;
                tomorrowsData  = null;
            }

            isDayNow    = (yesterdaysData == null && tomorrowsData == null);
            lastImageId = -1;

            if (isDayNow)
            {
                UpdateDayImage();
            }
            else
            {
                UpdateNightImage();
            }

            SystemThemeChanger.TryUpdateSystemTheme();
            JsonConfig.SaveConfig();
        }
Ejemplo n.º 15
0
        private static SolarData GetUserProvidedSolarData()
        {
            SolarData data = new SolarData();

            data.sunriseTime = DateTime.Parse(JsonConfig.settings.sunriseTime);
            data.sunsetTime  = DateTime.Parse(JsonConfig.settings.sunsetTime);
            int halfSunriseSunsetDuration = JsonConfig.settings.sunriseSunsetDuration * 30;

            data.solarTimes = new DateTime[4]
            {
                data.sunriseTime.AddSeconds(-halfSunriseSunsetDuration),
                data.sunriseTime.AddSeconds(halfSunriseSunsetDuration),
                data.sunsetTime.AddSeconds(-halfSunriseSunsetDuration),
                data.sunsetTime.AddSeconds(halfSunriseSunsetDuration)
            };
            return(data);
        }
Ejemplo n.º 16
0
        private void UpdateSelectedItem()
        {
            if (imageListView1.SelectedItems.Count > 0)
            {
                selectedIndex = imageListView1.SelectedItems[0].Index;
                int  imageNumber     = 1;
                bool themeDownloaded = true;

                if (selectedIndex > 0)
                {
                    string themeId = (string)imageListView1.Items[selectedIndex].Tag;
                    selectedIndex = ThemeManager.themeSettings.FindIndex(
                        t => t.themeId == themeId) + 1;
                    ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1];
                    themeDownloaded = ThemeManager.IsThemeDownloaded(theme);

                    if (themeDownloaded)
                    {
                        SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                        imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf(
                            AppContext.wpEngine.GetImageData(solarData, theme).Item1) + 1;
                    }
                    else
                    {
                        LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject(
                                             themeId + "_thumbnail"));
                    }
                }

                SetThemeDownloaded(themeDownloaded);
                creditsLabel.Text = GetCreditsText(themeDownloaded);

                if (themeDownloaded)
                {
                    maxImageNumber = GetMaxImageNumber();
                    LoadPreviewImage(imageNumber);
                }

                applyButton.Enabled = true;
            }
            else
            {
                applyButton.Enabled = false;
            }
        }
Ejemplo n.º 17
0
        public static SolarData GetSolarData(DateTime date)
        {
            if (JsonConfig.settings.dontUseLocation)
            {
                return(GetUserProvidedSolarData());
            }

            double latitude = double.Parse(JsonConfig.settings.latitude,
                                           CultureInfo.InvariantCulture);
            double longitude = double.Parse(JsonConfig.settings.longitude,
                                            CultureInfo.InvariantCulture);
            var       sunPhases = GetSunPhases(date, latitude, longitude);
            SolarData data      = new SolarData();

            try
            {
                data.sunriseTime = GetSolarTime(sunPhases, SunPhaseName.Sunrise);
                data.sunsetTime  = GetSolarTime(sunPhases, SunPhaseName.Sunset);
                data.solarTimes  = new DateTime[4]
                {
                    GetSolarTime(sunPhases, SunPhaseName.Dawn),
                    GetSolarTime(sunPhases, SunPhaseName.GoldenHourEnd),
                    GetSolarTime(sunPhases, SunPhaseName.GoldenHour),
                    GetSolarTime(sunPhases, SunPhaseName.Dusk)
                };
            }
            catch (InvalidOperationException)  // Handle polar day/night
            {
                DateTime solarNoon   = GetSolarTime(sunPhases, SunPhaseName.SolarNoon);
                double   sunAltitude = SunCalcNet.SunCalc.GetSunPosition(solarNoon.ToUniversalTime(),
                                                                         latitude, longitude).Altitude;

                if (sunAltitude > 0)
                {
                    data.polarPeriod = PolarPeriod.PolarDay;
                }
                else
                {
                    data.polarPeriod = PolarPeriod.PolarNight;
                }
            }

            return(data);
        }
Ejemplo n.º 18
0
        private void UpdateSelectedItem()
        {
            if (imageListView1.SelectedItems.Count > 0)
            {
                selectedIndex = imageListView1.SelectedItems[0].Index;
                int  imageNumber     = 1;
                bool themeDownloaded = true;

                if (selectedIndex > 0)
                {
                    string themeId = (string)imageListView1.Items[selectedIndex].Tag;
                    selectedIndex = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId) + 1;
                    ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1];
                    nameLabel.Text  = ThemeManager.GetThemeName(theme);
                    themeDownloaded = ThemeManager.IsThemeDownloaded(theme);

                    if (themeDownloaded)
                    {
                        SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);
                        imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf(
                            AppContext.wpEngine.GetImageData(solarData, theme).imageId) + 1;
                        LoadPreviewImage(imageNumber);
                    }
                    else
                    {
                        LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject(themeId + "_thumbnail"));
                    }
                }
                else
                {
                    nameLabel.Text = _("Windows Default");
                    LoadPreviewImage(new Bitmap(windowsWallpaper));
                }

                creditsLabel.Text        = GetCreditsText();
                downloadLabel.Visible    = selectedIndex > 0 && !themeDownloaded;
                previewLinkLabel.Visible = selectedIndex > 0 && themeDownloaded;
                applyButton.Enabled      = true;
            }
            else
            {
                applyButton.Enabled = false;
            }
        }
Ejemplo n.º 19
0
        public static SolarData GetSolarData(DateTime date)
        {
            var sunPhases = GetSunPhases(date.AddHours(12).ToUniversalTime(),
                                         JsonConfig.settings.latitude, JsonConfig.settings.longitude);

            SolarData data = new SolarData
            {
                sunriseTime = sunPhases[SunPhaseName.Sunrise.Value].ToLocalTime(),
                sunsetTime  = sunPhases[SunPhaseName.Sunset.Value].ToLocalTime(),
                solarTimes  = new DateTime[4]
            };

            data.solarTimes[0] = sunPhases[SunPhaseName.NauticalDawn.Value].ToLocalTime();
            data.solarTimes[1] = sunPhases[SunPhaseName.GoldenHourEnd.Value].ToLocalTime();
            data.solarTimes[2] = sunPhases[SunPhaseName.GoldenHour.Value].ToLocalTime();
            data.solarTimes[3] = sunPhases[SunPhaseName.NauticalDusk.Value].ToLocalTime();

            return(data);
        }
Ejemplo n.º 20
0
        private static SolarData GetUserProvidedSolarData(DateTime date)
        {
            SolarData data = new SolarData();

            data.sunriseTime = date.Date + UpdateHandler.SafeParse(JsonConfig.settings.sunriseTime).TimeOfDay;
            data.sunsetTime  = date.Date + UpdateHandler.SafeParse(JsonConfig.settings.sunsetTime).TimeOfDay;

            int halfSunriseSunsetDuration = JsonConfig.settings.sunriseSunsetDuration * 30;

            data.solarTimes = new DateTime[4]
            {
                data.sunriseTime.AddSeconds(-halfSunriseSunsetDuration),
                data.sunriseTime.AddSeconds(halfSunriseSunsetDuration),
                data.sunsetTime.AddSeconds(-halfSunriseSunsetDuration),
                data.sunsetTime.AddSeconds(halfSunriseSunsetDuration)
            };

            return(data);
        }
Ejemplo n.º 21
0
        public static string GetSunriseSunsetString(SolarData solarData)
        {
            switch (solarData.polarPeriod)
            {
            case PolarPeriod.PolarDay:
                JsonConfig.settings.IsPolarAllDay = true;
                return(_("Sunrise/Sunset: Up all day"));

            case PolarPeriod.PolarNight:
                JsonConfig.settings.IsPolarAllNight = true;
                return(_("Sunrise/Sunset: Down all day"));

            default:
                JsonConfig.settings.IsPolarAllDay   = false;
                JsonConfig.settings.IsPolarAllNight = false;
                return(string.Format(_("Sunrise: {0}, Sunset: {1}"),
                                     solarData.sunriseTime.ToShortTimeString(),
                                     solarData.sunsetTime.ToShortTimeString()));
            }
        }
Ejemplo n.º 22
0
        public void RunScheduler(bool forceImageUpdate = false)
        {
            if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady())
            {
                return;
            }

            schedulerTimer.Stop();
            DateTimeTZ DateTimeToday = DateTimeTZ.UTC.Today.ConvertTime(JsonConfig.settings.timezone);
            SolarData  data          = SunriseSunsetService.GetSolarData(DateTimeToday);
            DateTimeTZ DateTimeNow   = DateTimeTZ.UTC.Now.ConvertTime(JsonConfig.settings.timezone);

            isSunUp = (data.sunriseTime.Time <= DateTimeNow.Time && DateTimeNow.Time < data.sunsetTime.Time);

            DateTime?nextImageUpdateTime = null;

            if (ThemeManager.currentTheme != null)
            {
                if (forceImageUpdate)
                {
                    lastImagePath = null;
                }

                WallpaperShuffler.MaybeShuffleWallpaper();
            }

            SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme, DateTimeNow);

            if (ThemeManager.currentTheme != null)
            {
                SetWallpaper(imageData.imageId);
                nextImageUpdateTime = new DateTimeTZ(JsonConfig.settings.timezone, new DateTime(imageData.nextUpdateTicks)).Time;
            }

            ScriptManager.RunScripts(new ScriptArgs
            {
                daySegment2 = imageData.daySegment2,
                daySegment4 = imageData.daySegment4,
                imagePath   = (ThemeManager.currentTheme != null) ? lastImagePath : null
            });

            if (data.polarPeriod != PolarPeriod.None)
            {
                nextUpdateTime = DateTimeToday.AddDays(1).Time;
            }
            else if (isSunUp)
            {
                nextUpdateTime = data.sunsetTime.Time;
            }
            else if (DateTimeNow.Time < data.solarTimes[0].Time)
            {
                nextUpdateTime = data.sunriseTime.Time;
            }
            else
            {
                SolarData tomorrowsData = SunriseSunsetService.GetSolarData(DateTimeToday.AddDays(1));
                nextUpdateTime = tomorrowsData.sunriseTime.Time;
            }

            if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value)
            {
                nextUpdateTime = nextImageUpdateTime;
            }

            StartTimer(nextUpdateTime.Value);
        }
Ejemplo n.º 23
0
        public Tuple <int, long> GetImageData(SolarData data, ThemeConfig theme)
        {
            int[]    imageList;
            DateTime segmentStart;
            DateTime segmentEnd;

            if (!JsonConfig.settings.darkMode)
            {
                switch (GetCurrentDaySegment(data))
                {
                case DaySegment.AllDay:
                    imageList    = theme.dayImageList;
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                    break;

                case DaySegment.AllNight:
                    imageList    = theme.nightImageList;
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                    break;

                case DaySegment.Sunrise:
                    imageList    = theme.sunriseImageList;
                    segmentStart = data.solarTimes[0];
                    segmentEnd   = data.solarTimes[1];
                    break;

                case DaySegment.Day:
                    imageList    = theme.dayImageList;
                    segmentStart = data.solarTimes[1];
                    segmentEnd   = data.solarTimes[2];
                    break;

                case DaySegment.Sunset:
                    imageList    = theme.sunsetImageList;
                    segmentStart = data.solarTimes[2];
                    segmentEnd   = data.solarTimes[3];
                    break;

                default:
                    imageList = theme.nightImageList;

                    if (DateTime.Now < data.solarTimes[0])
                    {
                        SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(-1));
                        segmentStart = yesterdaysData.solarTimes[3];
                        segmentEnd   = data.solarTimes[0];
                    }
                    else
                    {
                        segmentStart = data.solarTimes[3];
                        SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(1));
                        segmentEnd = tomorrowsData.solarTimes[0];
                    }

                    break;
                }
            }
            else
            {
                imageList = theme.nightImageList;

                if (data.polarPeriod != PolarPeriod.None)
                {
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                }
                else if (isSunUp)
                {
                    segmentStart = data.sunriseTime;
                    segmentEnd   = data.sunsetTime;
                }
                else if (DateTime.Now < data.sunriseTime)
                {
                    SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(-1));
                    segmentStart = yesterdaysData.sunsetTime;
                    segmentEnd   = data.sunriseTime;
                }
                else
                {
                    segmentStart = data.sunsetTime;
                    SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(1));
                    segmentEnd = tomorrowsData.sunriseTime;
                }
            }

            TimeSpan segmentLength = segmentEnd - segmentStart;
            TimeSpan timerLength   = new TimeSpan(segmentLength.Ticks / imageList.Length);

            int  imageNumber     = (int)((DateTime.Now - segmentStart).Ticks / timerLength.Ticks);
            long nextUpdateTicks = segmentStart.Ticks + timerLength.Ticks * (imageNumber + 1);

            return(new Tuple <int, long>(imageList[imageNumber], nextUpdateTicks));
        }
Ejemplo n.º 24
0
        private DateTime UpdateImage(SolarData data, DaySegment segment)
        {
            int[]    imageList;
            DateTime segmentStart;
            DateTime segmentEnd;

            if (!JsonConfig.settings.darkMode)
            {
                switch (segment)
                {
                case DaySegment.Sunrise:
                    imageList    = ThemeManager.currentTheme.sunriseImageList;
                    segmentStart = data.solarTimes[0];
                    segmentEnd   = data.solarTimes[1];
                    break;

                case DaySegment.Day:
                    imageList    = ThemeManager.currentTheme.dayImageList;
                    segmentStart = data.solarTimes[1];
                    segmentEnd   = data.solarTimes[2];
                    break;

                case DaySegment.Sunset:
                    imageList    = ThemeManager.currentTheme.sunsetImageList;
                    segmentStart = data.solarTimes[2];
                    segmentEnd   = data.solarTimes[3];
                    break;

                default:
                    imageList = ThemeManager.currentTheme.nightImageList;

                    if (DateTime.Now < data.solarTimes[0])
                    {
                        SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(-1));
                        segmentStart = yesterdaysData.solarTimes[3];
                        segmentEnd   = data.solarTimes[0];
                    }
                    else
                    {
                        segmentStart = data.solarTimes[3];
                        SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(1));
                        segmentEnd = tomorrowsData.solarTimes[0];
                    }

                    break;
                }
            }
            else
            {
                imageList = ThemeManager.currentTheme.nightImageList;

                if (isSunUp)
                {
                    segmentStart = data.sunriseTime;
                    segmentEnd   = data.sunsetTime;
                }
                else if (DateTime.Now < data.sunriseTime)
                {
                    SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(-1));
                    segmentStart = yesterdaysData.sunsetTime;
                    segmentEnd   = data.sunriseTime;
                }
                else
                {
                    segmentStart = data.sunsetTime;
                    SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(1));
                    segmentEnd = tomorrowsData.sunriseTime;
                }
            }

            TimeSpan segmentLength = segmentEnd - segmentStart;
            TimeSpan timerLength   = new TimeSpan(segmentLength.Ticks / imageList.Length);

            int  imageNumber     = GetImageNumber(segmentStart, timerLength);
            long nextUpdateTicks = segmentStart.Ticks + timerLength.Ticks * (imageNumber + 1);

            SetWallpaper(imageList[imageNumber]);

            return(new DateTime(nextUpdateTicks));
        }
Ejemplo n.º 25
0
        public void RunScheduler(bool forceImageUpdate = false)
        {
            schedulerTimer.Stop();

            SolarData  data = SunriseSunsetService.GetSolarData(DateTime.Today);
            DaySegment currentSegment;

            if (data.solarTimes[0] <= DateTime.Now && DateTime.Now < data.solarTimes[1])
            {
                currentSegment = DaySegment.Sunrise;
            }
            else if (data.solarTimes[1] <= DateTime.Now && DateTime.Now < data.solarTimes[2])
            {
                currentSegment = DaySegment.Day;
            }
            else if (data.solarTimes[2] <= DateTime.Now && DateTime.Now < data.solarTimes[3])
            {
                currentSegment = DaySegment.Sunset;
            }
            else
            {
                currentSegment = DaySegment.Night;
            }

            isSunUp = (data.sunriseTime <= DateTime.Now && DateTime.Now < data.sunsetTime);
            DateTime?nextImageUpdateTime = null;

            if (ThemeManager.currentTheme != null)
            {
                if (forceImageUpdate)
                {
                    lastImagePath = null;
                }

                nextImageUpdateTime = UpdateImage(data, currentSegment);
            }

            SystemThemeChanger.TryUpdateSystemTheme();

            if (isSunUp)
            {
                nextUpdateTime = data.sunsetTime;
            }
            else if (DateTime.Now < data.solarTimes[0])
            {
                nextUpdateTime = data.sunriseTime;
            }
            else
            {
                SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                    DateTime.Today.AddDays(1));
                nextUpdateTime = tomorrowsData.sunriseTime;
            }

            if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value)
            {
                nextUpdateTime = nextImageUpdateTime;
            }

            StartTimer(nextUpdateTime.Value);
            JsonConfig.SaveConfig();
        }
Ejemplo n.º 26
0
        public SchedulerState GetImageData(SolarData data, ThemeConfig theme, DateTime dateNow)
        {
            int[]          imageList = null;
            DateTime       segmentStart;
            DateTime       segmentEnd;
            SchedulerState imageData = new SchedulerState()
            {
                daySegment2 = isSunUp ? 0 : 1
            };

            // Use 4-segment mode if theme is not downloaded, or has sunrise/sunset images and dark mode not enabled
            if (theme?.imageFilename == null || (ThemeManager.IsTheme4Segment(theme) && !JsonConfig.settings.darkMode))
            {
                switch (GetDaySegment(data, dateNow))
                {
                case DaySegment.AlwaysDay:
                    imageList             = theme?.dayImageList;
                    segmentStart          = dateNow.Date;
                    segmentEnd            = dateNow.Date.AddDays(1);
                    imageData.daySegment4 = 1;
                    break;

                case DaySegment.AlwaysNight:
                    imageList             = theme?.nightImageList;
                    segmentStart          = dateNow.Date;
                    segmentEnd            = dateNow.Date.AddDays(1);
                    imageData.daySegment4 = 3;
                    break;

                case DaySegment.Sunrise:
                    imageList             = theme?.sunriseImageList;
                    segmentStart          = data.solarTimes[0];
                    segmentEnd            = data.solarTimes[1];
                    imageData.daySegment4 = 0;
                    break;

                case DaySegment.Day:
                    imageList             = theme?.dayImageList;
                    segmentStart          = data.solarTimes[1];
                    segmentEnd            = data.solarTimes[2];
                    imageData.daySegment4 = 1;
                    break;

                case DaySegment.Sunset:
                    imageList             = theme?.sunsetImageList;
                    segmentStart          = data.solarTimes[2];
                    segmentEnd            = data.solarTimes[3];
                    imageData.daySegment4 = 2;
                    break;

                default:
                    imageList             = theme?.nightImageList;
                    imageData.daySegment4 = 3;

                    if (dateNow < data.solarTimes[0])
                    {
                        SolarData yesterdaysData = SunriseSunsetService.GetSolarData(dateNow.Date.AddDays(-1));
                        segmentStart = yesterdaysData.solarTimes[3];
                        segmentEnd   = data.solarTimes[0];
                    }
                    else
                    {
                        segmentStart = data.solarTimes[3];
                        SolarData tomorrowsData = SunriseSunsetService.GetSolarData(dateNow.Date.AddDays(1));
                        segmentEnd = tomorrowsData.solarTimes[0];
                    }

                    break;
                }
            }
            else
            {
                imageList = theme?.nightImageList;

                if (!JsonConfig.settings.darkMode && (isSunUp || data.polarPeriod == PolarPeriod.PolarDay))
                {
                    imageList = theme?.dayImageList;
                }

                if (data.polarPeriod != PolarPeriod.None)
                {
                    segmentStart = dateNow.Date;
                    segmentEnd   = dateNow.Date.AddDays(1);
                }
                else if (isSunUp)
                {
                    segmentStart = data.sunriseTime;
                    segmentEnd   = data.sunsetTime;
                }
                else if (dateNow < data.sunriseTime)
                {
                    SolarData yesterdaysData = SunriseSunsetService.GetSolarData(dateNow.Date.AddDays(-1));
                    segmentStart = yesterdaysData.sunsetTime;
                    segmentEnd   = data.sunriseTime;
                }
                else
                {
                    segmentStart = data.sunsetTime;
                    SolarData tomorrowsData = SunriseSunsetService.GetSolarData(dateNow.Date.AddDays(1));
                    segmentEnd = tomorrowsData.sunriseTime;
                }
            }

            if (imageList != null)
            {
                TimeSpan segmentLength = segmentEnd - segmentStart;
                TimeSpan timerLength   = new TimeSpan(segmentLength.Ticks / imageList.Length);

                int imageNumber = (int)((dateNow.Ticks - segmentStart.Ticks) / timerLength.Ticks);
                imageData.imageId         = imageList[imageNumber];
                imageData.imageNumber     = imageNumber;
                imageData.nextUpdateTicks = segmentStart.Ticks + timerLength.Ticks * (imageNumber + 1);
            }

            return(imageData);
        }
        public void RunScheduler(bool forceImageUpdate = false)
        {
            if (!LaunchSequence.IsLocationReady() || !LaunchSequence.IsThemeReady())
            {
                return;
            }

            schedulerTimer.Stop();

            SolarData data                = SunriseSunsetService.GetSolarData(DateTime.Today);
            bool      isSunUp             = IsSunUp(data, DateTime.Now);
            DateTime? nextImageUpdateTime = null;

            if (ThemeManager.currentTheme != null)
            {
                if (forceImageUpdate)
                {
                    lastImagePath = null;
                }

                WallpaperShuffler.MaybeShuffleWallpaper();
            }

            SchedulerState imageData = GetImageData(data, ThemeManager.currentTheme, DateTime.Now);

            if (ThemeManager.currentTheme != null)
            {
                nextImageUpdateTime = new DateTime(imageData.endTick);

                if (JsonConfig.settings.enableInterpolation)
                {
                    SchedulerState nextImageData = GetImageData(data, ThemeManager.currentTheme, nextImageUpdateTime.Value + TimeSpan.FromSeconds(1));

                    lock (interpolationLock)
                    {
                        interpolation.imageId1    = imageData.imageId;
                        interpolation.imageId2    = nextImageData.imageId;
                        interpolation.lastPercent = -1;
                        interpolation.startTick   = imageData.startTick;
                        interpolation.endTick     = imageData.endTick;
                        lastImagePath             = null;
                        UpdateInterpolation();
                    }
                }
                else
                {
                    SetWallpaper(imageData.imageId);
                }
            }

            ScriptManager.RunScripts(new ScriptArgs
            {
                daySegment2 = imageData.daySegment2,
                daySegment4 = imageData.daySegment4,
                imagePath   = (ThemeManager.currentTheme != null) ? lastImagePath : null
            });

            if (data.polarPeriod != PolarPeriod.None)
            {
                nextUpdateTime = DateTime.Today.AddDays(1);
            }
            else if (isSunUp)
            {
                nextUpdateTime = data.sunsetTime;
            }
            else if (DateTime.Now < data.solarTimes[0])
            {
                nextUpdateTime = data.sunriseTime;
            }
            else
            {
                SolarData tomorrowsData = SunriseSunsetService.GetSolarData(DateTime.Today.AddDays(1));
                nextUpdateTime = tomorrowsData.sunriseTime;
            }

            if (nextImageUpdateTime.HasValue && nextImageUpdateTime.Value < nextUpdateTime.Value)
            {
                nextUpdateTime = nextImageUpdateTime;
            }

            StartTimer(nextUpdateTime.Value);
        }
Ejemplo n.º 28
0
        public SchedulerState GetImageData(SolarData data, ThemeConfig theme)
        {
            int[]          imageList;
            DateTime       segmentStart;
            DateTime       segmentEnd;
            SchedulerState imageData = new SchedulerState()
            {
                daySegment2 = isSunUp ? 0 : 1
            };

            if (!JsonConfig.settings.darkMode)
            {
                switch (GetCurrentDaySegment(data))
                {
                case DaySegment.AllDay:
                    imageList    = theme.dayImageList;
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                    BrightnessManager.ChangeBrightness(0);
                    imageData.daySegment4 = 1;
                    break;

                case DaySegment.AllNight:
                    imageList    = theme.nightImageList;
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                    BrightnessManager.ChangeBrightness(1);
                    imageData.daySegment4 = 3;
                    break;

                case DaySegment.Sunrise:
                    imageList    = theme.sunriseImageList;
                    segmentStart = data.solarTimes[0];
                    segmentEnd   = data.solarTimes[1];
                    BrightnessManager.ChangeBrightness(2);
                    imageData.daySegment4 = 0;
                    break;

                case DaySegment.Day:
                    imageList    = theme.dayImageList;
                    segmentStart = data.solarTimes[1];
                    segmentEnd   = data.solarTimes[2];
                    BrightnessManager.ChangeBrightness(3);
                    imageData.daySegment4 = 1;
                    break;

                case DaySegment.Sunset:
                    imageList    = theme.sunsetImageList;
                    segmentStart = data.solarTimes[2];
                    segmentEnd   = data.solarTimes[3];
                    BrightnessManager.ChangeBrightness(4);
                    imageData.daySegment4 = 2;
                    break;

                default:
                    imageList             = theme.nightImageList;
                    imageData.daySegment4 = 3;

                    if (DateTime.Now < data.solarTimes[0])
                    {
                        SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(-1));
                        segmentStart = yesterdaysData.solarTimes[3];
                        segmentEnd   = data.solarTimes[0];
                    }
                    else
                    {
                        segmentStart = data.solarTimes[3];
                        SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                            DateTime.Today.AddDays(1));
                        segmentEnd = tomorrowsData.solarTimes[0];
                    }

                    BrightnessManager.ChangeBrightness(5);
                    break;
                }
            }
            else
            {
                imageList = theme.nightImageList;

                BrightnessManager.ChangeBrightness(5);

                if (data.polarPeriod != PolarPeriod.None)
                {
                    segmentStart = DateTime.Today;
                    segmentEnd   = DateTime.Today.AddDays(1);
                }
                else if (isSunUp)
                {
                    segmentStart = data.sunriseTime;
                    segmentEnd   = data.sunsetTime;
                }
                else if (DateTime.Now < data.sunriseTime)
                {
                    SolarData yesterdaysData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(-1));
                    segmentStart = yesterdaysData.sunsetTime;
                    segmentEnd   = data.sunriseTime;
                }
                else
                {
                    segmentStart = data.sunsetTime;
                    SolarData tomorrowsData = SunriseSunsetService.GetSolarData(
                        DateTime.Today.AddDays(1));
                    segmentEnd = tomorrowsData.sunriseTime;
                }
            }

            TimeSpan segmentLength = segmentEnd - segmentStart;
            TimeSpan timerLength   = new TimeSpan(segmentLength.Ticks / imageList.Length);

            int imageNumber = (int)((DateTime.Now - segmentStart).Ticks / timerLength.Ticks);

            imageData.imageId         = imageList[imageNumber];
            imageData.nextUpdateTicks = segmentStart.Ticks + timerLength.Ticks * (imageNumber + 1);

            return(imageData);
        }
Ejemplo n.º 29
0
        public static List <DateTime> GetAllImageTimes(ThemeConfig theme)
        {
            List <DateTime> times    = new List <DateTime>();
            SolarData       data     = SunriseSunsetService.GetSolarData(DateTime.Today);
            SolarData       nextData = SunriseSunsetService.GetSolarData(DateTime.Today.AddDays(1));

            if (data.polarPeriod != PolarPeriod.None)
            {
                if (theme.sunriseImageList != null)
                {
                    for (int i = 0; i < theme.sunriseImageList.Length; i++)
                    {
                        times.Add(DateTime.MinValue);
                    }
                }
                for (int i = 0; i < theme.dayImageList.Length; i++)
                {
                    if (data.polarPeriod == PolarPeriod.PolarDay)
                    {
                        times.Add(DateTime.Today + TimeSpan.FromTicks(TimeSpan.FromDays(1).Ticks *i / theme.dayImageList.Length));
                    }
                    else
                    {
                        times.Add(DateTime.MinValue);
                    }
                }
                if (theme.sunsetImageList != null)
                {
                    for (int i = 0; i < theme.sunsetImageList.Length; i++)
                    {
                        times.Add(DateTime.MinValue);
                    }
                }
                for (int i = 0; i < theme.nightImageList.Length; i++)
                {
                    if (data.polarPeriod == PolarPeriod.PolarNight)
                    {
                        times.Add(DateTime.Today + TimeSpan.FromTicks(TimeSpan.FromDays(1).Ticks *i / theme.nightImageList.Length));
                    }
                    else
                    {
                        times.Add(DateTime.MinValue);
                    }
                }
            }
            else if (ThemeManager.IsTheme4Segment(theme))
            {
                for (int i = 0; i < theme.sunriseImageList.Length; i++)
                {
                    times.Add(data.solarTimes[0] + TimeSpan.FromTicks((data.solarTimes[1].Ticks - data.solarTimes[0].Ticks) * i / theme.sunriseImageList.Length));
                }
                for (int i = 0; i < theme.dayImageList.Length; i++)
                {
                    times.Add(data.solarTimes[1] + TimeSpan.FromTicks((data.solarTimes[2].Ticks - data.solarTimes[1].Ticks) * i / theme.dayImageList.Length));
                }
                for (int i = 0; i < theme.sunsetImageList.Length; i++)
                {
                    times.Add(data.solarTimes[2] + TimeSpan.FromTicks((data.solarTimes[3].Ticks - data.solarTimes[2].Ticks) * i / theme.sunsetImageList.Length));
                }
                for (int i = 0; i < theme.nightImageList.Length; i++)
                {
                    times.Add(data.solarTimes[3] + TimeSpan.FromTicks((nextData.solarTimes[0].Ticks - data.solarTimes[3].Ticks) * i / theme.nightImageList.Length));
                }
            }
            else
            {
                for (int i = 0; i < theme.dayImageList.Length; i++)
                {
                    times.Add(data.sunriseTime + TimeSpan.FromTicks((data.sunsetTime.Ticks - data.sunriseTime.Ticks) * i / theme.dayImageList.Length));
                }
                for (int i = 0; i < theme.nightImageList.Length; i++)
                {
                    times.Add(data.sunsetTime + TimeSpan.FromTicks((nextData.sunriseTime.Ticks - data.sunsetTime.Ticks) * i / theme.nightImageList.Length));
                }
            }

            return(times);
        }
Ejemplo n.º 30
0
 private static DaySegment GetCurrentDaySegment(SolarData data)
 {
     return(GetDaySegment(data, DateTimeTZ.Local.Now.ConvertTime(JsonConfig.settings.timezone)));
 }