I modified a C# application from Bob Powell that moves graphics primitives
around on the screen into a Vb.NET 2005 application. I want to modify this
application so along with moving regular geometric shapes, I can also move
the alphanumeric characters as well. For example I place the character "A" on
the screen and when I point to it with the mouse the character will be
outlined and while holding down the left mouse button move the "A" somewhere
else on the screen.
Since I learn best by example I wrote another class for the Characters, but
it doesn't work. I asked Bob Powell and he suggested I convert the characters
to glyphs and hit test these, but since VB.NET's only resembalance to the
Visual Basic programming language is in name only I'm now completely lost.
Here is the Class I wrote:
Public Class DrawText
Inherits Primitive
Public Sub New()
MyBase.New()
End Sub
Public Overloads Overrides Sub Draw(ByVal g As Graphics)
Dim b As New SolidBrush(Me.C olor)
Dim txt As String = "Aa"
'Dim big_font As New Font("Times New Roman", 30, FontStyle.Bold)
'g.TextRenderin gHint =
Drawing.Text.Te xtRenderingHint .AntiAliasGridF it
'g.DrawString(t xt, big_font, Brushes.Black, 10, 100)
'g.FillRectangl e(b, New Rectangle(Me.Lo cation, Me.Size))
'b.Dispose()
'Create a GraphicsPath
Dim graphics_path As New Drawing2D.Graph icsPath
'Add some text to the path
graphics_path.A ddString(txt, _
New FontFamily("Tim es New Roman"), _
CInt(FontStyle. Bold), _
80, New Point(10, 100), _
StringFormat.Ge nericTypographi c)
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
g.FillPath(Brus hes.White, graphics_path)
g.DrawPath(New Pen(Drawing.Col or.Black, 3), graphics_path)
b.Dispose()
If Highlight Then
Dim p As New Pen(Drawing.Col or.Red, 3)
p.DashStyle = Drawing2D.DashS tyle.DashDot
g.DrawRectangle (p, New Rectangle(Me.Lo cation, Me.Size))
p.Dispose()
End If
End Sub
Public Overloads Overrides Function HitTest(ByVal p As Point) As
Boolean
Dim pth As New Drawing2D.Graph icsPath()
pth.AddEllipse( New Rectangle(Locat ion, Size))
Dim retval As Boolean = pth.IsVisible(p )
pth.Dispose()
Return retval
End Function
End Class
Can someone tell me what I'm doing wrong?
--
Mark
around on the screen into a Vb.NET 2005 application. I want to modify this
application so along with moving regular geometric shapes, I can also move
the alphanumeric characters as well. For example I place the character "A" on
the screen and when I point to it with the mouse the character will be
outlined and while holding down the left mouse button move the "A" somewhere
else on the screen.
Since I learn best by example I wrote another class for the Characters, but
it doesn't work. I asked Bob Powell and he suggested I convert the characters
to glyphs and hit test these, but since VB.NET's only resembalance to the
Visual Basic programming language is in name only I'm now completely lost.
Here is the Class I wrote:
Public Class DrawText
Inherits Primitive
Public Sub New()
MyBase.New()
End Sub
Public Overloads Overrides Sub Draw(ByVal g As Graphics)
Dim b As New SolidBrush(Me.C olor)
Dim txt As String = "Aa"
'Dim big_font As New Font("Times New Roman", 30, FontStyle.Bold)
'g.TextRenderin gHint =
Drawing.Text.Te xtRenderingHint .AntiAliasGridF it
'g.DrawString(t xt, big_font, Brushes.Black, 10, 100)
'g.FillRectangl e(b, New Rectangle(Me.Lo cation, Me.Size))
'b.Dispose()
'Create a GraphicsPath
Dim graphics_path As New Drawing2D.Graph icsPath
'Add some text to the path
graphics_path.A ddString(txt, _
New FontFamily("Tim es New Roman"), _
CInt(FontStyle. Bold), _
80, New Point(10, 100), _
StringFormat.Ge nericTypographi c)
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
g.FillPath(Brus hes.White, graphics_path)
g.DrawPath(New Pen(Drawing.Col or.Black, 3), graphics_path)
b.Dispose()
If Highlight Then
Dim p As New Pen(Drawing.Col or.Red, 3)
p.DashStyle = Drawing2D.DashS tyle.DashDot
g.DrawRectangle (p, New Rectangle(Me.Lo cation, Me.Size))
p.Dispose()
End If
End Sub
Public Overloads Overrides Function HitTest(ByVal p As Point) As
Boolean
Dim pth As New Drawing2D.Graph icsPath()
pth.AddEllipse( New Rectangle(Locat ion, Size))
Dim retval As Boolean = pth.IsVisible(p )
pth.Dispose()
Return retval
End Function
End Class
Can someone tell me what I'm doing wrong?
--
Mark
Comment