Example #1
0
 private WallpaperFile(string path, ushort desktopNumber, ushort monitorNumber, WallpaperPosition position)
 {
     this.Filepath      = path;
     this.DesktopNumber = desktopNumber;
     this.MonitorIndex  = monitorNumber;
     this.Position      = position;
 }
        private void UpdateCurrentComponentState(bool isInitializing = false)
        {
            if (Settings == null || SettingsBefore == null || (!Initialized && !isInitializing))
            {
                return;
            }
            string globalLightBefore = SettingsBefore.Component.GlobalWallpaper.Light ?? "";
            string globalDarkBefore  = SettingsBefore.Component.GlobalWallpaper.Dark ?? "";
            string globalLightAfter  = Settings.Component.GlobalWallpaper.Light ?? "";
            string globalDarkAfter   = Settings.Component.GlobalWallpaper.Dark ?? "";

            // check if the global wallpaper section has been modified.
            // Since we don't have target theme information here, if one value changes, we want a theme refresh
            if (!globalDarkBefore.Equals(globalDarkAfter))
            {
                currentGlobalTheme = Theme.Unknown;
            }
            if (!globalLightBefore.Equals(globalLightAfter))
            {
                currentGlobalTheme = Theme.Unknown;
            }

            // Same behavior with solid color
            if (!SettingsBefore.Component.SolidColors.Light.Equals(Settings.Component.SolidColors.Light))
            {
                currentSolidColorTheme = Theme.Unknown;
            }

            if (!SettingsBefore.Component.SolidColors.Dark.Equals(Settings.Component.SolidColors.Dark))
            {
                currentSolidColorTheme = Theme.Unknown;
            }

            // additinoally, if the user has changed the type dark before, an update is also required
            if (SettingsBefore.Component.TypeDark != Settings.Component.TypeDark)
            {
                StateUpdateOnTypeToggle(Settings.Component.TypeDark);
            }

            if (SettingsBefore.Component.TypeLight != Settings.Component.TypeLight)
            {
                StateUpdateOnTypeToggle(Settings.Component.TypeLight);
            }

            currentIndividualTheme   = GetIndividualWallpapersState();
            currentWallpaperPosition = WallpaperHandler.GetPosition();
        }
Example #3
0
        public static void SetWallpapers(List <MonitorSettings> monitorSettings, WallpaperPosition position, Theme newTheme)
        {
            IDesktopWallpaper handler = (IDesktopWallpaper) new DesktopWallpaperClass();

            handler.SetPosition(position);
            for (uint i = 0; i < handler.GetMonitorDevicePathCount(); i++)
            {
                string          monitorId      = handler.GetMonitorDevicePathAt(i);
                MonitorSettings monitorSetting = monitorSettings.Find(s => s.Id == monitorId);
                if (monitorSetting != null)
                {
                    if (newTheme == Theme.Dark)
                    {
                        if (!File.Exists(monitorSetting.DarkThemeWallpaper))
                        {
                            Logger.Warn($"target {Enum.GetName(typeof(Theme), newTheme)} wallpaper does not exist (skipping) path ${monitorSetting.DarkThemeWallpaper}, monitor ${monitorId}");
                        }
                        else
                        {
                            handler.SetWallpaper(monitorId, monitorSetting.DarkThemeWallpaper);
                        }
                    }
                    else
                    {
                        if (!File.Exists(monitorSetting.LightThemeWallpaper))
                        {
                            Logger.Warn($"wallpaper does not exist. path ${monitorSetting.DarkThemeWallpaper}, monitor ${monitorId}");
                        }
                        handler.SetWallpaper(monitorId, monitorSetting.LightThemeWallpaper);
                    }
                }
                else
                {
                    Logger.Warn($"no wallpaper config found for monitor {monitorId}, adding missing monitors");
                    DetectMonitors();
                }
            }
        }
 public override void EnableHook()
 {
     WallpaperHandler.DetectMonitors();
     currentWallpaperPosition = WallpaperHandler.GetPosition();
     base.EnableHook();
 }