Method SetContinuousScrollMode
SetContinuousScrollMode(Int32, Int32, Int32, Int32, String, Int32, Int32)
Sets the device to the continuous scroll mode.
Declaration
Error SetContinuousScrollMode(int numberOfPages, int numberOfTiles, int startTileNumber, int startTileOffset, string buttonText, int tileWidth, int tileHeight = 702)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfPages | The number of pages of the document. |
System.Int32 | numberOfTiles | The number of tiles the document is to be split up into. |
System.Int32 | startTileNumber | This tile number is requested first. |
System.Int32 | startTileOffset | Scrolls the first tile down. |
System.String | buttonText | The text inside the button. |
System.Int32 | tileWidth | The width of a tile /pixels. Recommended width: 992. |
System.Int32 | tileHeight | The height of a tile /pixels. Recommended height: 702. |
Returns
Type | Description |
---|---|
Error | Error |
Remarks
The continuous scroll mode is used for viewing multipage documents split up into several tiles. These tiles form a vertical stack of the document that can be scrolled with the pen.
When started, the device is requesting tiles through the ScrollEvent.
The device will never request for tile numbers bigger than the total numberOfTiles
.
When one is scrolling fast the device is asking for a tile that corresponds to a page number. Then IsPageNumber is true and you have to determine the corresponding tile number for that page number and set it with
SetContinuousScrollTileNumber(Int32, Int32, Int32).
These tile requests have to be fulfilled by uploading tiles by means of
UploadContinuousScrollTile(Bitmap, Int32, Int32, Int32)
The mode has one button labeled with the buttonText
.
Clicking it triggers a ButtonEvent while
the device shows an hourglass and waits for further commands.
Whether a device supports the continuous scroll feature can be queried with DeviceProperties.IFeatures.ContinuousScrollingSupport.
Examples
The following example initiates the continuous scroll mode with dynamically created tiles which have numbers written in them. The example assumes that each page of the document is composed of two tiles. The button is used for stopping the demonstration.
C#
int numberOfPages = 32;
int numberOfTiles = 2 * numberOfPages;
int startTileNumber = 7;
int width = 992; //recommended
int height = 702; //recommended
int startTileOffset = height / 2;
bool running = true;
driver.ButtonEvent += (object sender, ButtonEventArgs e) =>
{
driver.SetCustomerLogoMode();
running = false;
};
driver.ScrollEvent += (object sender, ScrollEventArgs e) =>
{
int pageNumber, tileNumber;
if (e.IsPageNumber)
{
pageNumber = e.RequestedNumber;
tileNumber = 2 * pageNumber;
driver.SetContinuousScrollTileNumber(tileNumber, numberOfTiles, 0);
return;
}
else
{
tileNumber = e.RequestedNumber;
pageNumber = (tileNumber + tileNumber % 2) / 2;
}
Bitmap bitmap = GetTile(tileNumber, width, height);
driver.UploadContinuousScrollTile(bitmap, tileNumber, pageNumber, numberOfTiles);
};
Error error = driver.SetContinuousScrollMode(numberOfPages, numberOfTiles,
startTileNumber, startTileOffset, "Click to exit.", width);
while (running)
{
Thread.Sleep(500);
}
Bitmap GetTile(int tileNumber, int width, int height)
{
int magicHeight = 702;
float emSize = 16.0f;
Rectangle box = new Rectangle(0, 0, width, height);
Bitmap bitmap = new Bitmap(box.Width, box.Height);
using Graphics g = Graphics.FromImage(bitmap);
g.Clear(Color.White);
g.DrawString($"Tile {tileNumber}.",
new Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
Brushes.Black, new PointF(width / 2, height / 2));
g.DrawRectangle(new Pen(Brushes.Blue, emSize), box);
g.DrawLine(new Pen(Brushes.Red, emSize), 0, magicHeight, width, magicHeight);
return bitmap;
}
A similar program in
VB.NET
Dim running As Boolean = True
Dim numberOfPages As Integer = 32
Dim numberOfTiles As Integer = 2 * numberOfPages
Dim startTileNumber As Integer = 7
Dim width As Integer = 992 'recommended
Dim height As Integer = 702 'recommended
Sub ScrollThroughNumberedTiles()
Dim r As Sig.DeviceAPI.Error
Dim startTileOffset As Integer = height / 2
r = driver.SetContinuousScrollMode(numberOfPages, numberOfTiles,
startTileNumber, startTileOffset, "Click to exit.", width)
While (running)
Thread.Sleep(500)
End While
End Sub
Sub HandleScrollEvent(sender As Object, e As ScrollEventArgs) Handles driver.ScrollEvent
Dim pageNumber, tileNumber As Integer
If (e.IsPageNumber) Then
pageNumber = e.RequestedNumber
tileNumber = 2 * pageNumber
driver.SetContinuousScrollTileNumber(tileNumber, numberOfTiles, 0)
Return
Else
tileNumber = e.RequestedNumber
pageNumber = (tileNumber + tileNumber Mod 2) / 2
End If
driver.UploadContinuousScrollTile(GetTile(tileNumber, width, height), tileNumber, pageNumber, numberOfTiles)
End Sub
Sub HandleButtonEvent(sender As Object, e As ButtonEventArgs) Handles driver.ButtonEvent
driver.SetCustomerLogoMode()
running = False
End Sub
Function GetTile(tileNumber As Integer, width As Integer, height As Integer) As Bitmap
Dim magicHeight As Integer = 702
Dim emSize As Single = 16.0F
Dim box As Rectangle = New Rectangle(0, 0, width, height)
Dim bitmap As Bitmap = New Bitmap(box.Width, box.Height)
Using g As Graphics = Graphics.FromImage(bitmap)
g.Clear(Color.White)
g.DrawString($"Tile {tileNumber}.",
New Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
Brushes.Black, New PointF(width / 2, height / 2))
g.DrawRectangle(New Pen(Brushes.Blue, emSize), box)
g.DrawLine(New Pen(Brushes.Red, emSize), 0, magicHeight, width, magicHeight)
Return bitmap
End Using
End Function