public void SetActiveLockscreenTheme(WallpaperTheme theme) { Debug.WriteLine($"Setting Active Lockscreen Theme To: {theme.ID} - {theme.Name}"); ActiveThemeService themeService = new ActiveThemeService(); themeService.ChangeActiveLockscreenTheme(theme); }
public async void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - {nameof(Run)} - Begun"); // Register the Monitoring Events taskInstance.Canceled += TaskInstance_Canceled; taskInstance.Task.Completed += Task_Completed; taskInstance.Task.Progress += Task_Progress; // Create the deferal and jump into the Task _deferral = taskInstance.GetDeferral(); // Create the Active theme Service var activeThemeService = new ActiveThemeService(); // Preform the service for the Active Desktop Theme var desktopTheme = activeThemeService.GetActiveDesktopTheme(); if (desktopTheme != null) { var desktopNextRunSetting = new ActiveDesktopThemeNextRunSetting(); if (DateTime.UtcNow >= desktopNextRunSetting.Value && desktopTheme.WallpaperChangeFrequency.TotalMilliseconds > 0.0) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Desktop - Changing Desktop Background"); await activeThemeService.NextDesktopBackground(); } else { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Desktop - Not enough time passed"); } } // Preform the service for the Active Lockscreen Theme var lockscreenTheme = activeThemeService.GetActiveLockscreenTheme(); if (lockscreenTheme != null) { var lockscreenNextRunSetting = new ActiveLockscreenThemeNextRunSetting(); if (DateTime.UtcNow >= lockscreenNextRunSetting.Value && lockscreenTheme.WallpaperChangeFrequency.TotalMilliseconds > 0.0) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Lockscreen - Changing Lockscreen Background"); await activeThemeService.NextLockscreenBackground(); } else { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Lockscreen - Not enough time passed"); } } // Update the ActiveThemeLastRun ActiveThemeTaskLastRunSetting activeThemeTaskLastRun = new ActiveThemeTaskLastRunSetting(); activeThemeTaskLastRun.Value = DateTime.UtcNow; // Trigger the task is compelted Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - {nameof(Run)} - Completed"); _deferral.Complete(); }
public async void DeselectActiveLockscreenThemeDialog() { ContentDialog deleteDialog = new ContentDialog { Title = "Deselect Lockscreen Theme?", Content = "If you deselect this theme it will no longer automatically update your Lockscreen Background", PrimaryButtonText = "Deselect", CloseButtonText = "Cancel" }; ContentDialogResult result = await deleteDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { ActiveThemeService activeThemeService = new ActiveThemeService(); activeThemeService.DeselectActiveLockscreenTheme(); ActiveLockscreenTheme = null; } }
public override void OnNavigatedTo() { Debug.WriteLine($"{nameof(ThemeDetailsViewModel)} - {nameof(OnNavigatedTo)}"); // Grab the parameter Theme = ThemeRepository.Find(((WallpaperTheme)NavigationService.Parameter).ID); FileCache.Clear(); // Enable or Disable the Active Theme Buttons ActiveThemeService activeThemeService = new ActiveThemeService(); if (activeThemeService.GetActiveDesktopThemeID() == Theme.ID) { SetActiveDesktopThemeButtonEnabled = false; } else { SetActiveDesktopThemeButtonEnabled = true; } if (activeThemeService.GetActiveLockscreenThemeID() == Theme.ID) { SetActiveLockscreenThemeButtonEnabled = false; } else { SetActiveLockscreenThemeButtonEnabled = true; } // Update the UI Elements in Settings RevertNameChangeCommand.Execute(null); RevertWallpaperSelectionMethodCommand.Execute(null); RevertWallpaperChangeFrequencyCommand.Execute(null); RefreshDirectoriesCommand.Execute(null); // Load the files Progress <IndicatorProgressReport> progress = new Progress <IndicatorProgressReport>(); progress.ProgressChanged += Progress_ProgressChanged; LoadFileCache(progress); }
public async void DeleteThemeDialog() { ContentDialog deleteDialog = new ContentDialog { Title = "Delete Theme Permanently?", Content = "If you delete this theme you will not be able to recover it. Are you sure you want to PERMANENTLY delete this Theme?", PrimaryButtonText = "Delete", CloseButtonText = "Cancel" }; ContentDialogResult result = await deleteDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { // Check the Active Themes and get rid of them if needed ActiveThemeService activeThemeService = new ActiveThemeService(); if (activeThemeService.GetActiveDesktopThemeID() == Theme.ID) { activeThemeService.DeselectActiveDesktopTheme(); } if (activeThemeService.GetActiveLockscreenThemeID() == Theme.ID) { activeThemeService.DeselectActiveLockscreenTheme(); } // Delete the theme var theme = ThemeRepository.Find(Theme.ID); if (theme == null) { return; } ThemeRepository.RemoveAndCommit(Theme.ID); // Redirect to the MainPage MainViewModel.Instance.NavigateThemesCommand.Execute(null); } }