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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
matt.smokeball  
#1 Posted : Monday, April 16, 2018 5:06:21 PM(UTC)
Quote
matt.smokeball

Rank: Member

Groups: Registered
Joined: 4/15/2018(UTC)
Posts: 24
Man
Australia
Location: Sydney

Thanks: 2 times
Hi

I'm currently running an eval on the WPF product for some POC.

Part of the requirement I have is to be able to change the background color of the selected field/control, so it's more easily visible to the user. The properties on the control object are all read only. Is there anyway to do this using the viewer or code?

Also, it seems that when tabbing through the fields, it will go back to the top of the page when tabbing from the last field on the page. Is there anyway to make it to to the first field on the next page instead?



Thanks

Edited by user Monday, April 16, 2018 9:08:25 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Monday, April 16, 2018 11:02:57 PM(UTC)
Quote
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)
To change highlight color of the all fields you may use PdfViewer.FormHighlightColor Property
Code:

FormHighlightColor = Color.FromArgb(25, 255, 0, 0);


If you want to highlight separate field you may try the following
1. Create derived class based on PdfViewer
2. Override one of the drawing methods - DrawCurrentPageHighlight for example
3. Override OnFormsInvalidate method
4. Store the area marked to painting (invalidate area)
5. Highlight that area at the drawing stage

Code:

public class MyPdfViewer : PdfViewer
{
    protected override void OnInitialized(EventArgs e)
    {
        base.OnInitialized(e);

        FormHighlightColor = Color.FromArgb(25, 255, 0, 0);
    }

    internal static int ToArgb(Color color)
    {
        return (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B;
    }

    private FS_RECTF _invalidateRect = default(FS_RECTF);
    protected override void OnFormsInvalidate(InvalidatePageEventArgs e)
    {
        base.OnFormsInvalidate(e);
        _invalidateRect = e.Rect;
    }

    protected override void DrawCurrentPageHighlight(DrawingContext drawingContext, int pageIndex, Rect actualRect)
    {
        base.DrawCurrentPageHighlight(drawingContext, pageIndex, actualRect);

        var ptTopLeft = PageToClient(pageIndex, new Point(_invalidateRect.left, _invalidateRect.top));
        var ptRightBottom = PageToClient(pageIndex, new Point(_invalidateRect.right, _invalidateRect.bottom));
        Rect rect = new Rect(ptTopLeft, ptRightBottom);
        drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(30, 0, 255,0)), null, rect);
    }
}

Edited by user Monday, April 16, 2018 11:03:36 PM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.