logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
frogcafe  
#1 Posted : Monday, March 14, 2016 5:14:32 PM(UTC)
frogcafe

Rank: Newbie

Groups: Registered
Joined: 3/14/2016(UTC)
Posts: 4

Thanks: 2 times
May I know how to turn on "touch pinch gesture" on the viewer and also allow "Ctrl" key + mouse wheel for zooming?

Edited by user Monday, March 14, 2016 5:50:27 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Tuesday, March 15, 2016 12:48:38 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,094

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
To implement the Zoom with Ctrl+MouseWeel you can create derived class like shown below.
Please note, the PdfViewer.SizeMode should be set to SizeModes.Zoom.

Code:

public class MyPdfViewer : PdfViewer
{
	private float _maxPageSize = 0;
	protected override void OnDocumentLoaded(EventArgs e)
	{
		foreach(var p in Document.Pages)
		{
			if (p.Width > _maxPageSize)
				_maxPageSize = p.Width;
			if (p.Height > _maxPageSize)
				_maxPageSize = p.Height;
		}
		base.OnDocumentLoaded(e);
		SizeMode = SizeModes.Zoom;
		Zoom = 1;
	}

	protected override void OnMouseWheel(MouseEventArgs e)
	{
		if ((ModifierKeys & Keys.Control) == Keys.Control)
		{
			float newZoom = Zoom;
			if (e.Delta < 0)
				newZoom *= 0.9f;
			else
				newZoom /= 0.9f;

			if (_maxPageSize * newZoom >100 &&_maxPageSize * newZoom < 5000)
				Zoom = newZoom;

		}
		else
			base.OnMouseWheel(e);
	}
}


To implement touch pinch gesture you can use the same technique.

Edited by user Tuesday, March 15, 2016 1:04:53 AM(UTC)  | Reason: Not specified

frogcafe  
#3 Posted : Tuesday, March 15, 2016 1:22:40 PM(UTC)
frogcafe

Rank: Newbie

Groups: Registered
Joined: 3/14/2016(UTC)
Posts: 4

Thanks: 2 times
If PdfViewer.SizeModes is set to SizeModes.Zoom, the web link will not be clickable. I used Pdfium (not .Net SDK) PdfRenderer to display PDF, it allows Ctrl-MouseWheel as well as clickable web link. Will it be any workaround way?
Paul Rayman  
#4 Posted : Tuesday, March 15, 2016 6:21:09 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,094

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
I am checked it - everything works fine. The WebLinks and PdfLinks are clickable in a Zoom size mode.

What do you mean then talking "PdfRenderer to display PDF"? Pdfium does not have anything called "PdfRenderer"
thanks 1 user thanked Paul Rayman for this useful post.
frogcafe on 3/16/2016(UTC)
frogcafe  
#5 Posted : Wednesday, March 16, 2016 4:22:30 AM(UTC)
frogcafe

Rank: Newbie

Groups: Registered
Joined: 3/14/2016(UTC)
Posts: 4

Thanks: 2 times
  1. Because I tried using Zoom size but not clickable, I'll check it out with your code.
  2. PdfRenderer


Thx

Edited by user Wednesday, March 16, 2016 4:23:53 AM(UTC)  | Reason: Not specified

apostol.bakalov  
#6 Posted : Monday, October 3, 2022 11:09:24 AM(UTC)
apostol.bakalov

Rank: Newbie

Groups: Registered
Joined: 11/28/2019(UTC)
Posts: 5
Man
Bulgaria

Hello,

Would it be possible to share a sample for pinch zoom for touch screens?
The pinch gestures work great with the touchpad of the laptop, but I have not had much luck to get it to work with touch screens.

I have tried using the touch events, but I am not sure I get all the pertinent information.

Best regards,
Apostol Bakalov

Originally Posted by: Paul Rayman Go to Quoted Post
To implement the Zoom with Ctrl+MouseWeel you can create derived class like shown below.
Please note, the PdfViewer.SizeMode should be set to SizeModes.Zoom.

Code:

public class MyPdfViewer : PdfViewer
{
	private float _maxPageSize = 0;
	protected override void OnDocumentLoaded(EventArgs e)
	{
		foreach(var p in Document.Pages)
		{
			if (p.Width > _maxPageSize)
				_maxPageSize = p.Width;
			if (p.Height > _maxPageSize)
				_maxPageSize = p.Height;
		}
		base.OnDocumentLoaded(e);
		SizeMode = SizeModes.Zoom;
		Zoom = 1;
	}

	protected override void OnMouseWheel(MouseEventArgs e)
	{
		if ((ModifierKeys & Keys.Control) == Keys.Control)
		{
			float newZoom = Zoom;
			if (e.Delta < 0)
				newZoom *= 0.9f;
			else
				newZoom /= 0.9f;

			if (_maxPageSize * newZoom >100 &&_maxPageSize * newZoom < 5000)
				Zoom = newZoom;

		}
		else
			base.OnMouseWheel(e);
	}
}


To implement touch pinch gesture you can use the same technique.


Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.