M
Mark
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.Color)
Dim txt As String = "Aa"
'Dim big_font As New Font("Times New Roman", 30, FontStyle.Bold)
'g.TextRenderingHint =
Drawing.Text.TextRenderingHint.AntiAliasGridFit
'g.DrawString(txt, big_font, Brushes.Black, 10, 100)
'g.FillRectangle(b, New Rectangle(Me.Location, Me.Size))
'b.Dispose()
'Create a GraphicsPath
Dim graphics_path As New Drawing2D.GraphicsPath
'Add some text to the path
graphics_path.AddString(txt, _
New FontFamily("Times New Roman"), _
CInt(FontStyle.Bold), _
80, New Point(10, 100), _
StringFormat.GenericTypographic)
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.FillPath(Brushes.White, graphics_path)
g.DrawPath(New Pen(Drawing.Color.Black, 3), graphics_path)
b.Dispose()
If Highlight Then
Dim p As New Pen(Drawing.Color.Red, 3)
p.DashStyle = Drawing2D.DashStyle.DashDot
g.DrawRectangle(p, New Rectangle(Me.Location, Me.Size))
p.Dispose()
End If
End Sub
Public Overloads Overrides Function HitTest(ByVal p As Point) As
Boolean
Dim pth As New Drawing2D.GraphicsPath()
pth.AddEllipse(New Rectangle(Location, 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?
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.Color)
Dim txt As String = "Aa"
'Dim big_font As New Font("Times New Roman", 30, FontStyle.Bold)
'g.TextRenderingHint =
Drawing.Text.TextRenderingHint.AntiAliasGridFit
'g.DrawString(txt, big_font, Brushes.Black, 10, 100)
'g.FillRectangle(b, New Rectangle(Me.Location, Me.Size))
'b.Dispose()
'Create a GraphicsPath
Dim graphics_path As New Drawing2D.GraphicsPath
'Add some text to the path
graphics_path.AddString(txt, _
New FontFamily("Times New Roman"), _
CInt(FontStyle.Bold), _
80, New Point(10, 100), _
StringFormat.GenericTypographic)
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.FillPath(Brushes.White, graphics_path)
g.DrawPath(New Pen(Drawing.Color.Black, 3), graphics_path)
b.Dispose()
If Highlight Then
Dim p As New Pen(Drawing.Color.Red, 3)
p.DashStyle = Drawing2D.DashStyle.DashDot
g.DrawRectangle(p, New Rectangle(Me.Location, Me.Size))
p.Dispose()
End If
End Sub
Public Overloads Overrides Function HitTest(ByVal p As Point) As
Boolean
Dim pth As New Drawing2D.GraphicsPath()
pth.AddEllipse(New Rectangle(Location, 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?