/// <summary>
 /// Set offset position of view range to given position.
 /// </summary>
 /// <param name="vr">View range to set new offset.</param>
 /// <param name="y_pos">new offset position.</param>
 private void scrollViewRangeTo(BrailleIOViewRange vr, int y_pos)
 {
     if (vr != null && y_pos <= 0)
     {
         if (y_pos >= (vr.ContentBox.Height - vr.ContentHeight))
         {
             vr.SetYOffset(y_pos);
         }
         else
         {
             vr.SetYOffset(0);
         }
     }
 }
 private void jumpToTopBorder(BrailleIOViewRange center)
 {
     if (center != null)
     {
         center.SetYOffset(0);
         io.RefreshDisplay();
         audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.jump.up"));
         Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] jump to top");
     }
 }
 /// <summary>
 /// Add the given scroll step to the current offset position of view range to realize a scrolling.
 /// </summary>
 /// <param name="vr">View range to scroll.</param>
 /// <param name="scrollStep">Steps to scroll the view range.</param>
 private void scrollViewRange(BrailleIOViewRange vr, int scrollStep)
 {
     if (vr != null)
     {
         int newPos = vr.OffsetPosition.Y + scrollStep;
         if (newPos <= 0 && newPos >= (vr.ContentBox.Height - vr.ContentHeight))
         {
             vr.SetYOffset(newPos);
         }
     }
 }
 private void jumpToBottomBorder(BrailleIOViewRange center)
 {
     if (center != null)
     {
         int offset = center.ContentHeight - center.ContentBox.Height;
         center.SetYOffset(-offset);
         io.RefreshDisplay();
         audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.jump.down"));
         Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] jump to bottom");
     }
 }
        void zoom(string viewName, string viewRangeName, double factor)
        {
            if (IO == null && IO.GetView(viewName) as BrailleIOScreen != null)
            {
                return;
            }
            // zoom in
            BrailleIOViewRange vr = ((BrailleIOScreen)IO.GetView(viewName)).GetViewRange(viewRangeName);

            if (vr != null)
            {
                if (vr.GetZoom() > 0)
                {
                    //TODO: make zoom to center
                    var   oldZoom   = vr.GetZoom();
                    var   newZoom   = oldZoom * factor;
                    var   oldvrdin  = vr.ViewBox;
                    Point oldcenter = new Point(
                        (int)Math.Round(((double)oldvrdin.Width / 2) + (vr.GetXOffset() * -1)),
                        (int)Math.Round(((double)oldvrdin.Height / 2) + (vr.GetYOffset() * -1))
                        );

                    Point newCenter = new Point(
                        (int)Math.Round(oldcenter.X * newZoom / oldZoom),
                        (int)Math.Round(oldcenter.Y * newZoom / oldZoom)
                        );

                    Point newOffset = new Point(
                        (int)Math.Round((newCenter.X - ((double)oldvrdin.Width / 2)) * -1),
                        (int)Math.Round((newCenter.Y - ((double)oldvrdin.Height / 2)) * -1)
                        );

                    vr.SetZoom(newZoom);

                    vr.SetXOffset(newOffset.X);
                    vr.SetYOffset(newOffset.Y);
                }
            }

            this.
            IO.RenderDisplay();
        }
        /// <summary>
        /// Set the Zooms factor of the view to the given factor.
        /// </summary>
        /// <param name="vr">The view to change the zoom factor.</param>
        /// <param name="factor">The new zoom-factor.</param>
        /// <param name="render">if set to <c>true</c> a new rendering is forced.</param>
        /// <returns>
        ///   <c>true</c> if the zoom factor of the view was changed successfully.
        /// </returns>
        /// <exception cref="System.ArgumentException">Zoom-factor must be not 0! - factor</exception>
        /// <remarks>
        /// Views will change their presentation only after calling <see cref="BrailleIOMediator.Instance.RenderDisplay()" />.
        /// Call the <c>RenderDisplay()</c> function after you have done all your changes to see the results.
        /// </remarks>
        public static bool ZoomTo(BrailleIOViewRange vr, double factor, bool render = false)
        {
            if (factor == 0.0)
            {
                throw new ArgumentException("Zoom-factor must be not 0!", "factor");
            }

            if (vr != null)
            {
                var   oldZoom   = vr.GetZoom();
                var   newZoom   = factor;
                var   oldvrdin  = vr.ViewBox;
                Point oldcenter = new Point(
                    (int)Math.Round(((double)oldvrdin.Width / 2) + (vr.GetXOffset() * -1)),
                    (int)Math.Round(((double)oldvrdin.Height / 2) + (vr.GetYOffset() * -1))
                    );

                Point newCenter = new Point(
                    (int)Math.Round(oldcenter.X * newZoom / oldZoom),
                    (int)Math.Round(oldcenter.Y * newZoom / oldZoom)
                    );

                Point newOffset = new Point(
                    (int)Math.Round((newCenter.X - ((double)oldvrdin.Width / 2)) * -1),
                    (int)Math.Round((newCenter.Y - ((double)oldvrdin.Height / 2)) * -1)
                    );

                vr.SetZoom(newZoom);

                vr.SetXOffset(newOffset.X);
                vr.SetYOffset(newOffset.Y);

                if (render && BrailleIOMediator.Instance != null)
                {
                    BrailleIOMediator.Instance.RenderDisplay();
                }
                return(oldZoom != vr.GetZoom());
            }
            return(false);
        }
        /// <summary>
        /// Synchronize the zoom and x/y offset of the given view range with that of the center view range of the visible screen.
        /// </summary>
        /// <param name="vr">view range that should be syncronized with visible center</param>
        private void syncViewRangeWithVisibleCenterViewRange(BrailleIOViewRange vr)
        {
            BrailleIOScreen vs = GetVisibleScreen();

            if (!vs.Name.Equals(BS_MINIMAP_NAME))
            {
                BrailleIOViewRange visibleCenterVR = vs.GetViewRange(VR_CENTER_NAME);
                double             zoom            = visibleCenterVR.GetZoom();
                int x = visibleCenterVR.GetXOffset();
                int y = visibleCenterVR.GetYOffset();

                if (visibleCenterVR.ContentHeight <= vr.ContentBox.Height && visibleCenterVR.ContentWidth <= vr.ContentBox.Width)
                {
                    vr.SetZoom(-1); // für Anpassung bei kleinster Zoomstufe
                }
                else
                {
                    vr.SetZoom(zoom);
                }
                vr.SetXOffset(x);
                vr.SetYOffset(y);
            }
        }
        /// <summary>
        /// Zooms the given view range to the new zoom level and calculates the new offset out of the old center position.
        /// </summary>
        /// <param name="vr">view range that should be zoomed</param>
        /// <param name="oldZoom">old zoom of the view range</param>
        /// <param name="newZoom">new zoom</param>
        /// <returns>true, if zoom was successful</returns>
        private bool zoom(BrailleIOViewRange vr, double oldZoom, double newZoom)
        {
            if (vr != null)
            {
                Point oldCenter   = new Point();
                var   oldvrdin    = vr.ContentBox;
                bool  zoomToShape = false;
                Point oldOffset   = new Point(vr.GetXOffset(), vr.GetYOffset());

                // Prüfung auf größte Zoomstufe
                if (newZoom > vr.MAX_ZOOM_LEVEL)
                {
                    if (oldZoom == vr.MAX_ZOOM_LEVEL)
                    {
                        return(false);
                    }
                    newZoom = vr.MAX_ZOOM_LEVEL;
                }
                // Prüfung auf kleinste Zoomstufe
                if (vr.ContentBox.Height >= vr.ContentHeight && vr.ContentBox.Width >= vr.ContentWidth)
                {
                    if (oldZoom >= newZoom)
                    {
                        return(false);
                    }

                    oldCenter = Point.Empty;
                    // central point of focused element as center for zooming
                    if (OoConnector.Instance != null && OoConnector.Instance.Observer != null)
                    {
                        OoShapeObserver shape = OoConnector.Instance.Observer.GetLastSelectedShape();
                        if (shape != null)
                        {
                            Rectangle shapeBoundingbox = shape.GetRelativeScreenBoundsByDom();
                            if (shapeBoundingbox != null)
                            {
                                // calculate shape position and size in pins (relative to document boundings on pin device)
                                Point shapePosition = new Point((int)Math.Round(shapeBoundingbox.X * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Y * vr.GetZoom()));
                                Size  shapeSize     = new Size((int)Math.Round(shapeBoundingbox.Width * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Height * vr.GetZoom()));
                                Point shapeCenter   = new Point(shapePosition.X + shapeSize.Width / 2, shapePosition.Y + shapeSize.Height / 2);
                                oldCenter = new Point(shapeCenter.X, shapeCenter.Y);
                            }
                        }
                    }

                    if (oldCenter != Point.Empty)
                    {
                        zoomToShape = true;
                    }
                    else
                    {
                        oldCenter = new Point(
                            (int)Math.Round(((double)vr.ContentWidth / 2) + (vr.GetXOffset() * -1)),
                            (int)Math.Round(((double)vr.ContentHeight / 2) + (vr.GetYOffset() * -1))
                            );
                    }
                }
                else
                {
                    oldCenter = Point.Empty;
                    // central point of focused element as center for zooming
                    if (OoConnector.Instance != null && OoConnector.Instance.Observer != null)
                    {
                        OoShapeObserver shape = OoConnector.Instance.Observer.GetLastSelectedShape();
                        if (shape != null)
                        {
                            Rectangle shapeBoundingbox = shape.GetRelativeScreenBoundsByDom();
                            if (shapeBoundingbox != null)
                            {
                                // calculate shape position and size in pins (relative to document boundings on pin device)
                                Point shapePosition = new Point((int)Math.Round(shapeBoundingbox.X * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Y * vr.GetZoom()));
                                Size  shapeSize     = new Size((int)Math.Round(shapeBoundingbox.Width * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Height * vr.GetZoom()));
                                Point shapeCenter   = new Point(shapePosition.X + shapeSize.Width / 2, shapePosition.Y + shapeSize.Height / 2);
                                oldCenter = new Point(shapeCenter.X, shapeCenter.Y);
                            }
                        }
                    }

                    if (oldCenter != Point.Empty)
                    {
                        zoomToShape = true;
                    }
                    else
                    {
                        // central point of center region as center for zooming
                        oldCenter = new Point(
                            (int)Math.Round(((double)oldvrdin.Width / 2) + (vr.GetXOffset() * -1)),
                            (int)Math.Round(((double)oldvrdin.Height / 2) + (vr.GetYOffset() * -1))
                            );
                    }
                }


                double zoomDivRatio = newZoom / oldZoom;

                if (newZoom > 0 && (vr.ContentBox.Height <= vr.ContentHeight * zoomDivRatio || vr.ContentBox.Width <= vr.ContentWidth * zoomDivRatio))
                {
                    Point newCenter = new Point(
                        (int)Math.Round(oldCenter.X * zoomDivRatio),
                        (int)Math.Round(oldCenter.Y * zoomDivRatio)
                        );

                    Point newOffset = new Point();
                    if (zoomToShape)
                    {
                        newOffset = new Point(oldOffset.X + (oldCenter.X - newCenter.X), oldOffset.Y + (oldCenter.Y - newCenter.Y));
                    }
                    else
                    {
                        newOffset = new Point(
                            (int)Math.Round((newCenter.X - ((double)oldvrdin.Width / 2)) * -1),
                            (int)Math.Round((newCenter.Y - ((double)oldvrdin.Height / 2)) * -1)
                            );
                    }

                    vr.SetZoom(newZoom);
                    vr.MoveTo(new Point(Math.Min(newOffset.X, 0), Math.Min(newOffset.Y, 0)));
                }
                else // set to smallest zoom level
                {
                    vr.SetZoom(-1);
                    vr.SetXOffset(0);
                    vr.SetYOffset(0);
                }

                // check for correct panning
                if (vr.GetXOffset() > 0)
                {
                    vr.SetXOffset(0);
                }
                if (vr.GetYOffset() > 0)
                {
                    vr.SetYOffset(0);
                }

                if ((vr.ContentWidth + vr.GetXOffset()) < vr.ContentBox.Width)
                {
                    int maxOffset = Math.Min(0, vr.ContentBox.Width - vr.ContentWidth);
                    vr.SetXOffset(maxOffset);
                }

                if ((vr.ContentHeight + vr.GetYOffset()) < vr.ContentBox.Height)
                {
                    int maxOffset = Math.Min(0, vr.ContentBox.Height - vr.ContentHeight);
                    vr.SetYOffset(maxOffset);
                }

                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Synchronize the zoom and x/y offset of the given view range with that of the center view range of the visible screen.
        /// </summary>
        /// <param name="vr">view range that should be syncronized with visible center</param>
        private void syncViewRangeWithVisibleCenterViewRange(BrailleIOViewRange vr)
        {
            BrailleIOScreen vs = GetVisibleScreen();
            if (!vs.Name.Equals(BS_MINIMAP_NAME))
            {
                BrailleIOViewRange visibleCenterVR = vs.GetViewRange(VR_CENTER_NAME);
                double zoom = visibleCenterVR.GetZoom();
                int x = visibleCenterVR.GetXOffset();
                int y = visibleCenterVR.GetYOffset();

                if (visibleCenterVR.ContentHeight <= vr.ContentBox.Height && visibleCenterVR.ContentWidth <= vr.ContentBox.Width)
                {
                    vr.SetZoom(-1); // für Anpassung bei kleinster Zoomstufe
                }
                else vr.SetZoom(zoom);
                vr.SetXOffset(x);
                vr.SetYOffset(y);
            }
        }
Example #10
0
        private bool[,] RenderTextBox(IViewBoxModel view, UiElement textBoxContent)
        {
            bool[,] viewMatrix;
            if (textBoxContent.isDisabled)
            {
                viewMatrix = Helper.createBoxDeaktivatedUpDown(view.ViewBox.Height, view.ViewBox.Width);
            }
            else
            {
                viewMatrix = Helper.createBox(view.ViewBox.Height, view.ViewBox.Width); //erstmal eine eckige Matrix
            }

            //Ecke links oben abrunden
            Debug.Print(viewMatrix.GetLength(0).ToString());
            Debug.Print(viewMatrix.GetLength(1).ToString());
            if (viewMatrix.GetLength(0) <= 0 || viewMatrix.GetLength(1) <= 0)
            {
                return(new bool[0, 0]);
            }
            viewMatrix[0, 0] = false;
            if (viewMatrix.GetLength(1) > 1)
            {
                viewMatrix[1, 0] = false;
            }
            if (viewMatrix.GetLength(0) > 1)
            {
                viewMatrix[0, 1] = false;
            }
            if (viewMatrix.GetLength(0) > 1 && viewMatrix.GetLength(1) > 1)
            {
                viewMatrix[1, 1] = true;
            }

            BrailleIOViewRange tmpBoxView = new BrailleIOViewRange(view.ViewBox.Left, view.ViewBox.Top, view.ViewBox.Width, view.ViewBox.Height);

            tmpBoxView.Name = "_B_" + textBoxContent.screenName + view.ViewBox.Left + view.ViewBox.Top + view.ViewBox.Width + view.ViewBox.Height;
            // tmpBoxView.SetText(textBoxText);
            tmpBoxView.SetMatrix(viewMatrix);
            // tmpBoxView.ShowScrollbars = true;
            tmpBoxView.SetYOffset(0);
            tmpBoxView.SetZIndex(2);

            object        cM       = textBoxContent.text as object;
            IViewBoxModel tmpModel = tmpBoxView as IViewBoxModel;

            callAllPreHooks(ref tmpModel, ref cM);
            tmpBoxView = tmpBoxView as BrailleIOViewRange;
            BrailleIOMediator brailleIOMediator = BrailleIOMediator.Instance;
            BrailleIOScreen   screen            = (BrailleIOScreen)brailleIOMediator.GetView(textBoxContent.screenName);

            if (screen != null)
            {
                BrailleIOViewRange viewRange = screen.GetViewRange(tmpBoxView.Name);
                if (viewRange == null)
                {
                    ((BrailleIOScreen)brailleIOMediator.GetView(textBoxContent.screenName)).AddViewRange(tmpBoxView.Name, tmpBoxView);
                }
            }

            callAllPostHooks(tmpBoxView, cM, ref viewMatrix, false);
            return(viewMatrix);
        }
        /// <summary>
        /// Zooms the given view range to the new zoom level and calculates the new offset out of the old center position.
        /// </summary>
        /// <param name="vr">view range that should be zoomed</param>
        /// <param name="oldZoom">old zoom of the view range</param>
        /// <param name="newZoom">new zoom</param>
        /// <returns>true, if zoom was successful</returns>
        private bool zoom(BrailleIOViewRange vr, double oldZoom, double newZoom)
        {
            if (vr != null)
            {
                Point oldCenter = new Point();
                var oldvrdin = vr.ContentBox;
                bool zoomToShape = false;
                Point oldOffset = new Point(vr.GetXOffset(), vr.GetYOffset());

                // Prüfung auf größte Zoomstufe
                if (newZoom > vr.MAX_ZOOM_LEVEL)
                {
                    if (oldZoom == vr.MAX_ZOOM_LEVEL) return false;
                    newZoom = vr.MAX_ZOOM_LEVEL;
                }
                // Prüfung auf kleinste Zoomstufe
                if (vr.ContentBox.Height >= vr.ContentHeight && vr.ContentBox.Width >= vr.ContentWidth)
                {
                    if (oldZoom >= newZoom) return false;
                    
                    oldCenter = Point.Empty;
                    // central point of focused element as center for zooming
                    if (OoConnector.Instance != null && OoConnector.Instance.Observer != null)
                    {
                        OoShapeObserver shape = OoConnector.Instance.Observer.GetLastSelectedShape();
                        if (shape != null)
                        {
                            Rectangle shapeBoundingbox = shape.GetRelativeScreenBoundsByDom();
                            if (shapeBoundingbox != null)
                            {
                                // calculate shape position and size in pins (relative to document boundings on pin device)
                                Point shapePosition = new Point((int)Math.Round(shapeBoundingbox.X * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Y * vr.GetZoom()));
                                Size shapeSize = new Size((int)Math.Round(shapeBoundingbox.Width * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Height * vr.GetZoom()));
                                Point shapeCenter = new Point(shapePosition.X + shapeSize.Width / 2, shapePosition.Y + shapeSize.Height / 2);
                                oldCenter = new Point(shapeCenter.X, shapeCenter.Y);
                            }
                        }
                    }

                    if (oldCenter != Point.Empty) zoomToShape = true;
                    else
                    {
                        oldCenter = new Point(
                            (int)Math.Round(((double)vr.ContentWidth / 2) + (vr.GetXOffset() * -1)),
                            (int)Math.Round(((double)vr.ContentHeight / 2) + (vr.GetYOffset() * -1))
                        );
                    }
                }
                else
                {
                    oldCenter = Point.Empty;
                    // central point of focused element as center for zooming
                    if (OoConnector.Instance != null && OoConnector.Instance.Observer != null)
                    {
                        OoShapeObserver shape = OoConnector.Instance.Observer.GetLastSelectedShape();
                        if (shape != null)
                        {
                            Rectangle shapeBoundingbox = shape.GetRelativeScreenBoundsByDom();
                            if (shapeBoundingbox != null)
                            {
                                // calculate shape position and size in pins (relative to document boundings on pin device)
                                Point shapePosition = new Point((int)Math.Round(shapeBoundingbox.X * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Y * vr.GetZoom()));
                                Size shapeSize = new Size((int)Math.Round(shapeBoundingbox.Width * vr.GetZoom()), (int)Math.Round(shapeBoundingbox.Height * vr.GetZoom()));
                                Point shapeCenter = new Point(shapePosition.X + shapeSize.Width / 2, shapePosition.Y + shapeSize.Height / 2);
                                oldCenter = new Point(shapeCenter.X, shapeCenter.Y);
                            }
                        }
                    }

                    if (oldCenter != Point.Empty) zoomToShape = true;
                    else
                    {
                        // central point of center region as center for zooming
                        oldCenter = new Point(
                            (int)Math.Round(((double)oldvrdin.Width / 2) + (vr.GetXOffset() * -1)),
                            (int)Math.Round(((double)oldvrdin.Height / 2) + (vr.GetYOffset() * -1))
                            );
                    }
                }

                if (newZoom > 0)
                {
                    double zoomRatio = newZoom / oldZoom;
                    Point newCenter = new Point(
                        (int)Math.Round(oldCenter.X * zoomRatio),
                        (int)Math.Round(oldCenter.Y * zoomRatio)
                        );

                    Point newOffset = new Point();
                    if (zoomToShape)
                    {
                        newOffset = new Point(oldOffset.X + (oldCenter.X - newCenter.X), oldOffset.Y + (oldCenter.Y - newCenter.Y));
                    }
                    else
                    {
                        newOffset = new Point(
                            (int)Math.Round((newCenter.X - ((double)oldvrdin.Width / 2)) * -1),
                            (int)Math.Round((newCenter.Y - ((double)oldvrdin.Height / 2)) * -1)
                            );
                    }

                    vr.SetZoom(newZoom);
                    vr.MoveTo(new Point(Math.Min(newOffset.X, 0), Math.Min(newOffset.Y, 0)));
                }
                else // set to smallest zoom level
                {
                    vr.SetZoom(-1);
                    vr.SetXOffset(0);
                    vr.SetYOffset(0);
                }

                // check for correct panning
                if (vr.GetXOffset() > 0) { vr.SetXOffset(0); }
                if (vr.GetYOffset() > 0) { vr.SetYOffset(0); }

                if ((vr.ContentWidth + vr.GetXOffset()) < vr.ContentBox.Width)
                {
                    int maxOffset = Math.Min(0, vr.ContentBox.Width - vr.ContentWidth);
                    vr.SetXOffset(maxOffset);
                }

                if ((vr.ContentHeight + vr.GetYOffset()) < vr.ContentBox.Height)
                {
                    int maxOffset = Math.Min(0, vr.ContentBox.Height - vr.ContentHeight);
                    vr.SetYOffset(maxOffset);
                }

                return true;
            }
            return false;
        }
 /// <summary>
 /// Set offset position of view range to given position.
 /// </summary>
 /// <param name="vr">View range to set new offset.</param>
 /// <param name="y_pos">new offset position.</param>
 private void scrollViewRangeTo(BrailleIOViewRange vr, int y_pos)
 {
     if (vr != null && y_pos <= 0)
     {
         if (y_pos >= (vr.ContentBox.Height - vr.ContentHeight)) vr.SetYOffset(y_pos);
         else vr.SetYOffset(0);
     }
 }
 /// <summary>
 /// Add the given scroll step to the current offset position of view range to realize a scrolling.
 /// </summary>
 /// <param name="vr">View range to scroll.</param>
 /// <param name="scrollStep">Steps to scroll the view range.</param>
 private bool scrollViewRange(BrailleIOViewRange vr, int scrollStep)
 {
     if (vr != null)
     {
         int newPos = vr.OffsetPosition.Y + scrollStep;
         if (newPos <= 0 && newPos >= (vr.ContentBox.Height - vr.ContentHeight))
         {
             vr.SetYOffset(newPos);
             return true;
         }
     }
     return false;
 }
 private void jumpToTopBorder(BrailleIOViewRange center)
 {
     if (center != null)
     {
         center.SetYOffset(0);
         io.RefreshDisplay();
         audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.jump.up"));
         Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] jump to top");
     }
 }
 private void jumpToBottomBorder(BrailleIOViewRange center)
 {
     if (center != null)
     {
         int offset = center.ContentHeight - center.ContentBox.Height;
         center.SetYOffset(-offset);
         io.RefreshDisplay();
         audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.panning.jump.down"));
         Logger.Instance.Log(LogPriority.MIDDLE, this, "[INTERACTION] jump to bottom");
     }
 }
 /// <summary>
 /// Add the given scroll step to the current offset position of view range to realize a scrolling.
 /// </summary>
 /// <param name="vr">View range to scroll.</param>
 /// <param name="scrollStep">Steps to scroll the view range.</param>
 private void scrollViewRange(BrailleIOViewRange vr, int scrollStep)
 {
     if (vr != null)
     {
         int newPos = vr.OffsetPosition.Y + scrollStep;
         if (newPos <= 0 && newPos >= (vr.ContentBox.Height - vr.ContentHeight)) vr.SetYOffset(newPos);
     }
 }