예제 #1
0
        private void MouseWheelHandler(Event e)
        {
            IViewport vp = Viewport;

            if (e.DefaultPrevented || null == vp || !vp.Visible)
            {
                return;
            }

            //Debug.Log("HScrollBar MouseWheelHandler");

            MouseEvent me     = (MouseEvent)e;
            var        delta  = me.CurrentEvent.delta.y;
            int        nSteps = (int)Math.Abs(delta);

            nSteps = 1; // TEMP

            // Scroll event.delta "steps".
            //Debug.Log("delta: " + delta);
            NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Right : NavigationUnit.Left;

            for (int hStep = 0; hStep < nSteps; hStep++)
            {
                float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                //if (null != hspDelta)
                vp.HorizontalScrollPosition += hspDelta;
            }

            e.PreventDefault();
        }
예제 #2
0
        private void SkinMouseWheelHandler(Event e)
        {
            MouseEvent me = (MouseEvent)e;
            IViewport  vp = Viewport;

            if (e.DefaultPrevented || null == vp || !vp.Visible)
            {
                return;
            }

            var            delta  = me.CurrentEvent.delta.y;
            int            nSteps = (int)Math.Abs(delta);
            NavigationUnit navigationUnit;

            // Scroll event.delta "steps".  If the VSB is up, scroll vertically,
            // if -only- the HSB is up then scroll horizontally.

            if (null != VerticalScrollBar && VerticalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Down : NavigationUnit.Up;
                for (int vStep = 0; vStep < nSteps; vStep++)
                {
                    float?vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit);
                    //if (null != vspDelta)
                    vp.VerticalScrollPosition += (float)vspDelta;
                }
                e.PreventDefault();
            }
            else if (null != HorizontalScrollBar && HorizontalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Right : NavigationUnit.Left;
                for (int hStep = 0; hStep < nSteps; hStep++)
                {
                    float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                    //if (null != hspDelta)
                    vp.HorizontalScrollPosition += hspDelta;
                }
                e.PreventDefault();
            }
        }