[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

drawing lines

Posted on 2004-10-23
16
Medium Priority
?
262 Views
Last Modified: 2010-04-23

Hello,

I am developing hangman game and I want to allow user to choose one of two options,,first if he want to show man by images for the body parts, or if he want the program to draw lines for the body parts

------

Else
            bodyParts = bodyParts + 1
            If bodyParts <= 6 AndAlso rdbImage.Checked = True Then
                showManImages(bodyParts)


            If bodyParts <= 6 AndAlso rdbDraw.Checked = True Then


            End If

------

The problem is that I dont know how to begin drawing..shall I have it in a seperate function?
I read some methods for drawing lines and rectangles that uses "e" but I am still lost

I hope if someone would help me in this

Great Thanks,
0
Comment
Question by:SEstudent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12389646
Override the Paint() method of your PictureBox and draw the appropriate body parts based on the bodypart count:

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        If rdbDraw.Checked Then
            If bodyParts >= 1 Then
                ' head
                e.Graphics.DrawEllipse(Pens.Black, New Rectangle(0, 0, 10, 10))
            End If
            If bodyParts >= 2 Then
                ' body
                e.Graphics.DrawLine(Pens.Black, 5, 10, 5, 30)
            End If
            If bodyParts >= 3 Then
                ' left arm
                e.Graphics.DrawLine(Pens.Black, 5, 15, 0, 20)
            End If
            If bodyParts >= 4 Then
                ' right arm
                e.Graphics.DrawLine(Pens.Black, 5, 15, 10, 20)
            End If
            If bodyParts >= 5 Then
                ' left leg
                e.Graphics.DrawLine(Pens.Black, 5, 30, 0, 35)
            End If
            If bodyParts >= 6 Then
                ' right leg
                e.Graphics.DrawLine(Pens.Black, 5, 30, 10, 35)
            End If
        End If
    End Sub

~IM
0
 

Author Comment

by:SEstudent
ID: 12391585

that's great, thanks

but do I have to create a new picture box and call it pictureBox1

and how can I call this method in the beginning?

-----

Else
            bodyParts = bodyParts + 1
            If bodyParts <= 6 AndAlso rdbImage.Checked = True Then
                showManImages(bodyParts)


            If bodyParts <= 6 AndAlso rdbDraw.Checked = True Then
            ------------> here

            End If

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12391757
Each time your bodyParts count changes you can cause the PictureBox to update by calling:

    PictureBox1.Refresh()

>> but do I have to create a new picture box and call it pictureBox1

The PictureBox should already be on your form to begin with, and if you are not using the drawing mode, then you can simply hide it.

Of course, there are many ways you could approach this problem.  I would need to know more about your layout and how the app works though to make better suggestions.

~IM
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:SEstudent
ID: 12391799

now I have this at the beginning

---

If letterFound() Then
            displayStars(1)
            If lblWord.Text = magicWord Then newGame()

        Else
            bodyParts = bodyParts + 1
            If bodyParts <= 6 AndAlso rdbImage.Checked = True Then
                showManImages(bodyParts)


                If bodyParts <= 6 AndAlso rdbDraw.Checked = True Then
                    PictureBox1.Refresh()
                End If

---

it is still not working..My layout have two radiobuttons to choose either draw or imaes..26 buttons for the alphabit and another box for the drawing
0
 

Author Comment

by:SEstudent
ID: 12392194

can I have a different class for drawing?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12393520
Does it just not work or do you get an error?

>> can I have a different class for drawing?

If you want a different class for drawing then you have to do one of two things to be able to draw on the PictureBox:

1) Pass a reference to the PictureBox into your class and use CreateGraphics() to draw onto it.  The drawing will not be persisent if you use this method.

2) In the PictureBox1_Paint() sub, pass the "e" variable into your class and use the graphics supplied in it to draw.  This will make the drawing persistent.

If you post the entire app here we can fix it more quickly.

~IM
0
 

Author Comment

