Results 1 to 15 of 15

Thread: creating forms

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Posts
    73

    creating forms

    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
    Last edited by pea33nut; Jun 29th, 2004 at 11:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width