public CaptureEngine(IDirect3DDevice device, GraphicsCaptureItem item)
        {
            _device    = device;
            _d3dDevice = Direct3D11Helper.CreateSharpDXDevice(_device);

            _framePool = Direct3D11CaptureFramePool.Create(
                _device, DirectXPixelFormat.B8G8R8A8UIntNormalized, 2, item.Size);
            _session  = _framePool.CreateCaptureSession(item);
            _lastSize = item.Size;

            _framePool.FrameArrived += OnFrameArrived;
        }
        private void OnFrameArrived(Direct3D11CaptureFramePool sender, object args)
        {
            var newSize = false;

            using (var frame = sender.TryGetNextFrame())
            {
                if (frame.ContentSize.Width != _lastSize.Width ||
                    frame.ContentSize.Height != _lastSize.Height)
                {
                    newSize   = true;
                    _lastSize = frame.ContentSize;
                }
                using (var bitmap = Direct3D11Helper.CreateSharpDXTexture2D(frame.Surface))
                {
                    FrameArrived?.Invoke(new CapturedBitmap(bitmap));
                }
            }
            if (newSize)
            {
                _framePool.Recreate(_device, DirectXPixelFormat.B8G8R8A8UIntNormalized, 2, _lastSize);
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            var vm = new MainViewModel();

            this.DataContext = vm;
            LoadSettings();

            _device = Direct3D11Helper.CreateDevice();
            _player = new HapticsPlayer();

            _headBridge = new HapticsBridge(
                new HapticsBridgeParameters(
                    6, 1, new HapticsPointSet[]
            {
                new HapticsPointSet(HapticsPosition.Head, new Point[]
                {
                    new Point(0, 0), new Point(1, 0), new Point(2, 0),
                    new Point(3, 0), new Point(4, 0), new Point(5, 0),
                })
            }),
                vm.Head,
                vm.ActiveColor,
                vm.InactiveColor,
                _player);
            _vestBridge = new HapticsBridge(
                new HapticsBridgeParameters(
                    8, 5, new HapticsPointSet[]
            {
                new HapticsPointSet(HapticsPosition.VestFront, new Point[]
                {
                    new Point(0, 0), new Point(1, 0), new Point(2, 0), new Point(3, 0),
                    new Point(0, 1), new Point(1, 1), new Point(2, 1), new Point(3, 1),
                    new Point(0, 2), new Point(1, 2), new Point(2, 2), new Point(3, 2),
                    new Point(0, 3), new Point(1, 3), new Point(2, 3), new Point(3, 3),
                    new Point(0, 4), new Point(1, 4), new Point(2, 4), new Point(3, 4),
                }),
                new HapticsPointSet(HapticsPosition.VestBack, new Point[]
                {
                    new Point(4, 0), new Point(5, 0), new Point(6, 0), new Point(7, 0),
                    new Point(4, 1), new Point(5, 1), new Point(6, 1), new Point(7, 1),
                    new Point(4, 2), new Point(5, 2), new Point(6, 2), new Point(7, 2),
                    new Point(4, 3), new Point(5, 3), new Point(6, 3), new Point(7, 3),
                    new Point(4, 4), new Point(5, 4), new Point(6, 4), new Point(7, 4),
                }),
            }),
                vm.Vest,
                vm.ActiveColor,
                vm.InactiveColor,
                _player);
            _leftArmBridge = new HapticsBridge(
                new HapticsBridgeParameters(
                    5, 4, new HapticsPointSet[]
            {
                new HapticsPointSet(HapticsPosition.Left, new Point[]
                {
                    new Point(0, 0), new Point(1, 0), new Point(2, 0), new Point(3, 0), new Point(4, 0),
                    new Point(0, 1), new Point(1, 1), new Point(2, 1), new Point(3, 1), new Point(4, 1),
                    new Point(0, 2), new Point(1, 2), new Point(2, 2), new Point(3, 2), new Point(4, 2),
                    new Point(0, 3), new Point(1, 3), new Point(2, 3), new Point(3, 3), new Point(4, 3),
                })
            }),
                vm.LeftArm,
                vm.ActiveColor,
                vm.InactiveColor,
                _player);
            _rightArmBridge = new HapticsBridge(
                new HapticsBridgeParameters(
                    5, 4, new HapticsPointSet[]
            {
                new HapticsPointSet(HapticsPosition.Right, new Point[]
                {
                    new Point(0, 0), new Point(1, 0), new Point(2, 0), new Point(3, 0), new Point(4, 0),
                    new Point(0, 1), new Point(1, 1), new Point(2, 1), new Point(3, 1), new Point(4, 1),
                    new Point(0, 2), new Point(1, 2), new Point(2, 2), new Point(3, 2), new Point(4, 2),
                    new Point(0, 3), new Point(1, 3), new Point(2, 3), new Point(3, 3), new Point(4, 3),
                })
            }),
                vm.RightArm,
                vm.ActiveColor,
                vm.InactiveColor,
                _player);
        }