by:SEstudent
ID: 12397251
here is my code
----------------


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        resetGame()
        PictureBoxBack.Visible = True
        PictureBoxHead.Visible = False
        PictureBoxNeck.Visible = False
        PictureBoxBody.Visible = False
        PictureBoxArms.Visible = False
        PictureBoxLegs.Visible = False
        PictureBoxRope.Visible = False
        rdbImage.Checked = True


    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click, Button10.Click, Button11.Click, Button12.Click, Button13.Click, Button14.Click, Button15.Click, Button16.Click, Button17.Click, Button18.Click, Button19.Click, Button20.Click, Button21.Click, Button22.Click, Button23.Click, Button24.Click, Button25.Click, Button26.Click

        buttonlist(1) = Button1
        buttonlist(2) = Button2
        buttonlist(3) = Button3
        buttonlist(4) = Button4
        buttonlist(5) = Button5
        buttonlist(6) = Button6
        buttonlist(7) = Button7
        buttonlist(8) = Button8
        buttonlist(9) = Button9
        buttonlist(10) = Button10
        buttonlist(11) = Button11
        buttonlist(12) = Button12
        buttonlist(13) = Button13
        buttonlist(14) = Button14
        buttonlist(15) = Button15
        buttonlist(16) = Button16
        buttonlist(17) = Button17
        buttonlist(18) = Button18
        buttonlist(19) = Button19
        buttonlist(20) = Button20
        buttonlist(20) = Button20
        buttonlist(21) = Button21
        buttonlist(22) = Button22
        buttonlist(23) = Button23
        buttonlist(24) = Button24
        buttonlist(25) = Button25
        buttonlist(26) = Button26

        index = Array.IndexOf(buttonlist, sender)
        buttonlist(index).Visible = False
        strletter = buttonlist(index).Text
        lstLetters.Items.Add(strletter)

       

        If letterFound() Then
            displayStars(1)
            If lblWord.Text = magicWord Then newGame()

        Else
            bodyParts = bodyParts + 1
            If bodyParts <= 6 AndAlso rdbImage.Checked = True Then
                showManImages(bodyParts)


                If bodyParts <= 6 AndAlso rdbDraw.Checked = True Then
                    PictureBox1.Refresh()
                End If

            End If
            End If

    End Sub

    Private Sub resetGame()
        lstOutput.Items.Clear()
        lstLetters.Items.Clear()
        lstWord.Items.Clear()
        bodyParts = 0
        get_magic_word()
        displayStars(0)
        lblResult.Text = ""
        PictureBoxBack.Visible = True
        PictureBoxHead.Visible = False
        PictureBoxNeck.Visible = False
        PictureBoxBody.Visible = False
        PictureBoxArms.Visible = False
        PictureBoxLegs.Visible = False
        PictureBoxRope.Visible = False
       



    End Sub
    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        If rdbDraw.Checked Then
            If bodyParts >= 1 Then
                ' head
                e.Graphics.DrawEllipse(Pens.Black, New Rectangle(0, 0, 10, 10))
            End If
            If bodyParts >= 2 Then
                ' body
                e.Graphics.DrawLine(Pens.Black, 5, 10, 5, 30)
            End If
            If bodyParts >= 3 Then
                ' left arm
                e.Graphics.DrawLine(Pens.Black, 5, 15, 0, 20)
            End If
            If bodyParts >= 4 Then
                ' right arm
                e.Graphics.DrawLine(Pens.Black, 5, 15, 10, 20)
            End If
            If bodyParts >= 5 Then
                ' left leg
                e.Graphics.DrawLine(Pens.Black, 5, 30, 0, 35)
            End If
            If bodyParts >= 6 Then
                ' right leg
                e.Graphics.DrawLine(Pens.Black, 5, 30, 10, 35)
            End If
        End If
    End Sub

    Private Sub showManImages(ByVal part As Integer)
        If rdbImage.Checked = True Then
            If part = 1 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" O ")
                PictureBoxHead.Visible = True
                lblResult.Text = "Wrong!"


            ElseIf part = 2 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" O ")
                lstOutput.Items.Add(" | ")
                PictureBoxNeck.Visible = True
                lblResult.Text = "Wrong!"


            ElseIf part = 3 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" O ")
                lstOutput.Items.Add(" | ")
                lstOutput.Items.Add(" = ")
                PictureBoxBody.Visible = True
                lblResult.Text = "Wrong!"


            ElseIf part = 4 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" O ")
                lstOutput.Items.Add("/|\")
                lstOutput.Items.Add(" = ")
                PictureBoxArms.Visible = True
                lblResult.Text = "Wrong!"


            ElseIf part = 5 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" O ")
                lstOutput.Items.Add("/|\")
                lstOutput.Items.Add(" = ")
                lstOutput.Items.Add("/ \")
                PictureBoxLegs.Visible = True
                lblResult.Text = "Warning: Man is almost hung!"


            ElseIf part = 6 Then
                lstOutput.Items.Clear()
                lstOutput.Items.Add(" | ")
                lstOutput.Items.Add(" O ")
                lstOutput.Items.Add("/|\")
                lstOutput.Items.Add(" = ")
                lstOutput.Items.Add("/ \")
                PictureBoxRope.Visible = True
                lblResult.Text = "Man was hung"
                game_over()

            End If

        End If

    End Sub

    Private Sub game_over()
        MsgBox("Game Over. The word was " & magicWord)
        resetGame()
        For index = 1 To 26
            buttonlist(index).Visible = True
        Next
    End Sub

    Private Sub newGame()
        MsgBox("Good Job! You got the word right. ")
        resetGame()
        For index = 1 To 26
            buttonlist(index).Visible = True
        Next
    End Sub

        Private Sub get_magic_word()
        readMagicWord()
    End Sub

    Private Sub btnNewGame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewGame.Click
        resetGame()
        For index = 1 To 26
            buttonlist(index).Visible = True
        Next
    End Sub
End Class
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12397495
I need the controls layout as well.

~IM
0
 

Author Comment

by:SEstudent
ID: 12397550

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents Button6 As System.Windows.Forms.Button
    Friend WithEvents Button7 As System.Windows.Forms.Button
    Friend WithEvents Button8 As System.Windows.Forms.Button
    Friend WithEvents Button9 As System.Windows.Forms.Button
    Friend WithEvents Button10 As System.Windows.Forms.Button
    Friend WithEvents Button11 As System.Windows.Forms.Button
    Friend WithEvents Button12 As System.Windows.Forms.Button
    Friend WithEvents Button13 As System.Windows.Forms.Button
    Friend WithEvents Button14 As System.Windows.Forms.Button
    Friend WithEvents Button15 As System.Windows.Forms.Button
    Friend WithEvents Button16 As System.Windows.Forms.Button
    Friend WithEvents Button17 As System.Windows.Forms.Button
    Friend WithEvents Button18 As System.Windows.Forms.Button
    Friend WithEvents Button19 As System.Windows.Forms.Button
    Friend WithEvents Button20 As System.Windows.Forms.Button
    Friend WithEvents Button21 As System.Windows.Forms.Button
    Friend WithEvents Button22 As System.Windows.Forms.Button
    Friend WithEvents Button23 As System.Windows.Forms.Button
    Friend WithEvents Button24 As System.Windows.Forms.Button
    Friend WithEvents Button25 As System.Windows.Forms.Button
    Friend WithEvents Button26 As System.Windows.Forms.Button
    Friend WithEvents lblWord As System.Windows.Forms.Label
    Friend WithEvents lstLetters As System.Windows.Forms.ListBox
    Friend WithEvents lstOutput As System.Windows.Forms.ListBox
    Friend WithEvents lstWord As System.Windows.Forms.ListBox
    Friend WithEvents lblResult As System.Windows.Forms.Label
    Friend WithEvents btnNewGame As System.Windows.Forms.Button
    Friend WithEvents PictureBoxNeck As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxBody As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxBack As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxArms As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxLegs As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxRope As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBoxHead As System.Windows.Forms.PictureBox
    Friend WithEvents rdbDraw As System.Windows.Forms.RadioButton
    Friend WithEvents rdbImage As System.Windows.Forms.RadioButton
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button5 = New System.Windows.Forms.Button
        Me.Button6 = New System.Windows.Forms.Button
        Me.Button7 = New System.Windows.Forms.Button
        Me.Button8 = New System.Windows.Forms.Button
        Me.Button9 = New System.Windows.Forms.Button
        Me.Button10 = New System.Windows.Forms.Button
        Me.Button11 = New System.Windows.Forms.Button
        Me.Button12 = New System.Windows.Forms.Button
        Me.Button13 = New System.Windows.Forms.Button
        Me.Button14 = New System.Windows.Forms.Button
        Me.Button15 = New System.Windows.Forms.Button
        Me.Button16 = New System.Windows.Forms.Button
        Me.Button17 = New System.Windows.Forms.Button
        Me.Button18 = New System.Windows.Forms.Button
        Me.Button19 = New System.Windows.Forms.Button
        Me.Button20 = New System.Windows.Forms.Button
        Me.Button21 = New System.Windows.Forms.Button
        Me.Button22 = New System.Windows.Forms.Button
        Me.Button23 = New System.Windows.Forms.Button
        Me.Button24 = New System.Windows.Forms.Button
        Me.Button25 = New System.Windows.Forms.Button
        Me.Button26 = New System.Windows.Forms.Button
        Me.lblWord = New System.Windows.Forms.Label
        Me.lstLetters = New System.Windows.Forms.ListBox
        Me.lstOutput = New System.Windows.Forms.ListBox
        Me.lstWord = New System.Windows.Forms.ListBox
        Me.lblResult = New System.Windows.Forms.Label
        Me.btnNewGame = New System.Windows.Forms.Button
        Me.PictureBoxHead = New System.Windows.Forms.PictureBox
        Me.PictureBoxNeck = New System.Windows.Forms.PictureBox
        Me.PictureBoxBody = New System.Windows.Forms.PictureBox
        Me.PictureBoxBack = New System.Windows.Forms.PictureBox
        Me.PictureBoxArms = New System.Windows.Forms.PictureBox
        Me.PictureBoxLegs = New System.Windows.Forms.PictureBox
        Me.PictureBoxRope = New System.Windows.Forms.PictureBox
        Me.rdbDraw = New System.Windows.Forms.RadioButton
        Me.rdbImage = New System.Windows.Forms.RadioButton
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(32, 216)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(24, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "a"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(64, 216)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(24, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "b"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(96, 216)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(24, 23)
        Me.Button3.TabIndex = 2
        Me.Button3.Text = "c"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(128, 216)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(24, 23)
        Me.Button4.TabIndex = 3
        Me.Button4.Text = "d"
        '
        'Button5
        '
        Me.Button5.Location = New System.Drawing.Point(160, 216)
        Me.Button5.Name = "Button5"
        Me.Button5.Size = New System.Drawing.Size(24, 23)
        Me.Button5.TabIndex = 4
        Me.Button5.Text = "e"
        '
        'Button6
        '
        Me.Button6.Location = New System.Drawing.Point(192, 216)
        Me.Button6.Name = "Button6"
        Me.Button6.Size = New System.Drawing.Size(24, 23)
        Me.Button6.TabIndex = 5
        Me.Button6.Text = "f"
        '
        'Button7
        '
        Me.Button7.Location = New System.Drawing.Point(224, 216)
        Me.Button7.Name = "Button7"
        Me.Button7.Size = New System.Drawing.Size(24, 23)
        Me.Button7.TabIndex = 6
        Me.Button7.Text = "g"
        '
        'Button8
        '
        Me.Button8.Location = New System.Drawing.Point(32, 248)
        Me.Button8.Name = "Button8"
        Me.Button8.Size = New System.Drawing.Size(24, 23)
        Me.Button8.TabIndex = 7
        Me.Button8.Text = "h"
        '
        'Button9
        '
        Me.Button9.Location = New System.Drawing.Point(64, 248)
        Me.Button9.Name = "Button9"
        Me.Button9.Size = New System.Drawing.Size(24, 23)
        Me.Button9.TabIndex = 8
        Me.Button9.Text = "i"
        '
        'Button10
        '
        Me.Button10.Location = New System.Drawing.Point(96, 248)
        Me.Button10.Name = "Button10"
        Me.Button10.Size = New System.Drawing.Size(24, 23)
        Me.Button10.TabIndex = 9
        Me.Button10.Text = "j"
        '
        'Button11
        '
        Me.Button11.Location = New System.Drawing.Point(128, 248)
        Me.Button11.Name = "Button11"
        Me.Button11.Size = New System.Drawing.Size(24, 23)
        Me.Button11.TabIndex = 10
        Me.Button11.Text = "k"
        '
        'Button12
        '
        Me.Button12.Location = New System.Drawing.Point(160, 248)
        Me.Button12.Name = "Button12"
        Me.Button12.Size = New System.Drawing.Size(24, 23)
        Me.Button12.TabIndex = 11
        Me.Button12.Text = "l"
        '
        'Button13
        '
        Me.Button13.Location = New System.Drawing.Point(192, 248)
        Me.Button13.Name = "Button13"
        Me.Button13.Size = New System.Drawing.Size(24, 23)
        Me.Button13.TabIndex = 12
        Me.Button13.Text = "m"
        '
        'Button14
        '
        Me.Button14.Location = New System.Drawing.Point(224, 248)
        Me.Button14.Name = "Button14"
        Me.Button14.Size = New System.Drawing.Size(24, 23)
        Me.Button14.TabIndex = 13
        Me.Button14.Text = "n"
        '
        'Button15
        '
        Me.Button15.Location = New System.Drawing.Point(32, 280)
        Me.Button15.Name = "Button15"
        Me.Button15.Size = New System.Drawing.Size(24, 23)
        Me.Button15.TabIndex = 14
        Me.Button15.Text = "o"
        '
        'Button16
        '
        Me.Button16.Location = New System.Drawing.Point(64, 280)
        Me.Button16.Name = "Button16"
        Me.Button16.Size = New System.Drawing.Size(24, 23)
        Me.Button16.TabIndex = 15
        Me.Button16.Text = "p"
        '
        'Button17
        '
        Me.Button17.Location = New System.Drawing.Point(96, 280)
        Me.Button17.Name = "Button17"
        Me.Button17.Size = New System.Drawing.Size(24, 23)
        Me.Button17.TabIndex = 16
        Me.Button17.Text = "q"
        '
        'Button18
        '
        Me.Button18.Location = New System.Drawing.Point(128, 280)
        Me.Button18.Name = "Button18"
        Me.Button18.Size = New System.Drawing.Size(24, 23)
        Me.Button18.TabIndex = 17
        Me.Button18.Text = "r"
        '
        'Button19
        '
        Me.Button19.Location = New System.Drawing.Point(160, 280)
        Me.Button19.Name = "Button19"
        Me.Button19.Size = New System.Drawing.Size(24, 23)
        Me.Button19.TabIndex = 18
        Me.Button19.Text = "s"
        '
        'Button20
        '
        Me.Button20.Location = New System.Drawing.Point(192, 280)
        Me.Button20.Name = "Button20"
        Me.Button20.Size = New System.Drawing.Size(24, 23)
        Me.Button20.TabIndex = 19
        Me.Button20.Text = "t"
        '
        'Button21
        '
        Me.Button21.Location = New System.Drawing.Point(224, 280)
        Me.Button21.Name = "Button21"
        Me.Button21.Size = New System.Drawing.Size(24, 23)
        Me.Button21.TabIndex = 20
        Me.Button21.Text = "u"
        '
        'Button22
        '
        Me.Button22.Location = New System.Drawing.Point(64, 312)
        Me.Button22.Name = "Button22"
        Me.Button22.Size = New System.Drawing.Size(24, 23)
        Me.Button22.TabIndex = 21
        Me.Button22.Text = "v"
        '
        'Button23
        '
        Me.Button23.Location = New System.Drawing.Point(96, 312)
        Me.Button23.Name = "Button23"
        Me.Button23.Size = New System.Drawing.Size(24, 23)
        Me.Button23.TabIndex = 22
        Me.Button23.Text = "w"
        '
        'Button24
        '
        Me.Button24.Location = New System.Drawing.Point(128, 312)
        Me.Button24.Name = "Button24"
        Me.Button24.Size = New System.Drawing.Size(24, 23)
        Me.Button24.TabIndex = 23
        Me.Button24.Text = "x"
        '
        'Button25
        '
        Me.Button25.Location = New System.Drawing.Point(160, 312)
        Me.Button25.Name = "Button25"
        Me.Button25.Size = New System.Drawing.Size(24, 23)
        Me.Button25.TabIndex = 24
        Me.Button25.Text = "y"
        '
        'Button26
        '
        Me.Button26.Location = New System.Drawing.Point(192, 312)
        Me.Button26.Name = "Button26"
        Me.Button26.Size = New System.Drawing.Size(24, 23)
        Me.Button26.TabIndex = 25
        Me.Button26.Text = "z"
        '
        'lblWord
        '
        Me.lblWord.Location = New System.Drawing.Point(32, 40)
        Me.lblWord.Name = "lblWord"
        Me.lblWord.TabIndex = 26
        '
        'lstLetters
        '
        Me.lstLetters.Location = New System.Drawing.Point(160, 24)
        Me.lstLetters.Name = "lstLetters"
        Me.lstLetters.Size = New System.Drawing.Size(72, 134)
        Me.lstLetters.TabIndex = 27
        '
        'lstOutput
        '
        Me.lstOutput.Location = New System.Drawing.Point(264, 192)
        Me.lstOutput.Name = "lstOutput"
        Me.lstOutput.Size = New System.Drawing.Size(80, 134)
        Me.lstOutput.TabIndex = 28
        '
        'lstWord
        '
        Me.lstWord.Location = New System.Drawing.Point(248, 24)
        Me.lstWord.Name = "lstWord"
        Me.lstWord.Size = New System.Drawing.Size(88, 134)
        Me.lstWord.TabIndex = 29
        '
        'lblResult
        '
        Me.lblResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.lblResult.Location = New System.Drawing.Point(8, 376)
        Me.lblResult.Name = "lblResult"
        Me.lblResult.Size = New System.Drawing.Size(248, 23)
        Me.lblResult.TabIndex = 31
        '
        'btnNewGame
        '
        Me.btnNewGame.Location = New System.Drawing.Point(280, 376)
        Me.btnNewGame.Name = "btnNewGame"
        Me.btnNewGame.TabIndex = 32
        Me.btnNewGame.Text = "New Game"
        '
        'PictureBoxHead
        '
        Me.PictureBoxHead.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxHead.Image = CType(resources.GetObject("PictureBoxHead.Image"), System.Drawing.Image)
        Me.PictureBoxHead.Location = New System.Drawing.Point(432, 56)
        Me.PictureBoxHead.Name = "PictureBoxHead"
        Me.PictureBoxHead.Size = New System.Drawing.Size(183, 74)
        Me.PictureBoxHead.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxHead.TabIndex = 35
        Me.PictureBoxHead.TabStop = False
        '
        'PictureBoxNeck
        '
        Me.PictureBoxNeck.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxNeck.Image = CType(resources.GetObject("PictureBoxNeck.Image"), System.Drawing.Image)
        Me.PictureBoxNeck.Location = New System.Drawing.Point(424, 56)
        Me.PictureBoxNeck.Name = "PictureBoxNeck"
        Me.PictureBoxNeck.Size = New System.Drawing.Size(183, 99)
        Me.PictureBoxNeck.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxNeck.TabIndex = 36
        Me.PictureBoxNeck.TabStop = False
        '
        'PictureBoxBody
        '
        Me.PictureBoxBody.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxBody.Image = CType(resources.GetObject("PictureBoxBody.Image"), System.Drawing.Image)
        Me.PictureBoxBody.Location = New System.Drawing.Point(480, 152)
        Me.PictureBoxBody.Name = "PictureBoxBody"
        Me.PictureBoxBody.Size = New System.Drawing.Size(64, 88)
        Me.PictureBoxBody.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxBody.TabIndex = 37
        Me.PictureBoxBody.TabStop = False
        '
        'PictureBoxBack
        '
        Me.PictureBoxBack.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxBack.Location = New System.Drawing.Point(400, 16)
        Me.PictureBoxBack.Name = "PictureBoxBack"
        Me.PictureBoxBack.Size = New System.Drawing.Size(216, 400)
        Me.PictureBoxBack.TabIndex = 38
        Me.PictureBoxBack.TabStop = False
        Me.PictureBoxBack.Visible = False
        '
        'PictureBoxArms
        '
        Me.PictureBoxArms.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxArms.Image = CType(resources.GetObject("PictureBoxArms.Image"), System.Drawing.Image)
        Me.PictureBoxArms.Location = New System.Drawing.Point(424, 144)
        Me.PictureBoxArms.Name = "PictureBoxArms"
        Me.PictureBoxArms.Size = New System.Drawing.Size(183, 89)
        Me.PictureBoxArms.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxArms.TabIndex = 39
        Me.PictureBoxArms.TabStop = False
        '
        'PictureBoxLegs
        '
        Me.PictureBoxLegs.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.PictureBoxLegs.Image = CType(resources.GetObject("PictureBoxLegs.Image"), System.Drawing.Image)
        Me.PictureBoxLegs.Location = New System.Drawing.Point(424, 232)
        Me.PictureBoxLegs.Name = "PictureBoxLegs"
        Me.PictureBoxLegs.Size = New System.Drawing.Size(183, 81)
        Me.PictureBoxLegs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxLegs.TabIndex = 40
        Me.PictureBoxLegs.TabStop = False
        '
        'PictureBoxRope
        '
        Me.PictureBoxRope.Image = CType(resources.GetObject("PictureBoxRope.Image"), System.Drawing.Image)
        Me.PictureBoxRope.Location = New System.Drawing.Point(424, 16)
        Me.PictureBoxRope.Name = "PictureBoxRope"
        Me.PictureBoxRope.Size = New System.Drawing.Size(183, 400)
        Me.PictureBoxRope.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.PictureBoxRope.TabIndex = 41
        Me.PictureBoxRope.TabStop = False
        '
        'rdbDraw
        '
        Me.rdbDraw.Location = New System.Drawing.Point(24, 88)
        Me.rdbDraw.Name = "rdbDraw"
        Me.rdbDraw.Size = New System.Drawing.Size(112, 24)
        Me.rdbDraw.TabIndex = 42
        Me.rdbDraw.Text = "Draw"
        '
        'rdbImage
        '
        Me.rdbImage.Location = New System.Drawing.Point(24, 136)
        Me.rdbImage.Name = "rdbImage"
        Me.rdbImage.TabIndex = 43
        Me.rdbImage.Text = "Images"
        '
        'PictureBox1
        '
        Me.PictureBox1.Location = New System.Drawing.Point(704, 56)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(216, 280)
        Me.PictureBox1.TabIndex = 44
        Me.PictureBox1.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(960, 438)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.rdbImage)
        Me.Controls.Add(Me.rdbDraw)
        Me.Controls.Add(Me.PictureBoxRope)
        Me.Controls.Add(Me.PictureBoxNeck)
        Me.Controls.Add(Me.btnNewGame)
        Me.Controls.Add(Me.lblResult)
        Me.Controls.Add(Me.lstWord)
        Me.Controls.Add(Me.lstOutput)
        Me.Controls.Add(Me.lstLetters)
        Me.Controls.Add(Me.lblWord)
        Me.Controls.Add(Me.Button26)
        Me.Controls.Add(Me.Button25)
        Me.Controls.Add(Me.Button24)
        Me.Controls.Add(Me.Button23)
        Me.Controls.Add(Me.Button22)
        Me.Controls.Add(Me.Button21)
        Me.Controls.Add(Me.Button20)
        Me.Controls.Add(Me.Button19)
        Me.Controls.Add(Me.Button18)
        Me.Controls.Add(Me.Button17)
        Me.Controls.Add(Me.Button16)
        Me.Controls.Add(Me.Button15)
        Me.Controls.Add(Me.Button14)
        Me.Controls.Add(Me.Button13)
        Me.Controls.Add(Me.Button12)
        Me.Controls.Add(Me.Button11)
        Me.Controls.Add(Me.Button10)
        Me.Controls.Add(Me.Button9)
        Me.Controls.Add(Me.Button8)
        Me.Controls.Add(Me.Button7)
        Me.Controls.Add(Me.Button6)
        Me.Controls.Add(Me.Button5)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.PictureBoxLegs)
        Me.Controls.Add(Me.PictureBoxArms)
        Me.Controls.Add(Me.PictureBoxHead)
        Me.Controls.Add(Me.PictureBoxBody)
        Me.Controls.Add(Me.PictureBoxBack)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region
0
 

Author Comment

by:SEstudent
ID: 12398313

Please let me know if this is enough..

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12399979
The problem is here:

            bodyParts = bodyParts + 1
            If bodyParts <= 6 AndAlso rdbImage.Checked = True Then
                showManImages(bodyParts)

                If bodyParts <= 6 AndAlso rdbDraw.Checked = True Then
                    PictureBox1.Refresh()
                End If

            End If

If rdgImage.Checked = True then rdbDraw.Checked cannot also be true:

            bodyParts = bodyParts + 1
            If bodyparts <= 6 Then
                If rdbImage.Checked = True Then
                    showManImages(bodyparts)
                ElseIf rdbDraw.Checked = True Then
                    PictureBox1.Refresh()
                End If
            End If

~IM
0
 

Author Comment

by:SEstudent
ID: 12407646

thank you that works :)

One last question for you

how can make my graph bigger..I tried to change the numbers but that doesn't work

thanks
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 12407774
You could do something like this so the hangman will scale to fit whatever the current size of the PictureBox is:

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        If rdbDraw.Checked Then
            If bodyParts >= 1 Then
                ' head
                e.Graphics.DrawEllipse(Pens.Black, New Rectangle(PictureBox1.Width / 4, 0, PictureBox1.Width / 2, PictureBox1.Height / 4))
            End If
            If bodyParts >= 2 Then
                ' body
                e.Graphics.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height / 4), CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height - PictureBox1.Height / 4))
            End If
            If bodyParts >= 3 Then
                ' left arm
                e.Graphics.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height / 2), CInt(PictureBox1.Width / 4), CInt(PictureBox1.Height - PictureBox1.Height / 4))
            End If
            If bodyParts >= 4 Then
                ' right arm
                e.Graphics.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height / 2), CInt(PictureBox1.Width - PictureBox1.Width / 4), CInt(PictureBox1.Height - PictureBox1.Height / 4))
            End If
            If bodyParts >= 5 Then
                ' left leg
                e.Graphics.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height - PictureBox1.Height / 4), CInt(PictureBox1.Width / 4), CInt(PictureBox1.Height))
            End If
            If bodyParts >= 6 Then
                ' right leg
                e.Graphics.DrawLine(Pens.Black, CInt(PictureBox1.Width / 2), CInt(PictureBox1.Height - PictureBox1.Height / 4), CInt(PictureBox1.Width - PictureBox1.Width / 4), CInt(PictureBox1.Height))
            End If
        End If
    End Sub
0
 

Author Comment

by:SEstudent
ID: 12407822

it works :)

thanks a lot...
0
 

Author Comment

by:SEstudent
ID: 12408472

Can I ask one last question please

how to erase all the drawings from the picturebox?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12410110
Like so:

    bodyParts = 0
    PictureBox1.Refresh()

~IM
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question