Пример #1
0
        private void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            if (!LaunchSequence.IsLocationReady())
            {
                DialogResult result = MessageDialog.ShowQuestion(_("WinDynamicDesktop cannot display wallpapers " +
                                                                   "until you have entered a valid location, so that it can calculate sunrise and sunset times for " +
                                                                   "your location. Are you sure you want to cancel and quit the program?"), _("Question"), true);

                if (result == DialogResult.Yes)
                {
                    Environment.Exit(0);
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Пример #2
0
        public AppContext(string[] args)
        {
            // TODO Check tab order on all dialogs
            DebugLogger.WriteLogFile();
            JsonConfig.LoadConfig();
            Localization.Initialize();

            ThemeManager.importPaths = args.Where(System.IO.File.Exists).ToList();
            HandleMultiInstance();

            InitializeTrayIcon();
            LocationManager.Initialize();
            ThemeManager.Initialize();
            ScriptManager.Initialize();

            wpEngine.RunScheduler();
            LaunchSequence.NextStep();
            UpdateChecker.Initialize();
        }
        private static void OnDownloadDialogClosed(object sender, EventArgs e)
        {
            MainMenu.themeItem.Enabled = true;
            List <ThemeConfig> missingThemes = FindMissingThemes();

            if (missingThemes.Count == 0)
            {
                filesVerified = true;
                LaunchSequence.NextStep();
            }
            else
            {
                DialogResult result = MessageBox.Show(_("Failed to download images. Click Retry " +
                                                        "to try again, Ignore to continue with some themes disabled, or Abort to " +
                                                        "exit the program."), _("Error"), MessageBoxButtons.AbortRetryIgnore,
                                                      MessageBoxIcon.Warning);

                if (result == DialogResult.Abort)
                {
                    Environment.Exit(0);
                }
                else if (result == DialogResult.Retry)
                {
                    DownloadMissingImages(missingThemes);
                }
                else
                {
                    foreach (ThemeConfig theme in missingThemes)
                    {
                        themeSettings.Remove(theme);
                    }

                    if (missingThemes.Contains(currentTheme))
                    {
                        currentTheme = null;
                    }

                    filesVerified = true;
                    LaunchSequence.NextStep();
                }
            }
        }
Пример #4
0
        private static void DownloadMissingImages()
        {
            List <ThemeConfig> missingThemes = new List <ThemeConfig>();

            foreach (ThemeConfig theme in themeSettings)
            {
                string themePath = Path.Combine("themes", theme.themeId);

                if (!Directory.Exists(themePath) ||
                    (Directory.GetFiles(themePath, theme.imageFilename).Length == 0))
                {
                    missingThemes.Add(theme);
                }
            }

            if (missingThemes.Count == 0)
            {
                filesVerified = true;
                LaunchSequence.NextStep();
                return;
            }

            foreach (ThemeConfig theme in
                     missingThemes.Where(theme => string.IsNullOrEmpty(theme.imagesZipUri)))
            {
                missingThemes.Remove(theme);
                ThemeLoader.HandleError(theme.themeId,
                                        string.Format(_("Failed to find images for the '{0}' theme"), theme.themeId));
            }

            downloadDialog             = new ProgressDialog();
            downloadDialog.FormClosed += OnDownloadDialogClosed;
            downloadDialog.Show();

            MainMenu.themeItem.Enabled = false;
            downloadDialog.InitDownload(missingThemes);
        }
Пример #5
0
 private static void OnLocationDialogClosed(object sender, EventArgs e)
 {
     locationDialog = null;
     LaunchSequence.NextStep();
 }
Пример #6
0
 private static void OnThemeDialogClosed(object sender, EventArgs e)
 {
     themeDialog = null;
     LaunchSequence.NextStep(true);
 }
Пример #7
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, DateTime.Now);

            if (ThemeManager.currentTheme != null)
            {
                SetWallpaper(imageData.imageId);
                nextImageUpdateTime = new DateTime(imageData.nextUpdateTicks);
            }

            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);
        }
        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);
        }
Пример #9
0
 private static void OnDownloadDialogClosed(object sender, EventArgs e)
 {
     MainMenu.themeItem.Enabled = true;
     filesVerified = true;
     LaunchSequence.NextStep();
 }