Public
Class
handViewer
Sub
setName(name
As
String
)
Label1.Text = name
End
setImage(
Optional
hand
List(Of Card) =
Nothing
Dim
img
Bitmap =
If
Not
Is
Then
img =
New
Bitmap(105 +
(hand.Count > 2, (hand.Count - 2) * 15, 0), 120)
gr
Graphics = Graphics.FromImage(img)
m
Drawing2D.Matrix
m.RotateAt(-20, Point.Empty)
gr.Transform = m
gr.DrawImage(hand(0).getImage,
Point(-8, 22))
gr.ResetTransform()
startX
Integer
= 33
For
x
= 1
To
hand.Count - 1
gr.DrawImage(hand(x).getImage,
Point(startX, 17))
startX += 15
Next
PictureBox1.Image = img
Private
PictureBox1_Resize(sender
Object
, e
EventArgs)
Handles
PictureBox1.Resize
Me
.Width = Math.Max(PictureBox1.Width, Label1.Width) + 6
Form1
WithEvents
game
BlackJack
Form1_Shown(sender
MyBase
.Shown
d
InputDialog
'this shows a modal Dialog with a prompt, and a title, with no DefaultResponse
d.ShowDialog(
"Enter your name"
,
"OOP BlackJack"
) = DialogResult.OK
playerName
= d.returnedValue
HandViewer1.setName(playerName)
HandViewer2.setName(
"Computer"
game =
BlackJack(
, playerName)
btnNewGame.PerformClick()
Else
Application.
Exit
()
btnNewGame_Click(sender
btnNewGame.Click
HandViewer1.setImage()
HandViewer2.setImage()
btnHit.Enabled =
True
btnStick.Enabled =
btnNewGame.Enabled =
False
game.NewGame()
btnStick_Click(sender
btnStick.Click
game.stick()
btnHit_Click(sender
btnHit.Click
game.hit()
game_displayHand(hand
List(Of Card), player
game.displayHand
player = 1
HandViewer1.setImage(hand)
HandViewer2.setImage(hand)
game_displayText(text
game.displayText
Label1.Text &= text & Environment.NewLine & Environment.NewLine
game_clearText()
game.clearText
Label1.Text =
""
game_isOver()
game.isOver
HandViewer1_Resize(sender
HandViewer1.Resize
HandViewer2.Left = HandViewer1.Right + 6