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

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Tuesday, August 16, 2016 5:03:46 PM(UTC)
 
Hi,

You can easily implement this behaviour by self.
To do that you should create a derived class from PdfViewer and write the following code.

Code:

public class MyPdfViewer : PdfViewer
{
	//List containing the indices of the selected pages
	private List<int> _selectedPages = new List<int>();

	//Overrides the mouse down behaviour
	protected override void OnMouseDown(MouseEventArgs e)
	{
		try
		{
			//Determines the page to the mouse coordinates
			int pageIndex = this.PointInPage(e.Location);
			if (pageIndex < 0)
			{
				//If click outside the page, but in the viewer, then deselect all pages
				_selectedPages.Clear();
				Invalidate();
				return;
			}

			//if click inside selected page then do nothing
			if (_selectedPages.Contains(pageIndex))
				return;

			//Add a new page into list of selected pages and invalidate the PdfViewer
			_selectedPages.Add(pageIndex);
			Invalidate();
		}
		finally
		{
			//Execute the base behaviour
			base.OnMouseDown(e);
		}
	}

	//Overrides the drawing of current page highlight
	protected override void DrawCurrentPageHighlight(Graphics graphics, int pageIndex, Rectangle actualRect)
	{
		if (_selectedPages.Contains(pageIndex))
		{
			//if pageIndex inside a list of selected page, then highlight the border
			using (var pen = new Pen(this.CurrentPageHighlightColor, 8))
			{
				actualRect.Inflate(0, 0);
				var sm = graphics.SmoothingMode;
				graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
				graphics.DrawRectangle(pen, actualRect);
				graphics.SmoothingMode = sm;
			}
		}
	}
}
Guest Posted: Tuesday, August 16, 2016 2:52:40 AM(UTC)
 
Hello,

how can i enable multiselect for pages in the winform PDF viewer control?

f.e. the user should be able to select one or more pages to be deleted.

If the multiselect pages feature is not available is it possible to implement that?


Thanks in advance