예제 #1
0
        public void SetActiveLockscreenTheme(WallpaperTheme theme)
        {
            Debug.WriteLine($"Setting Active Lockscreen Theme To: {theme.ID} - {theme.Name}");
            ActiveThemeService themeService = new ActiveThemeService();

            themeService.ChangeActiveLockscreenTheme(theme);
        }
        private void GridView_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            GridView gridView = (GridView)sender;

            themesMenuFlyout.ShowAt(gridView, e.GetPosition(gridView));
            m_rightClickedWallPaperTheme = ((FrameworkElement)e.OriginalSource).DataContext as WallpaperTheme;
        }
예제 #3
0
 public void ChangeActiveLockscreenTheme(WallpaperTheme theme)
 {
     if (!ServiceEnabled)
     {
         return;
     }
     DeselectActiveLockscreenTheme();
     m_activeLockscreenThemeSetting.Value = theme.ID;
 }
예제 #4
0
        public List <FileDiscoveryCache> GetCache(WallpaperTheme theme)
        {
            List <FileDiscoveryCache> cache = FileCacheRepo.GetAllQuery()
                                              .Where(x => x.WallpaperThemeID == theme.ID)
                                              .OrderBy(x => x.FolderPath)
                                              .ThenBy(x => x.FilePath)
                                              .ToList();

            return(cache);
        }
        private void MenuFlyoutItem_SetActiveLockscreen_Click(object sender, RoutedEventArgs e)
        {
            if (m_rightClickedWallPaperTheme == null)
            {
                return;
            }

            ViewModel.SetActiveLockscreenTheme(m_rightClickedWallPaperTheme);
            m_rightClickedWallPaperTheme = null;
        }
        private void MenuFlyoutItem_Delete_Click(object sender, RoutedEventArgs e)
        {
            if (m_rightClickedWallPaperTheme == null)
            {
                return;
            }

            ViewModel.DeleteThemeDialog(m_rightClickedWallPaperTheme.ID);
            m_rightClickedWallPaperTheme = null;
        }
예제 #7
0
        public void NavigateTheme(WallpaperTheme theme)
        {
            if (!CanNavigate)
            {
                return;
            }

            Debug.WriteLine($"Navigating To: {theme.ID} - {theme.Name}");

            MainViewModel.Instance.CurrentNavigationLocation = Models.Enums.NavigationLocation.ThemeDetails;
            NavigationService.Navigate(typeof(ThemeDetailsPage), theme);
        }
        public ThemeDetailsViewModel()
            : base()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                Theme      = new WallpaperTheme();
                Theme.Name = "Theme Name";
            }
            else
            {
                // Code runs "for real"
            }

            // Populate the Timespan Selector Lists
            DaysList = new List <int>();
            for (int i = 0; i <= 7; i++)
            {
                DaysList.Add(i);
            }

            HoursList = new List <int>();
            for (int i = 0; i < 24; i++)
            {
                HoursList.Add(i);
            }

            MinutesList = new List <int>();
            for (int i = 0; i < 60; i++)
            {
                MinutesList.Add(i);
            }

            SecondsList = new List <int>();
            for (int i = 0; i < 60; i++)
            {
                SecondsList.Add(i);
            }

            ResetViewModel();
        }
