Thumbnail viewer navigation

Discussions about document viewing.
Post Reply
jradic
Posts: 3
Joined: Thu Nov 24, 2016 10:52 am

Thumbnail viewer navigation

Post by jradic » Thu Nov 24, 2016 11:02 am

Hi,

We have following requirement regarding thumbnail viewer. We have document with 9 pages and when this document is displayed inside thumbnail viewer it generates 3 rows and 3 columns images We would like, after selecting first image in thumbnail control, to move along other images using only Right arrow keyboard button. So the order of selecting images using only Right arrow keyboard should be (1,2,3) then move on to second row (4,5,6) and then move on to third row (6,7,8).
Is this possible?

Best regards
Josko

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Thumbnail viewer navigation

Post by Cedric » Thu Nov 24, 2016 1:15 pm

I think the most easiest way to do this would be to capture the keystrokes for left and right arrow keys and do something like this:

Code: Select all

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
	if (keyData == Keys.Left)
	{
		if (GetSelectedItemIdx() - 1 < 0)
		{
			ThumbnailEx1.SelectItem(0);
		}
		else
		{
			ThumbnailEx1.SelectItem(GetSelectedItemIdx() - 1);
		}
		return true;
	}
	if (keyData == Keys.Right)
	{
		if (GetSelectedItemIdx() + 1 > ThumbnailEx1.ItemCount)
		{
			ThumbnailEx1.SelectItem(ThumbnailEx1.ItemCount - 1);
		}
		else
		{
			ThumbnailEx1.SelectItem(GetSelectedItemIdx() + 1);
		}
		return true;
	}
	return base.ProcessCmdKey(ref msg, keyData);
}

private int GetSelectedItemIdx()
{
	for (int i = 0; i < ThumbnailEx1.ItemCount; i++)
	{
		if (ThumbnailEx1.GetItemSelectState(i))
		{
			return i;
		}
	}
	return 0;
}

jradic
Posts: 3
Joined: Thu Nov 24, 2016 10:52 am

Re: Thumbnail viewer navigation

Post by jradic » Thu Nov 24, 2016 1:43 pm

Hi Cedric,

Thank you for the quick response. I will give it a try and let you know.

Best regards
Josko

jradic
Posts: 3
Joined: Thu Nov 24, 2016 10:52 am

Re: Thumbnail viewer navigation

Post by jradic » Fri Nov 25, 2016 10:40 am

Hi Cedric,

Based on your input I have managed to alter navigation of thumbnail control in regards to left and light arrow keys. I did not override ProcessCmdKey but subscribed to the KeyUp and KeyDown events of ThumbnailEx control.
But now navigation using up and down arrow keys is messed up. I have attached a small sample project. Can you have a look?

Best regards
Josko
Attachments
ThumbnailDemo.zip
(41.9 KiB) Downloaded 368 times

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Thumbnail viewer navigation

Post by Cedric » Mon Nov 28, 2016 12:42 pm

Unfortunately I'm not familiar enough with WPF to determine the exact source of the issue here but I suspect it is because of the WPF/WinForm mix together with trying to change the default behavior.
One possible option would be to implement up and down keys behavior the same it is done for left and right keys (I didn't try though so it might have other impact I don't know about). Another possible option would be to update to GdPicture.NET 12 because it now contains native WPF controls (starting with GdPicture.NET 11) so it might be easier to integrate in a WPF application.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest