Setting currently reading text of a book to the centre of the web browser document
<p>I have a windows based application which reads and play book.  I'm using webBrowser control for text being read.  The current text is highlighted always.  The highlighted text always stays on top of document. But I want it to be at the centre of the document while playing book.</p>

<p>Here the highlighted text refers to the complete line or paragraph.</p>

<p>The approach I'm using is:</p>

<p>//for getting x and y position of currently reading text</p>

<pre><code>                    var parent = element.OffsetParent;
                    int xoff = element.OffsetRectangle.X;
                    int yoff = element.OffsetRectangle.Y;

                    while (parent != null)
                    {
                        xoff += parent.OffsetRectangle.X;
                        yoff += parent.OffsetRectangle.Y;
                        parent = parent.OffsetParent;
                    }

               //for getting the height of the document
                    var yBoff = wbDocument.Document.Body.OffsetRectangle.Height;

              //for getting the offset rectangle for currently reading text
                  Rectangle rect1 =  wbDocument.Document.GetElementById(contentSpineID).OffsetRectangle;
</code></pre>

<p>//if y position of text is greater or equal to the height of document then set the text at the centre of the document(setting the offset rectangle to the new position)</p>

<pre><code>                    if (yoff &gt;= yBoff/2)
                   {
                         yoff = yBoff / 2;
                         rect1.Offset(0, yoff);

                   }
</code></pre>

<p>But this code is not functional in my app.  May be it might need some additional functionality also.  So could anyone please tell me some solution for this?</p>
