예제 #1
0
        public MaskedPointerShape(int Width, int Height, Direct2DEditorSession EditorSession)
        {
            this.Width     = Width;
            this.Height    = Height;
            _editorSession = EditorSession;

            var copyTexDesc = new Texture2DDescription
            {
                Width             = this.Width,
                Height            = this.Height,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = Format.B8G8R8A8_UNorm,
                SampleDescription =
                {
                    Count   = 1,
                    Quality = 0
                },
                Usage          = ResourceUsage.Staging,
                BindFlags      = 0,
                CpuAccessFlags = CpuAccessFlags.Read
            };

            _copyTex = new Texture2D(_editorSession.Device, copyTexDesc);

            ShapeBuffer   = new byte[Width * Height * 4];
            DesktopBuffer = new byte[Width * Height * 4];
        }
        public FullScreenDesktopDuplicator(bool IncludeCursor,
                                           IPreviewWindow PreviewWindow,
                                           IPlatformServices PlatformServices)
        {
            using var factory = new Factory1();
            var outputs = factory
                          .Adapters1
                          .SelectMany(M => M.Outputs)
                          .ToArray();

            var bounds = PlatformServices.DesktopRectangle;

            Width  = bounds.Width;
            Height = bounds.Height;

            PointTransform = P => new Point(P.X - bounds.Left, P.Y - bounds.Top);

            _editorSession = new Direct2DEditorSession(Width, Height, PreviewWindow);

            _outputs.AddRange(outputs.Select(M =>
            {
                var output1 = M.QueryInterface <Output1>();

                var rect = M.Description.DesktopBounds;

                return(new DeskDuplOutputEntry
                {
                    DuplCapture = new DuplCapture(output1),
                    Location = new SharpDX.Point(rect.Left - bounds.Left, rect.Top - bounds.Top),
                    MousePointer = IncludeCursor ? new DxMousePointer(_editorSession) : null
                });
            }));
        }
예제 #3
0
        public DxgiTargetDeviceContext(IPreviewWindow PreviewWindow, int Width, int Height)
        {
            _editorSession        = new Direct2DEditorSession(Width, Height, PreviewWindow);
            _gdiCompatibleTexture = _editorSession.CreateGdiTexture(Width, Height);

            _dxgiSurface = _gdiCompatibleTexture.QueryInterface <Surface1>();
        }
예제 #4
0
 public MaskedColorPointerShape(IntPtr ShapeBuffer,
                                OutputDuplicatePointerShapeInformation ShapeInfo,
                                Direct2DEditorSession EditorSession)
     : base(ShapeInfo.Width, ShapeInfo.Height, EditorSession)
 {
     _maskedShapeBuffer = new byte[Width * Height * 4];
     Marshal.Copy(ShapeBuffer, _maskedShapeBuffer, 0, _maskedShapeBuffer.Length);
 }
예제 #5
0
        public MonochromePointerShape(IntPtr ShapeBuffer,
                                      OutputDuplicatePointerShapeInformation ShapeInfo,
                                      Direct2DEditorSession EditorSession)
            : base(ShapeInfo.Width, ShapeInfo.Height / 2, EditorSession)
        {
            _andMaskBuffer = new byte[Width * Height / 8];
            Marshal.Copy(ShapeBuffer, _andMaskBuffer, 0, _andMaskBuffer.Length);

            _xorMaskBuffer = new byte[Width * Height / 8];
            Marshal.Copy(ShapeBuffer + _andMaskBuffer.Length, _xorMaskBuffer, 0, _xorMaskBuffer.Length);
        }
예제 #6
0
        public void Dispose()
        {
            _bmp?.Dispose();
            _bmp = null;

            _copyTex?.Dispose();
            _copyTex = null;

            ShapeBuffer = DesktopBuffer = null;

            _editorSession = null;

            OnDispose();
        }
예제 #7
0
        public void Dispose()
        {
            try { _duplCapture.Dispose(); }
            catch { }
            finally { _duplCapture = null; }

            // Mouse Pointer disposed later to prevent errors.
            try { _mousePointer?.Dispose(); }
            catch { }
            finally { _mousePointer = null; }

            try { _editorSession.Dispose(); }
            catch { }
            finally { _editorSession = null; }
        }
예제 #8
0
        public DesktopDuplicator(bool IncludeCursor, Output1 Output, IPreviewWindow PreviewWindow)
        {
            _duplCapture = new DuplCapture(Output);

            var bounds = Output.Description.DesktopBounds;
            var width  = bounds.Right - bounds.Left;
            var height = bounds.Bottom - bounds.Top;

            _editorSession = new Direct2DEditorSession(width, height, PreviewWindow);

            if (IncludeCursor)
            {
                _mousePointer = new DxMousePointer(_editorSession);
            }
        }
        public void Dispose()
        {
            foreach (var entry in _outputs)
            {
                try { entry.DuplCapture.Dispose(); }
                catch { }
                finally { entry.DuplCapture = null; }

                // Mouse Pointer disposed later to prevent errors.
                try { entry.MousePointer?.Dispose(); }
                catch { }
                finally { entry.MousePointer = null; }
            }

            try { _editorSession.Dispose(); }
            catch { }
            finally { _editorSession = null; }
        }
예제 #10
0
 public DxMousePointer(Direct2DEditorSession editorSession)
 {
     _editorSession = editorSession;
 }