public void View(string path, ContextObject context) { _viewer = new SlideshowPanel(); context.ViewerContent = _viewer; context.Title = $"{Path.GetFileName(path)}"; _entries = new List <string>( Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)); _viewer.ShowEntriesFound(_entries); _viewer.StartSlideshow += () => { var cts = new CancellationTokenSource(); var token = cts.Token; int numberOfSeconds = _viewer.NumberOfSeconds * 1000; Task.Run(async() => { foreach (var entry in _entries) { if (token.IsCancellationRequested) { break; } PipeServerManager.SendMessage( PipeMessages.Switch, entry); await Task.Delay(numberOfSeconds); } ; }); Task.Run(() => { var PipeName = "QuickLook.App.Pipe." + WindowsIdentity.GetCurrent().User?.Value; var _server = new NamedPipeServerStream(PipeName, PipeDirection.In, 2); using (var reader = new StreamReader(_server)) { while (true) { _server.WaitForConnection(); var msg = reader.ReadLine(); _server.Disconnect(); if (msg.IndexOf("Close") > -1) { _server.Dispose(); cts.Cancel(); break; } } } }); }; context.IsBusy = false; }
public void Cleanup() { if (_viewer == null) { return; } _viewer = null; }