void SwitchWebcamPreview() { if (_webcamModel.WebcamCapture == null) { return; } if (IsVisible) { if (PresentationSource.FromVisual(this) is HwndSource source) { var win = _platformServices.GetWindow(source.Handle); var rect = GetPreviewWindowRect(); _webcamModel.WebcamCapture.UpdatePreview(win, rect); } } else if (PresentationSource.FromVisual(MainWindow.Instance) is HwndSource source) { var win = _platformServices.GetWindow(source.Handle); var rect = new RectangleF(280, 1, 50, 40).ApplyDpi(); _webcamModel.WebcamCapture.UpdatePreview(win, rect); } }
public void Shot(ShotCmdOptions ShotOptions) { _settings.IncludeCursor = ShotOptions.Cursor; // Screenshot Window with Transparency if (Regex.IsMatch(ShotOptions.Source, @"win:\d+")) { var ptr = int.Parse(ShotOptions.Source.Substring(4)); try { var win = _platformServices.GetWindow(new IntPtr(ptr)); var bmp = _screenShotModel.ScreenShotWindow(win); _screenShotModel.SaveScreenShot(bmp, ShotOptions.FileName).Wait(); } catch { // Suppress Errors } } else { var videoSourceKind = HandleVideoSource(ShotOptions); var bmp = _screenShotModel.GetScreenShot(videoSourceKind).Result; _screenShotModel.SaveScreenShot(bmp, ShotOptions.FileName).Wait(); } }
void UpdateWebcamPreview() { if (PresentationSource.FromVisual(this) is HwndSource source) { var win = _platformServices.GetWindow(source.Handle); var rect = GetPreviewWindowRect(); _webcamCapture?.Value?.UpdatePreview(win, rect); } }
public override bool ParseCli(string Arg) { if (!Regex.IsMatch(Arg, @"^win:\d+$")) { return(false); } var handle = new IntPtr(int.Parse(Arg.Substring(4))); Set(_platformServices.GetWindow(handle)); return(true); }