예제 #9
0
        public async Task <List <FileDiscoveryCache> > PreformFileDiscovery(WallpaperTheme theme, IProgress <IndicatorProgressReport> progress)
        {
            if (theme == null)
            {
                return(new List <FileDiscoveryCache>());
            }

            List <FileDiscoveryCache> updatedThemeFilesCache = new List <FileDiscoveryCache>();

            progress?.Report(new IndicatorProgressReport(true, 0.0, $"Grabbing Theme directories - {theme.Name} - Step 1/1", true));
            var directories = DirectoryRepo.GetAllQuery()
                              .Where(x => x.WallpaperThemeID == theme.ID)
                              .ToList();

            if (directories.Count == 0)
            {
                return(new List <FileDiscoveryCache>());
            }

            // Step one we have to populate our openedList with all the directories in the theme
            Stack <WallpaperDirectory> openedList = new Stack <WallpaperDirectory>(directories);

            // Grab the Excluded Paths
            var excludedList = directories
                               .Where(x => x.IsExcluded)
                               .Select(x => x.Path.ToLower())
                               .ToList();

            // Mark the File Discovery Date on the Theme and Update it
            if (allCacheProgress == null)
            {
                theme.DateCacheDiscovered = DateTime.UtcNow;
                ThemeRepo.UpdateAndCommit(theme);
            }

            // Begin the discovery process
            while (openedList.Count > 0)
            {
                var currentDirectory = openedList.Pop();
                if (currentDirectory.IsExcluded)
                {
                    continue;
                }

                try
                {
                    List <StorageFolder> allFolders = new List <StorageFolder>();

                    // Convert the path into a StorageFolder
                    progress?.Report(new IndicatorProgressReport(true, 20.0, $"Discovering Folders For Theme - {theme.Name} - Step 1/3", true));
                    var rootFolder = await StorageFolder.GetFolderFromPathAsync(currentDirectory.Path);

                    allFolders.Add(rootFolder);

                    // If we are allowed to gather subdirectories, gather them as well
                    if (currentDirectory.IncludeSubdirectories)
                    {
                        progress?.Report(new IndicatorProgressReport(true, 30.0, $"Discovering Subfolders For Theme - {theme.Name} - Step 2/3", true));
                        var subfoldersOpenedList = await StorageTask.Instance.GetDirectoryTreeFromFolder(rootFolder, false);

                        allFolders.AddRange(subfoldersOpenedList);
                    }

                    // Next go through all the folders and get their files
                    progress?.Report(new IndicatorProgressReport(true, 40.0, $"Discovering Files For Theme - {theme.Name} - Step 3/3", true));
                    foreach (var currentFolder in allFolders)
                    {
                        try
                        {
                            var files = await currentFolder.GetFilesAsync();

                            foreach (var currentFile in files)
                            {
                                if (currentFile.ContentType.ToLower().Contains("image"))
                                {
                                    FileDiscoveryCache cache = new FileDiscoveryCache();
                                    cache.WallpaperThemeID  = currentDirectory.WallpaperThemeID;
                                    cache.FileAccessTokenID = currentDirectory.FileAccessTokenID;
                                    cache.StorageLocation   = currentDirectory.StorageLocation;
                                    cache.FolderPath        = currentFolder.Path;
                                    cache.FilePath          = currentFile.Path;
                                    cache.DateDiscovered    = theme.DateCacheDiscovered;
                                    updatedThemeFilesCache.Add(cache);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.ToString());
                            if (Debugger.IsAttached)
                            {
                                Debugger.Break();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
            }

            // Check the exclusion list and remove what shouldn't exist
            progress?.Report(new IndicatorProgressReport(true, 60.0, $"Excluding Items - {theme.Name} - Step 1/1", true));
            for (int i = updatedThemeFilesCache.Count - 1; i >= 0; i--)
            {
                foreach (var excludedPath in excludedList)
                {
                    if (updatedThemeFilesCache[i].FilePath.ToLower().Contains(excludedPath))
                    {
                        updatedThemeFilesCache.RemoveAt(i);
                        break;
                    }
                }
            }

            // Order the Cache
            progress?.Report(new IndicatorProgressReport(true, 70.0, $"Ordering Cache - {theme.Name} - Step 1/1", true));
            updatedThemeFilesCache = updatedThemeFilesCache.OrderBy(x => x.FolderPath)
                                     .ThenBy(x => x.FilePath)
                                     .ToList();

            // Before we clear the cache, make sure we aren't running within the scope of PreformFileDiscoveryAll
            if (allCacheProgress == null)
            {
                // Before we upload to the repo, we need to clear the cache for the current theme
                progress?.Report(new IndicatorProgressReport(true, 80.0, $"Clearing Old Cache - {theme.Name} - Step 1/2", true));
                var currentThemeCache = FileCacheRepo.GetAllQuery().Where(x => x.WallpaperThemeID == theme.ID).ToList();
                FileCacheRepo.RemoveRange(currentThemeCache);
            }

            // With the current items out of the way, we can now add in our new items
            progress?.Report(new IndicatorProgressReport(true, 90.0, $"Updating Cache - {theme.Name} - Step 2/2", true));
            FileCacheRepo.AddRange(updatedThemeFilesCache);

            progress?.Report(new IndicatorProgressReport(true, 100.0, $"Completed Cache For - {theme.Name}", true));
            return(updatedThemeFilesCache);
        }
예제 #10
0
        public async Task <StorageFile> CreateWindowsTheme(WallpaperTheme theme)
        {
            using (var context = new WallpaperManagerContext())
            {
                var fileDiscoveryService = new FileDiscoveryService(context);

                var fileCache = fileDiscoveryService.GetCache(theme);
                if (fileCache.Count <= 0)
                {
                    return(null);
                }

                // Build up the file format
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("; Copyright © Killerrin Studios");
                builder.AppendLine();
                builder.AppendLine("[Theme]");
                builder.AppendLine($"DisplayName={theme.Name}");
                builder.AppendLine();
                builder.AppendLine(@"[Control Panel\Desktop]");
                builder.AppendLine($"Wallpaper={theme.FirstImageFromCache}");
                builder.AppendLine("; The path to the wallpaper picture can point to a .bmp, .gif, .jpg, .png, or .tif file.");
                builder.AppendLine("Pattern=");
                //builder.AppendLine($"MultimonBackgrounds={0}");
                //builder.AppendLine($"PicturePosition={4}");
                builder.AppendLine($"TileWallpaper={0}");
                builder.AppendLine("; 0: The wallpaper picture should not be tiled");
                builder.AppendLine("; 1: The wallpaper picture should be tiled ");
                builder.AppendLine($"WallpaperStyle={10}");
                builder.AppendLine("; 0:  The image is centered if TileWallpaper = 0 or tiled if TileWallpaper = 1");
                builder.AppendLine("; 2:  The image is stretched to fill the screen");
                builder.AppendLine("; 6:  The image is resized to fit the screen while maintaining the aspect ratio. (Windows 7 and later)");
                builder.AppendLine("; 10: The image is resized and cropped to fill the screen while maintaining the aspect ratio. (Windows 7 and later)");
                builder.AppendLine();
                builder.AppendLine("[Slideshow]");
                if (theme.WallpaperChangeFrequency.TotalMilliseconds > 0.0)
                {
                    builder.AppendLine($"Interval={theme.WallpaperChangeFrequency.TotalMilliseconds}");
                }
                else
                {
                    builder.AppendLine($"Interval={TimeSpan.FromMinutes(5.0).TotalMilliseconds}");
                }
                builder.AppendLine("; Interval is a number that determines how often the background changes. It is measured in milliseconds.");
                switch (theme.WallpaperSelectionMethod)
                {
                case ImageSelectionMethod.Random:
                case ImageSelectionMethod.Sequential:
                    builder.AppendLine($"Shuffle={(int)theme.WallpaperSelectionMethod}");
                    break;

                default:
                    builder.AppendLine($"Shuffle={0}");
                    break;
                }
                builder.AppendLine("; 0: Disabled");
                builder.AppendLine("; 1: Enabled");
                builder.AppendLine();
                builder.AppendLine($"ImagesRootPath={fileCache[0].FolderPath}");
                for (int i = 0; i < fileCache.Count; i++)
                {
                    builder.AppendLine($"Item{i}Path={fileCache[i].FilePath}");
                }
                builder.AppendLine();
                builder.AppendLine("[VisualStyles]");
                builder.AppendLine($@"Path=%ResourceDir%\Themes\Aero\Aero.msstyles");
                builder.AppendLine($"ColorStyle=NormalColor");
                builder.AppendLine($"Size=NormalSize");
                builder.AppendLine($"AutoColorization=0");
                builder.AppendLine($"ColorizationColor=0XC40078D7");
                builder.AppendLine();
                builder.AppendLine("[boot]");
                builder.AppendLine("SCRNSAVE.EXE=");
                builder.AppendLine();
                builder.AppendLine("[MasterThemeSelector]");
                builder.AppendLine("MTSM=RJSPBS");

                FileSavePicker savePicker = new FileSavePicker();
                savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("Windows Theme File", new List <string>()
                {
                    ".theme"
                });
                savePicker.SuggestedFileName = $"{theme.Name}";

                var file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    CachedFileManager.DeferUpdates(file);
                    await FileIO.WriteTextAsync(file, builder.ToString());

                    FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == FileUpdateStatus.Complete || status == FileUpdateStatus.CompleteAndRenamed)
                    {
                        return(file);
                    }
                }
            }

            return(null);
        }