public WebcamOverlayReactor(WebcamOverlaySettings Settings) { Location = Settings.ObserveProperty(M => M.XLoc) .CombineLatest( Settings.ObserveProperty(M => M.YLoc), FrameSize, WebcamSize, Settings.ObserveProperty(M => M.Scale), (X, Y, FrameSize, WebcamSize, Scale) => Settings.GetPosition(FrameSize.ToDrawingSize(), WebcamSize.ToDrawingSize())) .ToReadOnlyReactivePropertySlim(); Size = Settings.ObserveProperty(M => M.Scale) .CombineLatest( FrameSize, WebcamSize, (Scale, FrameSize, WebcamSize) => Settings.GetSize(FrameSize.ToDrawingSize(), WebcamSize.ToDrawingSize()).ToWpfSize()) .ToReadOnlyReactivePropertySlim(); Opacity = Settings .ObserveProperty(M => M.Opacity) .Select(M => M / 100.0) .ToReadOnlyReactivePropertySlim(); }
public override void Draw(IEditableFrame Editor, Func <Point, Point> PointTransform = null) { // No Webcam if (_webcamModel.AvailableCams.Count < 1 || _webcamModel.SelectedCam is NoWebcamItem) { return; } var cap = _webcamCapture.Value; if (cap == null) { return; } var frameSize = new Size((int)Editor.Width, (int)Editor.Height); var webcamSize = new Size(cap.Width, cap.Height); var pos = _settings.GetPosition(frameSize, webcamSize); var size = _settings.GetSize(frameSize, webcamSize); Draw(Editor, GetImage(Editor), pos, size, _settings.Opacity); }