Description: Create a shipping application that will enable a user to select the
ID: 3633903 • Letter: D
Question
Description:Create a shipping application that will enable a user to select the weight of a package, the destination zone for
the package, and the application finds the rate to ship the package.
The user should be able to clear the screen.
A File menu should allow the user to print preview and print a document that contains the charges selected
since the last clear including the total of all shipping charges selected.
Also under the File menu, the user can Exit the program.
The following table defines the shipping charges your application should display:
Table 1: Shipping Charges
Shipping Weight Zone A Zone B Zone C Zone D
<= 1 pound $1.00 $1.50 $2.40 $1.85
<= 3 pounds $1.58 $2.00 $2.40 $3.05
<= 5 pounds $1.71 $2.52 $3.10 $4.00
<= 10 pounds $2.04 $3.12 $4.00 $5.01
>10 pounds $2.52 $3.75 $5.10 $7.25
Deliverables:
Design the application and turn in the following:
Object diagrams for each control on the form.
Pseudo Code for each event, operation, procedure, and function that will be coded.
Code and test the application. Your application should include arrays, accept/cancel buttons, access keys, and exception/error
handling.
Explanation / Answer
Public Class Form1 Dim frmImage As Bitmap Public Enum area wholeForm clientRectangle clientRectangleMinusMenuStrip End Enum Private Shared Function captureForm(ByVal frm As Form, ByVal ms As MenuStrip, ByVal printArea As area) As Bitmap frm.BringToFront() Dim img As Bitmap = Nothing Dim gr As Graphics If printArea = area.clientRectangle Then img = New Bitmap(frm.ClientSize.Width, frm.ClientSize.Height) gr = Graphics.FromImage(img) gr.CopyFromScreen(frm.PointToScreen(frm.ClientRectangle.Location), Point.Empty, frm.ClientSize) ElseIf printArea = area.wholeForm Then img = New Bitmap(frm.Width, frm.Height) gr = Graphics.FromImage(img) gr.CopyFromScreen(frm.Location, Point.Empty, frm.Size) ElseIf printArea = area.clientRectangleMinusMenuStrip Then img = New Bitmap(frm.ClientSize.Width, frm.ClientSize.Height - ms.Height) gr = Graphics.FromImage(img) Dim p As Point = frm.PointToScreen(frm.ClientRectangle.Location) p.Offset(0, ms.Height) gr.CopyFromScreen(p, Point.Empty, img.Size) End If Return img End Function Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click frmImage = captureForm(Me, MenuStrip1, DirectCast(ComboBox1.SelectedItem, area)) Dim ppd As New PrintPreviewDialog ppd.Document = PrintDocument1 ppd.WindowState = FormWindowState.Maximized ppd.ShowDialog() End Sub Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click frmImage = captureForm(Me, MenuStrip1, DirectCast(ComboBox1.SelectedItem, area)) PrintDocument1.Print() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add(area.clientRectangle) ComboBox1.Items.Add(area.clientRectangleMinusMenuStrip) ComboBox1.Items.Add(area.wholeForm) End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage e.Graphics.DrawImage(frmImage, e.MarginBounds.Location) End Sub End Class