Exemplo n.º 1
0
 private void StartAutoScroll(ScrollDir TheDir)
 {
     this.ActualScrollDir      = TheDir;
     this.ScrollTimer.Interval = 500;             // 750
     if (TheDir == ScrollDir.mouse)
     {
         this.ScrollTimer.Interval = 30;
     }
     this.ScrollTimer.Start();
 }
Exemplo n.º 2
0
    public void ScrollThroughItems(ScrollDir direction)
    {
        if (StoredItems.Count == 0)
        {
            return;
        }

        if (direction == ScrollDir.next)
        {
            numInStoredItems += 1;
        }
        else
        {
            numInStoredItems -= 1;
        }
        numInStoredItems = mod(numInStoredItems, StoredItems.Count);

        ActiveStoredItem = StoredItems[numInStoredItems];
    }
Exemplo n.º 3
0
 /// <summary>
 /// Simulates mouse wheel scrolling.
 /// </summary>
 /// <param name="direction">The direction to scroll.</param>
 public static void Scroll(ScrollDir direction)
 {
     mouse_event((int)MouseEvents.Scroll, 0, 0, (int)direction, IntPtr.Zero);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Simulates mouse wheel scrolling.
 /// </summary>
 /// <param name="direction">The direction to scroll.</param>
 public static void Scroll(ScrollDir direction)
 {
   mouse_event((int) MouseEvents.Scroll, 0, 0, (int) direction, IntPtr.Zero);
 }
        /**
         * Move to the given X and Y offsets, but check them ahead of time
         * to be sure not to go outside the the big strip.
         *
         * @param offsetX    The big strip X offset to use as the left border of the screen.
         * @param offsetY    The big strip Y offset to use as the right border of the screen.
         * @param moveHandle whether to move scroll handle or not
         */
        public void MoveTo(float offsetX, float offsetY, bool moveHandle)
        {
            if (IsSwipeVertical)
            {
                // Check X offset
                var scaledPageWidth = ToCurrentScale(PdfFile.MaxPageWidth);
                if (scaledPageWidth < Width)
                {
                    offsetX = Width / 2 - scaledPageWidth / 2;
                }
                else
                {
                    if (offsetX > 0)
                    {
                        offsetX = 0;
                    }
                    else if (offsetX + scaledPageWidth < Width)
                    {
                        offsetX = Width - scaledPageWidth;
                    }
                }

                // Check Y offset
                var contentHeight = PdfFile.GetDocLen(Zoom);
                if (contentHeight < Height)
                {
                    // whole document height visible on screen
                    offsetY = (Height - contentHeight) / 2;
                }
                else
                {
                    if (offsetY > 0)
                    {
                        // top visible
                        offsetY = 0;
                    }
                    else if (offsetY + contentHeight < Height)
                    {
                        // bottom visible
                        offsetY = -contentHeight + Height;
                    }
                }

                if (offsetY < CurrentYOffset)
                {
                    scrollDir = ScrollDir.End;
                }
                else if (offsetY > CurrentYOffset)
                {
                    scrollDir = ScrollDir.Start;
                }
                else
                {
                    scrollDir = ScrollDir.None;
                }
            }
            else
            {
                // Check Y offset
                var scaledPageHeight = ToCurrentScale(PdfFile.MaxPageHeight);
                if (scaledPageHeight < Height)
                {
                    offsetY = Height / 2 - scaledPageHeight / 2;
                }
                else
                {
                    if (offsetY > 0)
                    {
                        offsetY = 0;
                    }
                    else if (offsetY + scaledPageHeight < Height)
                    {
                        offsetY = Height - scaledPageHeight;
                    }
                }

                // Check X offset
                var contentWidth = PdfFile.GetDocLen(Zoom);
                if (contentWidth < Width)
                {
                    // whole document width visible on screen
                    offsetX = (Width - contentWidth) / 2;
                }
                else
                {
                    if (offsetX > 0)
                    {
                        // left visible
                        offsetX = 0;
                    }
                    else if (offsetX + contentWidth < Width)
                    {
                        // right visible
                        offsetX = -contentWidth + Width;
                    }
                }

                if (offsetX < CurrentXOffset)
                {
                    scrollDir = ScrollDir.End;
                }
                else if (offsetX > CurrentXOffset)
                {
                    scrollDir = ScrollDir.Start;
                }
                else
                {
                    scrollDir = ScrollDir.None;
                }
            }

            CurrentXOffset = offsetX;
            CurrentYOffset = offsetY;
            var positionOffset = PositionOffset;

            if (moveHandle && ScrollHandle != null && !DocumentFitsView)
            {
                ScrollHandle.SetScroll(positionOffset);
            }

            Callbacks.CallOnPageScroll(this, new PageScrolledEventArgs(CurrentPage, positionOffset));

            Redraw();
        }
        void VerifyScroll(CmdApp app, ScrollDir dir, int clicks)
        {
            WinCon.CONSOLE_SCREEN_BUFFER_INFO_EX beforeScroll;
            WinCon.CONSOLE_SCREEN_BUFFER_INFO_EX afterScroll;
            int deltaActual;
            int deltaExpected;

            beforeScroll = app.GetScreenBufferInfo();

            switch (dir)
            {
            case ScrollDir.Vertical:
                app.ScrollWindow(clicks);
                break;

            case ScrollDir.Horizontal:
                app.HScrollWindow(clicks);
                break;

            default:
                throw new NotSupportedException();
            }

            // Give the window message a moment to take effect.
            Globals.WaitForTimeout();

            switch (dir)
            {
            case ScrollDir.Vertical:
                deltaExpected = clicks * app.GetRowsPerScroll();
                break;

            case ScrollDir.Horizontal:
                deltaExpected = clicks * app.GetColsPerScroll();
                break;

            default:
                throw new NotSupportedException();
            }

            afterScroll = app.GetScreenBufferInfo();

            switch (dir)
            {
            case ScrollDir.Vertical:
                // Scrolling "negative" vertically is pulling the wheel downward which makes the lines move down.
                // This means that if you scroll down from the top, before = 0 and after = 3. 0 - 3 = -3.
                // The - sign of the delta here then aligns with the down = negative rule.
                deltaActual = beforeScroll.srWindow.Top - afterScroll.srWindow.Top;
                break;

            case ScrollDir.Horizontal:
                // Scrolling "negative" horizontally is pushing the wheel left which makes lines move left.
                // This means that if you scroll left, before = 3 and after = 0. 0 - 3 = -3.
                // The - sign of the delta here then aligns with the left = negative rule.
                deltaActual = afterScroll.srWindow.Left - beforeScroll.srWindow.Left;
                break;

            default:
                throw new NotSupportedException();
            }

            Verify.AreEqual(deltaExpected, deltaActual);
        }
Exemplo n.º 7
0
 private void StopAutoScroll()
 {
     this.ScrollTimer.Stop();
     this.ActualScrollDir = ScrollDir.none;
 }