private void SetupStreamers() { int screenId = 0; foreach (Screen screen in Screen.AllScreens) { ScreenVideoSource videoSource = new ScreenVideoSource(screen, screenId++); MJPEGStreamer streamer = new MJPEGStreamer(videoSource, qualityDefinition); streamer.StreamStarted += (sender, e) => { if (_isRunning) { AddStreamClient(GetClientStreamDescription(e.Stream)); } }; streamer.StreamStopped += (sender, e) => { if (_isRunning) { RemoveStreamClient(GetClientStreamDescription(e.Stream)); } }; string streamName = $"screen{screenId}"; _streamers[streamName] = streamer; _previewImageList.Images.Add(streamName, _blankImage); _screensListView.Items.Add(streamName, $"Screen {screenId}", streamName); } }
private void UpdatePreviews() { foreach (MJPEGStreamer streamer in _streamers.Values) { ScreenVideoSource videoSource = (ScreenVideoSource)streamer.Source; if (!videoSource.IsCapturing) { _previewImageList.Images[videoSource.ScreenId] = _blankImage; continue; } using (Image previewImage = videoSource.QueryPreviewImage()) if (previewImage != null) { _previewImageList.Images[videoSource.ScreenId] = previewImage; } } _screensListView.Refresh(); }