public FileAndTimeControl(FileAtTime fat, UserSettings userSettings) { InitializeComponent(); _fileAtTime = fat; _userSettings = userSettings; dtpTimeOfDay.Text = fat.TimeOfDay; txtFilePath.Text = fat.WallpaperPath; if (!string.IsNullOrEmpty(txtFilePath.Text)) { var directoryInfo = new FileInfo(txtFilePath.Text).Directory; if (directoryInfo != null) { ofdBrowse.InitialDirectory = directoryInfo.FullName; } } }
public FileAtTime Start(FileAtTime currentFileAtTime) { var now = DateTime.Now; _userSettings.FileTimes.Sort(); var shouldBeFileAtTime = _userSettings.FileTimes.LastOrDefault(f => f.GetTimeOfDayDateTime() <= now); if (shouldBeFileAtTime != null && currentFileAtTime == null) { Win32Wallpaper.Set(shouldBeFileAtTime.GetWallpaperFileInfo(), _userSettings.WallpaperStyle); return shouldBeFileAtTime; } if (shouldBeFileAtTime == null && currentFileAtTime != null) { Win32Wallpaper.Set(currentFileAtTime.GetWallpaperFileInfo(), _userSettings.WallpaperStyle); return currentFileAtTime; } if (shouldBeFileAtTime == null || (currentFileAtTime.TimeOfDay == shouldBeFileAtTime.TimeOfDay && currentFileAtTime.WallpaperPath == shouldBeFileAtTime.WallpaperPath)) { return shouldBeFileAtTime; } DoTransition(shouldBeFileAtTime.GetWallpaperFileInfo(), currentFileAtTime.GetWallpaperFileInfo()); return shouldBeFileAtTime; }
private void btnAddFileAndTime_Click(object sender, EventArgs e) { var fat = new FileAtTime(); _userSettings.FileTimes.Add(fat); pnlFileTimes.Controls.Add(new FileAndTimeControl(fat, _userSettings)); }
private void WallpaperTimerElapsed(object sender, ElapsedEventArgs e) { try { lock (_syncLock) { if (_wallpaperChanger == null) { _wallpaperChanger = new WallpaperChanger(); } else { return; } } _currentFileAtTime = _wallpaperChanger.Start(_currentFileAtTime); _wallpaperChanger = null; } finally { _wallpaperTimer.Start(); } }