Ok, this is going to be a big one. In this tutorial, we shall show you how easy it is to use GdPicture to make your own Document Viewer.
We will start right from showing you how to download GdPicture, through starting your Visual Studio Application, all the way to adding the navigation buttons.
Nine Steps, here we go:
Step 1: Downloading and Installing GdPicture.NET on your computer.
You will need to go to our download page:
https://www.gdpicture.com/download.php
When there, click the download button, then click on (Download EXE file).
Once downloaded, Run it, and go through the easy to use installation wized.
Step 2: Requesting a Trial Key Through the LicenseManager.
GdPicture 9 has a new method of requesting Trial Keys or Registering Commercial Keys:
Upon installing GdPicture.NET, you will be prompted to the Run the LicenseManager.EXE tool. There you shall find two buttons:
a. Request a Trial Key - If you choose this one, you need to fill in your information, which will be used to create a Support Account for you at our Support Platform
https://www.gdpicture.com/support/getti ... m-our-team
b. Register a License - If you choose this one, you will need to fill in your commercial key which you have obtained upon purchasing a GdPicture.NET toolkit.
For more detailed information and illustrationgs, please refer to:
https://www.gdpicture.com/evaluate/sdk-evaluation.php
Step 3: Starting a New Visual Studio Project.
- Start Visual Studio
- Go to File -> New -> Project
For VB.NET:
Other Languages -> Visual Basic -> Windows: Windows Forms Application For C#:
Other Languages -> Visual C# -> Windows: Windows Forms Applications - Name your application and select the directory you want it in.
- Press OK
Step 4: Adding Gdpicture.NET visual controls to the toolbox.
• Right-click into the Toolbox Items and select "Add/Remove Items" for Visual Studio 2003 or "Choose Items" for Visual Studio 2005 & later. • Select the .NET Framework Components tab • Click on the Brows... button
• Select the GdPicture.NET dll which can be found on C:\Program Files\GdPicture.NET %VersionNumber%\Redist\Framework X.X\GdPicture.NET.dll • Now you will be able to select a GdViewer Item from the Toolbox in order to draw it within your forms.
Do not forget to add a reference to GdPicture.NET.dll in your project. If you do not know how to, please refer to:
https://www.gdpicture.com/guides/gdpict ... e_NET.html
Step 5: Unlocking the control (with the LicenseManager class) in the form load event
Before GdPicture object of any kind is initialized, you need to call the Method RegisterKey of a LicenseManager object with your commercial or demo key. This is best done on the load of the form:
The code in your application should look something like this:
VB.NET
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oLicenseManager As New GdPicture.LicenseManager
oLicenseManager.RegisterKEY("MY_GDPICTURENET9_KEY")
End Sub
Code: Select all
private void Form1_Load(System.Object eventSender, System.EventArgs eventArgs)
{
LicenseManager oLicenceManager = new LicenseManager();
oLicenceManager.RegisterKEY("MY_GDPICTURENET9_KEY");
}
If you have an upgrade, you need to use two calls also, one with the old key, and the second with the upgrade key.
Step 6: Drawing a GdViewer on the Form
Drawing a GdViewer is extremely simple.
- Select GdViewer in the Toolbox
- Drag it and Drop it on the Form
- Position it and resize it as you wish - In the Properties Menu, go to Name and type "myGdViewer".
NOTE: You do note have to rename it if you wish, you can use the default name, but we will use this name in this tutorial.
Step 7: Creating an Open Image Button with the code behind
- Same way you drew the GdViewer, draw a button on the form.
- In the Properties Menu, go to Text and type: "Open Image"
- Double click on the button, this will initialize a Button_Click event for you, in which you will call the Display Function of the GdViewer. Your code should look something like this:
VB.NET:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
myGdViewer.DisplayFromFile("")
End Sub
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
myGdViewer.DisplayFromFile("");
}
8- Adding Page Navigation Buttons (prev, next, first, last)
Same way we added the OpenImage Button. Now we shall add four buttons for page display in multipage files.
All you have to do is:
- Draw the Button
- Write the Text in the Properties Menu that corresponds to it.
- Double Clik on it
- Call the function in myGdViewer that does what you need
- Repeat four times
We will show you the code of the Previous Page, and give you the functions of the other Page Navigation buttons.
1. Previous Page:
VB.NET:
Code: Select all
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
myGdViewer.DisplayPreviousPage()
End Sub
Code: Select all
private void button2_Click(object sender, EventArgs e)
{
myGdViewer.DisplayPreviousPage();
}
Code: Select all
myGdViewer.DisplayNextPage()
Code: Select all
myGdViewer.DisplayFirstPage()
Code: Select all
myGdViewer.DisplayLastPage()
- Also add another button
- in the Text property write "Close Document"
- Double Click on it
- in the Event call the function:
Code: Select all
myGdViewer.CloseDocument()
Hope this was not too long for you people.
Best of luck,
Sami