[ASP.NET] Text in GDI+ afbreken

Pagina: 1
Acties:

  • BDT
  • Registratie: December 2001
  • Laatst online: 23-10-2023
Hallo,

Ik ben bezig met een Poll in GDI+. Nu heb ik een probleem omdat ik alles uitlees in het plaatje gaat sommige text overlappen aangezien die uit de database wordt gelezen.

Wat ik dus wil is de text onder elkaar plaatsen. Dus na elk woord een break(enter) Zodat de text niet meer door elkaar kan lopen.

Oja, dat door elkaar lopen komt omdat ik de text in een loopje uitlees en dan naast elkaar ga printen.

Ik hoop dat het kan wat ik wil, want ik heb er na een dag zoeken nog niks over kunnen vinden.

Hier volgt mijn code tot zo ver:

Const iColWidth As Integer = 30
Const iColSpace As Integer = 30
Const iMaxHeight As Integer = 100
Const iHeightSpace As Integer = 25
Const iXLegendSpace As Integer = 12
Const iTitleSpace As Integer = 50

Dim iMaxWidth As Integer = (iColWidth + iColSpace) * aX.Count + iColSpace
Dim iMaxColHeight As Integer = 0
Dim iTotalHeight As Integer = iMaxHeight + iXLegendSpace + iTitleSpace

Dim objBitmap As Bitmap = New Bitmap(iMaxWidth, iTotalHeight)
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

objGraphics.FillRectangle(New SolidBrush(Color.White), 0, 0, iMaxWidth, iTotalHeight)
objGraphics.FillRectangle(New SolidBrush(Color.White), 0, 0, iMaxWidth, iMaxHeight)

' find the maximum value
Dim iValue As Integer
For Each iValue In aY
If iValue > iMaxColHeight Then iMaxColHeight = iValue
Next

Dim iBarX As Integer = iColSpace, iCurrentHeight As Integer
Dim objBrush As SolidBrush = New SolidBrush(Color.Red)
Dim fontLegend As Font = New Font("Arial", 8)
Dim fontValues As Font = New Font("Arial", 8)
Dim fontTitle As Font = New Font("Arial", 12)

' loop through and draw each bar
Dim iLoop As Integer
For iLoop = 0 To aX.Count - 1
iCurrentHeight = (Convert.ToDouble(aY(iLoop)) / Convert.ToDouble(iMaxColHeight)) * Convert.ToDouble(iMaxHeight - iHeightSpace)

objGraphics.FillRectangle(objBrush, iBarX, iMaxHeight - iCurrentHeight, iColWidth, iCurrentHeight)
objGraphics.DrawString(aX(iLoop), fontLegend, objBrush, iBarX, iMaxHeight)
objGraphics.DrawString(String.Format("{0:#,###}", aY(iLoop)), fontValues, objBrush, iBarX, iMaxHeight - iCurrentHeight - 15)

iBarX += (iColSpace + iColWidth)
Next

Dim salign As New System.Drawing.StringFormat()

salign.Alignment = StringAlignment.Center
objGraphics.DrawString(strTitle, fontTitle, objBrush, (iMaxWidth / 2) - strTitle.Length * 4, iMaxHeight + iXLegendSpace)
salign.Alignment = StringAlignment.Center

objBitmap.Save(Target, ImageFormat.Gif)
objGraphics.Dispose()
objBitmap.Dispose()


Ik hoop dat iemand mij hierbij kan helpen.

Sega till I die!


  • BDT
  • Registratie: December 2001
  • Laatst online: 23-10-2023
Niemand die van GDI+ iets afweet verder?

Sega till I die!


  • KnoppenSpook
  • Registratie: Augustus 2000
  • Laatst online: 04-09-2023
misschien staat hier wat? http://www.codeproject.com/vcpp/gdiplus/

/me weet geen leuke quote voor in zijn signature


  • BDT
  • Registratie: December 2001
  • Laatst online: 23-10-2023
Die had ik ook al gevonden. Helaas niets nuttigs.

Thx anyway.

Sega till I die!