//? Using this will cause old wallpapers to remain visible if you aren't filling the entire screen /* * // makes the background transparent to prevent flickering (Only stops the 1 frame flicker when closing, not the one that occurs when loading) * protected override void OnPaintBackground(PaintEventArgs e) * { * var sb = new SolidBrush(Color.FromArgb(0, 0, 0, 0)); * e.Graphics.FillRectangle(sb, this.DisplayRectangle); * } */ // TODO Create a queue that stores pictureBoxes/axWindowMediaPlayers for each wallpaper. This will be used to allow transitions & prevent flickering from // TODO style readjustment when changing wallpapers by *locking* the previous wallpaper in place public void SetWallpaper(string imageLocation) { Loops = 0; WallpaperUptime.Stop(); //! The below conditions were removed but I may consider re-adding this in the future when monitor-specific settings are added, although other methods of handling //! not changing a monitor's wallpaper would probably be better than this //!if (imageLocation == null) return; //? Under certain conditions a wallpaper won't be selected, this prevents the program from crashing over this if (!IsHandleCreated) { return; } if (InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate { SetWallpaperProcess(); }); } else { SetWallpaperProcess(); } async void SetWallpaperProcess() { if (!WallpaperManagerTools.IsSupportedVideoType(imageLocation)) { IsPlayingVideo = false; player.Stop(); panelWallpaper.Visible = false; panelWallpaper.Enabled = false; pictureBoxWallpaper.ImageLocation = imageLocation; pictureBoxWallpaper.Enabled = true; pictureBoxWallpaper.Visible = true; activeVideoImagePath = null; } else { IsPlayingVideo = true; WallpaperUptime.Restart(); pictureBoxWallpaper.Visible = false; pictureBoxWallpaper.Enabled = false; panelWallpaper.Enabled = true; panelWallpaper.Visible = true; activeVideoImagePath = imageLocation; await Task.Run(() => { player.Reload(imageLocation); WallpaperData.VideoSettings videoSettings = WallpaperData.GetImageData(imageLocation).VideoSettings; player.Volume = AudioManager.IsWallpapersMuted ? 0 : videoSettings.Volume; player.Speed = videoSettings.PlaybackSpeed; }).ConfigureAwait(false); } } ResetWallpaperStyle(); // this needs to be readjusted with each image }