Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/06/2007, 15:22
jetzona
 
Fecha de Ingreso: marzo-2006
Mensajes: 202
Antigüedad: 18 años, 2 meses
Puntos: 2
Re: Traduccion de C# a Visual Basic .Net

continua:

Private Sub pr_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
e.Graphics.PageUnit = GraphicsUnit.Millimeter
gfx = e.Graphics
DrawImage()
DrawHeader()
DrawSubHeader()
DrawItems()
DrawTotales()
DrawFooter()
If (Not (headerImage) Is Nothing) Then
headerImage.Dispose()
headerImage.Dispose()
End If
End Sub

Private Function YPosition() As Single
Return (topMargin _
+ ((count * printFont.GetHeight(gfx)) _
+ imageHeight))
End Function

Private Sub DrawImage()
If (Not (headerImage) Is Nothing) Then
Try
gfx.DrawImage(headerImage, New Point(CType(leftMargin, Integer), CType(YPosition(), Integer)))
Dim height As Double = ((CType(headerImage.Height, Double) / 58) _
* 15)
imageHeight = (CType(Math.Round(height), Integer) + 3)
Catch As Exception

End Try
End If
End Sub

Private Sub DrawHeader()
For Each header As String In headerLines
If (header.Length > maxChar) Then
Dim currentChar As Integer = 0
Dim headerLenght As Integer = header.Length

While (headerLenght > maxChar)
line = header.Substring(currentChar, maxChar)
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
currentChar = (currentChar + maxChar)
headerLenght = (headerLenght - maxChar)

End While
line = header
gfx.DrawString(line.Substring(currentChar, (line.Length - currentChar)), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
Else
line = header
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
End If
Next
DrawEspacio()
End Sub

Private Sub DrawSubHeader()
For Each subHeader As String In subHeaderLines
If (subHeader.Length > maxChar) Then
Dim currentChar As Integer = 0
Dim subHeaderLenght As Integer = subHeader.Length

While (subHeaderLenght > maxChar)
line = subHeader
gfx.DrawString(line.Substring(currentChar, maxChar), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
currentChar = (currentChar + maxChar)
subHeaderLenght = (subHeaderLenght - maxChar)

End While
line = subHeader
gfx.DrawString(line.Substring(currentChar, (line.Length - currentChar)), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
Else
line = subHeader
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
line = DottedLine()
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
End If
Next
DrawEspacio()
End Sub

Private Sub DrawItems()
Dim ordIt As OrderItem = New OrderItem(Microsoft.VisualBasic.ChrW(63))
gfx.DrawString("CANT DESCRIPCION IMPORTE", printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
DrawEspacio()
For Each item As String In items
line = ordIt.GetItemCantidad(item)
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
line = ordIt.GetItemPrice(item)
line = (AlignRightText(line.Length) + line)
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
Dim name As String = ordIt.GetItemName(item)
leftMargin = 0
If (name.Length > maxCharDescription) Then
Dim currentChar As Integer = 0
Dim itemLenght As Integer = name.Length

While (itemLenght > maxCharDescription)
line = ordIt.GetItemName(item)
gfx.DrawString((" " + line.Substring(currentChar, maxCharDescription)), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
currentChar = (currentChar + maxCharDescription)
itemLenght = (itemLenght - maxCharDescription)

End While
line = ordIt.GetItemName(item)
gfx.DrawString((" " + line.Substring(currentChar, (line.Length - currentChar))), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
Else
gfx.DrawString((" " + ordIt.GetItemName(item)), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
End If
Next
leftMargin = 0
DrawEspacio()
line = DottedLine()
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
DrawEspacio()
End Sub

Private Sub DrawTotales()
Dim ordTot As OrderTotal = New OrderTotal(Microsoft.VisualBasic.ChrW(63))
For Each total As String In totales
line = ordTot.GetTotalCantidad(total)
line = (AlignRightText(line.Length) + line)
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
leftMargin = 0
line = (" " + ordTot.GetTotalName(total))
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
Next
leftMargin = 0
DrawEspacio()
DrawEspacio()
End Sub

Private Sub DrawFooter()
For Each footer As String In footerLines
If (footer.Length > maxChar) Then
Dim currentChar As Integer = 0
Dim footerLenght As Integer = footer.Length

While (footerLenght > maxChar)
line = footer
gfx.DrawString(line.Substring(currentChar, maxChar), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
currentChar = (currentChar + maxChar)
footerLenght = (footerLenght - maxChar)

End While
line = footer
gfx.DrawString(line.Substring(currentChar, (line.Length - currentChar)), printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
Else
line = footer
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
End If
Next
leftMargin = 0
DrawEspacio()
End Sub

Private Sub DrawEspacio()
line = ""
gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition, New StringFormat)
count = (count + 1)
End Sub
End Class

Public Class OrderItem

Private delimitador() As Char = New Char() {Microsoft.VisualBasic.ChrW(63)}

Public Sub New(ByVal delimit As Char)
MyBase.New()
delimitador = New Char() {delimit}
End Sub

Public Function GetItemCantidad(ByVal orderItem As String) As String
Dim delimitado() As String = orderItem.Split(delimitador)
Return delimitado(0)
End Function