Instantiating and Using the Certificate ClassListing 23.5 shows code that's behind the Default.aspx page. The two methods shown are the CreateImage() method and the OutputImage() method. The CreateImage() method uses the Certificate class (named cert) and sets all properties with the appropriate values from the user interface objects. All these properties determine the appearance of the final certificate. The OuputImage() method instantiates a Certificate object, calls the CreateImage() method (which sets all the Certificate class's properties), saves the image using the Save() method, and outputs the file name into the HTML stream. Listing 23.5 Instantiating and Using the Certificate ClassSub CreateImage(ByVal cert As Certificate) cert.Path = Request.MapPath("") cert.Filename = Session("Filename") cert.BackgroundTile = tile.SelectedItem.Text + ".gif" If ul.SelectedIndex > 0 Then cert.UpperLeftImage = ul.SelectedItem.Text End If If ur.SelectedIndex > 0 Then cert.UpperRightImage = ur.SelectedItem.Text End If If bl.SelectedIndex > 0 Then cert.BottomLeftImage = bl.SelectedItem.Text End If If br.SelectedIndex > 0 Then cert.BottomRightImage = br.SelectedItem.Text End If cert.MainText = Session("MainText") cert.MainTextColor = MainTextColor.SelectedIndex cert.LeftText = Session("LeftText") cert.LeftTextColor = LeftColor.SelectedIndex cert.RightText = Session("RightText") cert.RightTextColor = RightColor.SelectedIndex cert.CreateImage() End Sub Public Sub OutputImage() Dim cert As New Certificate() CreateImage(cert) cert.SaveImage("TempImages") ImageTag.Text = "<IMG src="/books/2/627/1/html/2/ + Chr(34) + _ "TempImages/" + Session("Filename") + Chr(34) + ">" End Sub |