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

Notification

Icon
Error

Options
Go to last post Go to first unread
JayR  
#1 Posted : Monday, April 19, 2021 3:45:38 PM(UTC)
JayR

Rank: Newbie

Groups: Registered
Joined: 10/16/2019(UTC)
Posts: 2

I would like to use the PdfViewer in one of the tiled views but allow the user to select multiple pages (and of course be able to determine which page(s) were selected).

I checked the control's properties and these forums for a hint on how to do this but found nothing. Can this be done?

Thanks
-Jay
Paul Rayman  
#2 Posted : Monday, April 19, 2021 5:37:49 PM(UTC)
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Hello,

You can easily implement such functionality.

Code:

public class MyPdfViewer : PdfViewer
{
    private Dictionary<int, int> _mySelecedPages = new Dictionary<int, int>();
    private Pen _pen = new Pen(Brushes.Red, 4);

    protected override void OnMouseDown(MouseEventArgs e)
    {
        base.OnMouseDown(e);

        if (!ModifierKeys.HasFlag(Keys.Control))
            _mySelecedPages.Clear();

        int pageIdx = this.PointInPage(e.Location);
        if (pageIdx >= 0)
            _mySelecedPages[pageIdx] = 1;
        else
            _mySelecedPages.Clear();

        Invalidate();
    }

    protected override void DrawCurrentPageHighlight(Graphics graphics, int pageIndex, Rectangle actualRect)
    {
        if (ShowCurrentPageHighlight && _mySelecedPages.ContainsKey(pageIndex))
            graphics.DrawRectangle(_pen, actualRect);
            
    }
}

Edited by user Monday, April 19, 2021 5:43:18 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest
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.