private void SetWallpaper(int imageId1, int imageId2, double percent)
        {
            string imageFilename1 = ThemeManager.currentTheme.imageFilename.Replace("*", imageId1.ToString());
            string imageFilename2 = ThemeManager.currentTheme.imageFilename.Replace("*", imageId2.ToString());

            string folder     = Path.Combine(Directory.GetCurrentDirectory(), "themes", ThemeManager.currentTheme.themeId);
            string imagePath1 = Path.Combine(folder, imageFilename1);
            string imagePath2 = Path.Combine(folder, imageFilename2);
            string outputPath = Path.Combine(folder, "current.jpg");

            Task.Run(() =>
            {
                var sw = new System.Diagnostics.Stopwatch();

                sw.Restart();
                using (var image1 = new ImageMagick.MagickImage(imagePath1))
                    using (var image2 = new ImageMagick.MagickImage(imagePath2))
                    {
                        image1.Quality = 98;
                        image1.Composite(image2, ImageMagick.CompositeOperator.Blend, Math.Round(percent * 100).ToString());
                        image1.Write(outputPath);
                    }
                sw.Stop();
                Console.WriteLine($"NEW: {sw.ElapsedMilliseconds}");

                GC.Collect();

                WallpaperApi.EnableTransitions();
                UwpDesktop.GetHelper().SetWallpaper("current.jpg");
            });

            lastImagePath = outputPath;
        }
Exemple #2
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*", imageId.ToString());
            string imagePath     = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                                ThemeManager.currentTheme.themeId, imageFilename);

            if (imagePath == lastImagePath)
            {
                return;
            }

            WallpaperApi.EnableTransitions();
            UwpDesktop.GetHelper().SetWallpaper(imageFilename);

            if (Environment.OSVersion.Version.Build >= 21337)
            {
                if (!virtualDesktopInit.IsCompleted)
                {
                    virtualDesktopInit.Wait();
                }

                foreach (VirtualDesktop desktop in VirtualDesktop.GetDesktops())
                {
                    if (desktop.Id != VirtualDesktop.Current.Id)
                    {
                        desktop.WallpaperPath = imagePath;
                    }
                }
            }

            lastImagePath = imagePath;
        }
        public override async void SetWallpaper(string imagePath)
        {
            WallpaperApi.EnableTransitions();

            var uri = new Uri("ms-appdata:///local/themes/" + ThemeManager.currentTheme.themeId + "/" +
                              Path.GetFileName(imagePath));
            var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

            var profileSettings = Windows.System.UserProfile.UserProfilePersonalizationSettings.Current;
            await profileSettings.TrySetWallpaperImageAsync(file);

            WallpaperApi.SyncVirtualDesktops(imagePath);
        }
Exemple #4
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*", imageId.ToString());
            string imagePath     = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                                ThemeManager.currentTheme.themeId, imageFilename);

            if (imagePath == lastImagePath)
            {
                return;
            }

            WallpaperApi.EnableTransitions();
            UwpDesktop.GetHelper().SetWallpaper(imageFilename);

            lastImagePath = imagePath;
        }
Exemple #5
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*",
                                                                                   imageId.ToString());
            string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                            ThemeManager.currentTheme.themeId, imageFilename);

            if (imagePath == lastImagePath)
            {
                return;
            }

            WallpaperApi.EnableTransitions();
            UwpDesktop.GetHelper().SetWallpaper(imageFilename);

            if (UwpDesktop.IsRunningAsUwp() && JsonConfig.settings.changeLockScreen)
            {
                UwpHelper.SetLockScreenImage(imageFilename);
            }

            lastImagePath = imagePath;
        }