I have 2 classes (Graphics circle, Graphics Item) Than I have a form that calls these classes and code to draw on this form. what do I need to do to use this code through out my program without using all of this code.
Public Class frmdraw
Inherits System.Windows.Forms.Form
enums....
Public Enum GraphicsTools As Integer
CirclePen = 0
End Enum
Public Enum GraphicsSizes As Integer
Small = 4
Medium = 10
Large = 20
End Enum
members.....
Public GraphicsItem As New ArrayList
Public GraphicTool As GraphicsTools = GraphicsTools.CirclePen
Public GraphicsSize As GraphicsSizes = GraphicsSizes.Large
Public GraphicColor As Color = Color.Black
DoMousePaint - respond to a mouse movement....
Private Sub DoMousePaint(ByVal e As MouseEventArgs)
store the new item somewhere...
Dim newItem As GraphicsItem
what tool are you using?
Select Case GraphicTool
circlepen?
Case GraphicTool.CirclePen
create a new graphics circle...
Dim circle As New GraphicsCircle
circle.SetPoint(e.X, e.Y, GraphicsSize, GraphicColor, True)
store this for addition...
newItem = circle
End Select
where you given an item?
If Not newItem Is Nothing Then
add it to the list...
GraphicsItem.Add(newItem)
invalidate...
Invalidate()
End If
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
is the button down?
If e.Button = MouseButtons.Left Then
DoMousePaint(e)
End If
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
is the button down?
If e.Button = MouseButtons.Left Then
DoMousePaint(e)
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
go through the list...
Dim item As GraphicsItem
For Each item In GraphicsItem
ask each item to draw itself
item.Draw(e.Graphics)
Next
End Sub
Public Class frmdraw
Inherits System.Windows.Forms.Form
enums....
Public Enum GraphicsTools As Integer
CirclePen = 0
End Enum
Public Enum GraphicsSizes As Integer
Small = 4
Medium = 10
Large = 20
End Enum
members.....
Public GraphicsItem As New ArrayList
Public GraphicTool As GraphicsTools = GraphicsTools.CirclePen
Public GraphicsSize As GraphicsSizes = GraphicsSizes.Large
Public GraphicColor As Color = Color.Black
DoMousePaint - respond to a mouse movement....
Private Sub DoMousePaint(ByVal e As MouseEventArgs)
store the new item somewhere...
Dim newItem As GraphicsItem
what tool are you using?
Select Case GraphicTool
circlepen?
Case GraphicTool.CirclePen
create a new graphics circle...
Dim circle As New GraphicsCircle
circle.SetPoint(e.X, e.Y, GraphicsSize, GraphicColor, True)
store this for addition...
newItem = circle
End Select
where you given an item?
If Not newItem Is Nothing Then
add it to the list...
GraphicsItem.Add(newItem)
invalidate...
Invalidate()
End If
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
is the button down?
If e.Button = MouseButtons.Left Then
DoMousePaint(e)
End If
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
is the button down?
If e.Button = MouseButtons.Left Then
DoMousePaint(e)
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
go through the list...
Dim item As GraphicsItem
For Each item In GraphicsItem
ask each item to draw itself
item.Draw(e.Graphics)
Next
End Sub