Hello all, I have a question regarding the some data which is being transfered from one form to my class. It's not going quite the way i'd like to , so I figured maybe there is someone who could help me.
This is my code in my class
Public Class DrawableTextBox
Inherits Drawable
Dim i_testString As Integer
Private s_InsertLabel As String
Private drawFont As Font
Public Sub New(ByVal fore_color As Color, ByVal fill_color As Color, Optional ByVal line_width As Integer = 0, Optional ByVal new_x1 As Integer = 0, Optional ByVal new_y1 As Integer = 0, Optional ByVal new_x2 As Integer = 1, Optional ByVal new_y2 As Integer = 1)
MyBase.New(fore_color, fill_color, line_width)
X1 = new_x1
Y1 = new_y1
X2 = new_x2
Y2 = new_y2
Trace.WriteLine(s_InsertLabel)
End Sub
Friend WriteOnly Property _textBox() As String
Set(ByVal Value As String)
s_InsertLabel = Value
Trace.WriteLine(s_InsertLabel)
End Set
End Property
' Draw the object on this Graphics surface.
Public Overrides Sub Draw(ByVal gr As System.Drawing.Graphics)
' Make a Rectangle representing this rectangle.
Dim rect As Rectangle = GetBounds()
' Fill the rectangle as usual.
Dim fill_brush As New SolidBrush(FillColor)
gr.FillRectangle(fill_brush, rect)
fill_brush.Dispose()
' See if we're selected.
If IsSelected Then
' Draw the rectangle highlighted.
Dim highlight_pen As New Pen(Color.Yellow, LineWidth)
gr.DrawRectangle(highlight_pen, rect)
highlight_pen.Dispose()
' Draw grab handles.
Trace.WriteLine("drawing the lines for my textbox")
DrawGrabHandle(gr, X1, Y1)
DrawGrabHandle(gr, X1, Y2)
DrawGrabHandle(gr, X2, Y2)
DrawGrabHandle(gr, X2, Y1)
Else
'TextBox()
Dim fg_pen As New Pen(Color.Red, LineWidth)
'Dim fontSize As Single = 0.1 + ((Y2 - Y1) / 2)
Dim fontSize As Single = 20
Try
Dim drawFont As New Font("Arial", fontSize, FontStyle.Bold)
Trace.WriteLine(s_InsertLabel)
gr.DrawString(s_InsertLabel, drawFont, Brushes.Brown, X1, Y1)
Catch ex As ArgumentException
End Try
gr.DrawRectangle(Pens.Azure, rect)
' gr.DrawRectangle(fg_pen, rect)
fg_pen.Dispose()
End If
End Sub
Public Function GetValueString(ByVal ValueType As String)
Return ValueType
End Function
' Return the object's bounding rectangle.
Public Overrides Function GetBounds() As System.Drawing.Rectangle
Return New Rectangle( _
Min(X1, X2), _
Min(Y1, Y2), _
Abs(100), _
Abs(30))
Trace.WriteLine("don't forget to make variables in GetBounds DrawableTextbox")
End Function
' Return True if this point is on the object.
Public Overrides Function IsAt(ByVal x As Integer, ByVal y As Integer) As Boolean
Return (x >= Min(X1, X2)) AndAlso _
(x <= Max(X1, X2)) AndAlso _
(y >= Min(Y1, Y2)) AndAlso _
(y <= Max(Y1, Y2))
End Function
' Move the second point.
Public Overrides Sub NewPoint(ByVal x As Integer, ByVal y As Integer)
X2 = x
Y2 = y
End Sub
' Return True if the object is empty (e.g. a zero-length line).
Public Overrides Function IsEmpty() As Boolean
Return (X1 = X2) AndAlso (Y1 = Y2)
End Function
End Class
I've got a form with a textbox( form1) in which the text is being inserted and passed through a buttonclick (al via properties).
As you can see I've placed several traces and in the property of the class my trace works fine , however if I look in my Draw function it is already gone.
And I get a blank trace.
Does anyone know what's happening here.
thanks in advance.
(forgive me I'm new )