Alright, all your argument is fair enough this is the code here:
I am putting it in the textbox textchanged event where it takes the
first char of the string, check the length of the width. I f the width
is over the border of the restricted boundary set, go to the next
line...repeat process until it reaches the max height. Naturally the
delete function doesn't work because every time I press the delete
button on the keyboard I get index out of bound, I have to code the
delete function where in the drawstring I move one step to the left,
decrement the index of the strtest3 by one until I reach the top. What
is my objective in this whole affair it is simple let me show by this
link:
http://www.tlucretius.net/7thSea/bookgen.gif (this link is obtained
from google image there is no fear of virus or anything like that). If
you click on the link you will see the book open in two pages, this is
pretty much what is loaded in the picturebox of my project, but the
two pages are empty. Now at the begging of the code when I type
anything in the keyboard the txtContent textChange checks to see if I
reached the end of the first line if not keep drawing what I typed.
But if it did reach the end of the first line by using this statement
if fSize.Width > (dblMaxX - dblX) Then, then go one line down and
repeat the process. In the picture as you see, ones I reach the last
line of the first page then I use this code to see if I reached the
end of the height. If I did then I use this here:
dblX = imgLoadPicture.Width / 1.9
dblY = imgLoadPicture.Height / 10
so that I can reach the second page and put the cursor at first line
of the second page. My complete desire at the point when I reach the
end of the line of the second page I erase everything in the book and
start again from the beginning.
But it is not working correctly, the first part is half working, yes
it does what I want it keeps writing in the book until it reaches at
the end of the page, but if I made a mistake in my typing and I press
delete button, instead of deleting the text in the book it draws the
code of the delete and keeps going until I get an index out of
bound..which is wrong. That means I have to physically code the delete
button in such away that if I press delete I decrement the index
bound, I delete one character in the string I, decrement the X
coordinate so that it goes one back and if I reach at the beginning of
the line, I decrement the Y coordinate so I start at the end of the
previous line and keep until I reach at the beginning of the page.
That is if I am at the beginning of the page of the page, if I am
not, I have to continue decrementing the indexing bound until I am at
the beginning of the second page and then do mathematical calculation
until I am at the end of the line of the previous page and repeat
process when I press delete until I am at the beginning of the page of
the book. But my code is not working correctly, if you can see it can
you help them then? I tried my best to explain what I am looking for
what the code is doing, I hope I was descriptive on the matter ^_^* I
thank you guys for helping me on this issue, looking forward (now) for
any help in this regard.
Private Sub txtContent_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtContent.TextChanged
'ReDim Preserve strtest3(Len(strText))
If blNewLine = False Then
strtest3 = txtContent.Text
strText = strtest3
strtest = strText
fSize = g.MeasureString(strtest3, fntFonts)
' Check to see if I reached at the end of the page then go
to the next page
If fSize.Height > (dblMaxY - dblY) Then
dblX = imgLoadPicture.Width / 1.9
dblY = imgLoadPicture.Height / 10
strtest3 = txtContent.Text
strtest3(iCharCounter) = vbCr
newLen = Len(txtContent.Text)
strText.CopyTo(iCharCounter, strtest2, 0, (newLen -
iCharCounter))
'
While (iCharCounter <= UBound(strtest3))
' This code here displays the text on the
picturebox with the image loaded.
' bmpDrawText = New Bitmap(picBookPaperDoll.Image)
g = Graphics.FromImage(bmpDrawText)
If Asc(strtest3.GetValue(iCharCounter)) = 13 Then
strText2 = String.Empty ' We are in a new
line
blNewLine = True
dblY = dblY + 5
txtContent.Text = String.Empty
End If
iCharCounter = iCharCounter + 1
End While
iCharCounter = 0
' Check to see if I reached at the end of the line
then go down one line.
ElseIf fSize.Width > (dblMaxX - dblX) Then
strtest3 = txtContent.Text
strtest3(iCharCounter) = vbCr
newLen = Len(txtContent.Text)
strText.CopyTo(iCharCounter, strtest2, 0, (newLen -
iCharCounter))
'
While (iCharCounter <= UBound(strtest3))
' This code here displays the text on the
picturebox with the image loaded.
' bmpDrawText = New Bitmap(picBookPaperDoll.Image)
g = Graphics.FromImage(bmpDrawText)
If Asc(strtest3.GetValue(iCharCounter)) = 13 Then
strText2 = String.Empty ' We are in a new
line
blNewLine = True
dblY = dblY + 5
txtContent.Text = String.Empty
End If
iCharCounter = iCharCounter + 1
End While
End If
Try
If Asc(strtest3.GetValue(newBeginningCounter)) <> 13
Then
strText2 = strText2 &
strtest3.GetValue(newBeginningCounter).ToString
g.DrawString(strText2.ToString, fntFonts,
Brushes.Red, dblX, dblY)
End If
Catch ex As Exception
newBeginningCounter = 0
strText2 = strText2 &
strtest3.GetValue(newBeginningCounter).ToString
g.DrawString(strText2.ToString, fntFonts, Brushes.Red,
dblX, dblY)
End Try
newBeginningCounter = newBeginningCounter + 1 :
iCharCounter = iCharCounter + 1
picBookPaperDoll.Image = bmpDrawText
ElseIf blNewLine = True Then
blNewLine = False : iCharCounter = 0
End If
End Sub