Exemplo n.º 1
0
        public void GetNextContainerBlock_Works(TestData data)
        {
            var nextBlock = BlockTreeWalker.GetNextNonContainerBlock(data.GetCurrent(this));

            DidYouKnow.That(GetNameOf(nextBlock)).Should().Be(GetNameOf(data.GetExpected(this)));
            DidYouKnow.That(nextBlock).Should().Be(data.GetExpected(this));
        }
Exemplo n.º 2
0
        /// <summary> Uses HitTesting to determine the block at the specified point. </summary>
        /// <param name="point"> The point at which the hit test should be performed. </param>
        /// <returns> The block at a the given point. </returns>
        public Block GetBlockAt(DocumentPoint point)
        {
            _block = null;

            if (point.Y < 0)
            {
                return(_ownerView.GetBlockFor(new DocumentPoint(0, 0)));
            }
            else if (point.Y > _ownerView.RootVisual.ActualHeight)
            {
                var lastBlock = _ownerView.Context.Document.Root.LastBlock;
                return(BlockTreeWalker.GetNextNonContainerBlock(lastBlock)
                       ?? lastBlock as ContentBlock);
            }

            var localPoint = _ownerView.ToPoint(point);
            var instance   = _ownerView.InputHitTest(localPoint);

            if (instance is IDocumentItemView view &&
                GetAssociatedBlock(view) is Block block)
            {
                _block = block;
            }