コード例 #1
0
        public WebcamOverlayReactor(WebcamOverlaySettings Settings)
        {
            Margin = Settings
                     .ObserveProperty(M => M.X)
                     .CombineLatest(
                Settings
                .ObserveProperty(M => M.Y),
                FrameSize,
                (X, Y, FrameSize) =>
            {
                var pos = Settings.GetPosition((float)FrameSize.Width, (float)FrameSize.Height);

                return(new Thickness(pos.X, pos.Y, 0, 0));
            })
                     .ToReadOnlyReactivePropertySlim();

            Width = Settings
                    .ObserveProperty(M => M.Width)
                    .CombineLatest(FrameSize, (Width, FrameSize) => Settings.GetWidth((float)FrameSize.Width))
                    .ToReadOnlyReactivePropertySlim();

            Height = Settings
                     .ObserveProperty(M => M.Height)
                     .CombineLatest(FrameSize, (Height, FrameSize) => Settings.GetHeight((float)FrameSize.Height))
                     .ToReadOnlyReactivePropertySlim();

            Opacity = Settings
                      .ObserveProperty(M => M.Opacity)
                      .Select(M => M / 100.0)
                      .ToReadOnlyReactivePropertySlim();
        }
コード例 #2
0
ファイル: WebcamOverlay.cs プロジェクト: zz110/Captura
        public override void Draw(IEditableFrame Editor, Func <Point, Point> PointTransform = null)
        {
            var pos = _settings.GetPosition(Editor.Width, Editor.Height);
            var w   = _settings.GetWidth(Editor.Width);
            var h   = _settings.GetHeight(Editor.Height);

            Draw(Editor, GetImage(Editor), pos, new SizeF(w, h), _settings.Opacity);
        }
コード例 #3
0
ファイル: WebcamOverlay.cs プロジェクト: zizhang2/Captura
        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 = _webcamModel.WebcamCapture;

            if (cap == null)
            {
                return;
            }

            var pos = _settings.GetPosition(Editor.Width, Editor.Height);
            var w   = _settings.GetWidth(Editor.Width);
            var h   = _settings.GetHeight(Editor.Height);

            var imgWbyH = cap.Width / cap.Height;

            var frameWbyH = w / h;

            if (imgWbyH > frameWbyH)
            {
                var newH = w / imgWbyH;

                pos.Y += (h - newH) / 2;
                h      = newH;
            }
            else
            {
                var newW = h * imgWbyH;

                pos.X += (w - newW) / 2;
                w      = newW;
            }

            Draw(Editor, GetImage(Editor), pos, new SizeF(w, h), _settings.Opacity);
        }