public DirectoryScanner(string path, Playlist playlist) { this.path = path; this.playlist = playlist; Scan(); playlist.ShuffleNew(); watcher = new FileSystemWatcher(Path.GetFullPath(path), FilePattern); watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Changed += (_, e) => Scan(); watcher.Created += (_, e) => Scan(); watcher.EnableRaisingEvents = true; }
public MainWindow() { InitializeComponent(); Directory.CreateDirectory(ScanDirectory); playlist = new Playlist(random); scanner = new DirectoryScanner(ScanDirectory, playlist); timer = new Timer(_ => DoNextPhoto(), null, Timeout.Infinite, Timeout.Infinite); ScheduleTimer(1); playlist.FirstFreshPhoto += () => ScheduleTimer(); // Also immediately invokes }