Chapter 23. Effective Use of GDI: Creating a Certificates Program

Chapter 23. Effective Use of GDI+: Creating a Certificates Program

In This Chapter:

  • The Member Variables and Properties

  • Creating the Certificate

  • Initializing the Default.aspx User Interface Objects

  • Instantiating and Using the Certificate Class

  • Responding to User Interaction

I have always loved those Web sites at which you could make a greeting card and send it. It's fascinating how they can give you such a rich design tool that's online. And there are tons and tons of options for creating some awesome cards.

But don't be fooled by the cuteness of the idea there's a real business model here. For starters, these attractions bring millions of users to a site. And millions of users mean millions of advertising banner impressions. These ad banner impressions translate into dollars and cents.

Another business model involves embedding advertisements in the greeting cards that are sent out. The cards can also contain links to the sending Web site so that receivers can easily get to the Web site and send a card in return. All of this translates into traffic and advertising revenue.

There's a slight variation to the greeting card idea that I wanted to add to one of my Web sites that offers activities for children. The site is eKidPlace and can be found at www.eKidPlace.com. What I added to the site was the capability to send certificates of achievement to people. A certificate might be for something such as running a five-minute mile, memorizing the Gettysburg Address, or winning the lottery. Setting up this feature was quite a bit of work because I did it three years ago and resorted to Java for much of the interactive portion of the application. I also had to write some server-side code that saved the image to disk on the server.

But with ASP.NET, the application that took months to create using Java and server-side C++ recently took a day to create using ASP.NET. All the user interface objects, such as the drop-down lists, were a snap with ASP.NET, and GDI+ made the image creation and saving to disk a virtual snap to do.

Table 23.1 contains the methods that do the work in the Certificates application. This table will be a handy reference as you work your way through the program.

Table 23.1. The Methods for the Certificates Application

Method

Listing

Source Code File

Description

DrawCornerImages

23.2

CertificatesVB.vb

This method draws the certificate corner images into the bitmap.

TileCertificate

23.2

CertificatesVB.vb

This method tiles the certificate background.

DrawMainText

23.2

CertificatesVB.vb

This method draws the main text into the certificate.

DrawLeftText

23.2

CertificatesVB.vb

This method draws the text at the lower left part of the certificate.

DrawRightText

23.2

CertificatesVB.vb

This method draws the text at the bottom right part of the certificate.

CreateImage

23.2

CertificatesVB.vb

This method creates a bitmap, calls draw methods such as TileCertificate and DrawMainText, and then saves the image to disk.

Page_Load

23.3

Default.aspx.vb

This method is called when the default.aspx page is loaded.

Application_Start

23.4

Global.asax.vb

This method creates a list of file names for all the available corner images.

CreateImage

23.5

Default.aspx.vb

This image instantiates a Certificates object and uses it to create a certificate.

OutputImage

23.5

Default.aspx.vb

This method outputs an IMG tag into the HTML stream.

CreateNewFilename

23.6

Default.aspx.vb

This method generates a file name based on the system clock.

ul_SelectedIndexChanged

23.6

Default.aspx.vb

This method responds to a change in the selected upper left image.

ur_SelectedIndexChanged

23.6

Default.aspx.vb

This method responds to a change in the selected upper right image.

bl_SelectedIndexChanged

23.6

Default.aspx.vb

This method responds to a change in the selected bottom left image.

br_SelectedIndexChanged

23.6

Default.aspx.vb

This method responds to a change in the selected bottom right image.

tile_SelectedIndexChanged

23.6

Default.aspx.vb

This method is fired when the user changes the selected tile.

InsertNow_Click

23.6

Default.aspx.vb

This method is fired when the user clicks the Insert button.

InsertLeft_Click

23.6

Default.aspx.vb

This method is fired when the user clicks the Insert Left button.

InsertRight_Click

23.6

Default.aspx.vb

This method is fired when the user clicks the Insert Right button.

SendEmail_Click

23.6

Default.aspx.vb

This method is fired when the user clicks the Send Email button.

The Certificates application has a number of properties that determine the appearance of the certificate. These properties are shown in Table 23.2 for your convenience.

Table 23.2. The Properties for the Certificates Application

Property

Listing

Source Code File

Description

BackgroundTile

23.1

CertificatesVB.vb

The name of the background tile image

UpperLeftImage

23.1

CertificatesVB.vb

The name of the image that will appear in the upper left corner of the certificate

UpperRightImage

23.1

CertificatesVB.vb

The name of the image that will appear in the upper right corner of the certificate

BottomLeftImage

23.1

CertificatesVB.vb

The name of the image that will appear in the bottom left corner of the certificate

BottomRightImage

23.1

CertificatesVB.vb

The name of the image that will appear in the bottom right corner of the certificate

Filename

23.1

CertificatesVB.vb

The file name to which the certificate will be saved

Path

23.1

CertificatesVB.vb

The path into which the certificate file will be saved

MainText

23.1

CertificatesVB.vb

The text that appears in the center of the certificate

LeftText

23.1

CertificatesVB.vb

The text that appears in the lower left portion of the certificate

RightText

23.1

CertificatesVB.vb

The text that appears in the lower right portion of the certificate

MainTextColor

23.1

CertificatesVB.vb

The color of the main text

LeftTextColor

23.1

CertificatesVB.vb

The color of the text in the lower left portion of the certificate

RightTextColor

23.1

CertificatesVB.vb

The color of the text in the lower right portion of the certificate



ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
EAN: N/A
Year: 2003
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net