Rank: Newbie
Groups: Registered
Joined: 9/13/2017(UTC) Posts: 4  Location: Ohio
|
Hi,
I would like to overlay a pointer (e.g., red circle or arrow point) at one precise location on top of the PDF page. Is there a way to programmatically add graphics like this in real-time using the pdf viewer control? I don't want to change the underlying PDF, just want a temporary pointer graphic that appears in the c# form control.
Thanks, Jim
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
You can create a derived class and override OnPaint method Code:
class MyPdfViewer : PdfViewer
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//draw red square at the left-bottom corner of the current page
var point = PageToClient(CurrentIndex, new PointF(0, 0));
e.Graphics.FillRectangle(Brushes.Red, point.X, point.Y-30, 30, 30);
//draw blue square at the right-bottom corner of the current page
point = PageToClient(CurrentIndex, new PointF(CurrentPage.Width, 0));
e.Graphics.FillRectangle(Brushes.Blue, point.X-30, point.Y - 30, 30, 30);
//draw green square at the left-top corner of the current page
point = PageToClient(CurrentIndex, new PointF(0, CurrentPage.Height));
e.Graphics.FillRectangle(Brushes.Green, point.X, point.Y, 30, 30);
//draw yellow square at the righttop corner of the current page
point = PageToClient(CurrentIndex, new PointF(CurrentPage.Width, CurrentPage.Height));
e.Graphics.FillRectangle(Brushes.Yellow, point.X-30, point.Y, 30, 30);
}
}
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/13/2017(UTC) Posts: 4  Location: Ohio
|
Thanks for the help Paul.
I've made the suggested derived class below, but when I go to drag the new form component from the toolbox into the form using the designer I receive a message that says "Failed to load toolbox item 'MyPdfViewer'. It will be removed from the toolbox."
Thanks again for your help.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Well... I've no such problem. Everything works fine. Seems like version of the target framework of the project less than framework version of the PdfViewer added to the toolbox. Edited by user Tuesday, September 19, 2017 5:49:08 PM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/13/2017(UTC) Posts: 4  Location: Ohio
|
hmm... using .net 4.6.1 for the project and still have the issue. What code do you have in the designer code for the derived component? I've just got the boilerplate code still, maybe that's the problem: Code:
namespace DeskVizForms
{
partial class MyPdfViewerComponent
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/13/2017(UTC) Posts: 4  Location: Ohio
|
Got it working! It looks like I needed to have the "Any CPU" profile selected, instead of "x64"...
Thanks for the help!
|
|
|
|
|
|
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close