1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
| Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
picDropTarget1.AllowDrop = True
picDropTarget2.AllowDrop = True
picDropTarget3.AllowDrop = True
picDropTarget4.AllowDrop = True
picDropTarget5.AllowDrop = True
picDropTarget6.AllowDrop = True
picDropTarget7.AllowDrop = True
picDropTarget8.AllowDrop = True
picDropTarget9.AllowDrop = True
picDropTarget10.AllowDrop = True
picDropTarget11.AllowDrop = True
picDragSource1.Tag = "selectionner_le_chocolat.png"
picDragSource2.Tag = "afficher_prix_a_payer.png"
picDragSource3.Tag = "introduire_piece.png"
picDragSource4.Tag = "affiche_somme_versee.png"
picDragSource5.Tag = "somme_versee_superieure.png"
picDragSource6.Tag = "somme_versee_egale.png"
picDragSource7.Tag = "somme_versee_inferieure.png"
picDragSource8.Tag = "rendre_monnaie.png"
picDragSource9.Tag = "monnaie_rendue.png"
picDragSource10.Tag = "distribuer_chocolat.png"
picDragSource11.Tag = "chocolat_distribue.png"
End Sub
Private nomdelimage As String
Private MouseIsDown As Boolean = False 'flag
Private tagSource As String
' Start the drag.
Private Sub picDragSource_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDragSource1.MouseDown, picDragSource2.MouseDown, picDragSource9.MouseDown, picDragSource8.MouseDown, picDragSource7.MouseDown, picDragSource6.MouseDown, picDragSource5.MouseDown, picDragSource4.MouseDown, picDragSource3.MouseDown, picDragSource11.MouseDown, picDragSource10.MouseDown ', picDragSource3.MouseDown, picDragSource4.MouseDown, picDragSource5.MouseDown, picDragSource6.MouseDown, picDragSource7.MouseDown, picDragSource8.MouseDown, picDragSource9.MouseDown, picDragSource10.MouseDown, picDragSource11.MouseDown
' Start the drag if it's the left mouse button.
If (e.Button = MouseButtons.Left) Then
tagSource = DirectCast(sender, System.Windows.Forms.PictureBox).Tag
DirectCast(sender, PictureBox).DoDragDrop(DirectCast(sender, PictureBox).Image, DragDropEffects.Copy)
End If
End Sub
' Allow a copy of an image.
Private Sub picDropTarget_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picDropTarget2.DragEnter, picDropTarget1.DragEnter, picDropTarget9.DragEnter, picDropTarget8.DragEnter, picDropTarget7.DragEnter, picDropTarget6.DragEnter, picDropTarget5.DragEnter, picDropTarget4.DragEnter, picDropTarget3.DragEnter, picDropTarget11.DragEnter, picDropTarget10.DragEnter ' Handles picDropTarget1.DragEnter
' See if this is a copy and the data includes an image.
If (e.Data.GetDataPresent(DataFormats.Bitmap) AndAlso (e.AllowedEffect And DragDropEffects.Copy) <> 0) Then
' Allow this.
e.Effect = DragDropEffects.Copy
Else
' Don't allow any other drop.
e.Effect = DragDropEffects.None
End If
End Sub
'Accept the drop.
Private Sub picDropTarget_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picDropTarget2.DragDrop, picDropTarget1.DragDrop, picDropTarget9.DragDrop, picDropTarget8.DragDrop, picDropTarget7.DragDrop, picDropTarget6.DragDrop, picDropTarget5.DragDrop, picDropTarget4.DragDrop, picDropTarget3.DragDrop, picDropTarget11.DragDrop, picDropTarget10.DragDrop ' Handles picDropTarget1.DragDrop
Dim bm As Bitmap = DirectCast(e.Data.GetData(DataFormats.Bitmap, True), Bitmap)
Dim pb As PictureBox = DirectCast(sender, PictureBox)
pb.Tag = tagSource
pb.Image = bm
End Sub
' comptabilisation des reponses
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
picDragSource1.Tag = "selectionner_le_chocolat.png"
picDragSource2.Tag = "afficher_prix_a_payer.png"
picDragSource3.Tag = "introduire_piece.png"
picDragSource4.Tag = "affiche_somme_versee.png"
picDragSource5.Tag = "somme_versee_superieure.png"
picDragSource6.Tag = "somme_versee_egale.png"
picDragSource7.Tag = "somme_versee_inferieure.png"
picDragSource8.Tag = "rendre_monnaie.png"
picDragSource9.Tag = "monnaie_rendue.png"
picDragSource10.Tag = "distribuer_chocolat.png"
picDragSource11.Tag = "chocolat_distribue.png"
Dim iResult As Integer = 0
If picDropTarget1.Tag = "selectionner_le_chocolat.png" Then
iResult = iResult + 1
End If
If picDropTarget2.Tag = "afficher_prix_a_payer.png" Then
iResult = iResult + 1
End If
If picDropTarget3.Tag = "introduire_piece.png" Then
iResult = iResult + 1
End If
If picDropTarget4.Tag = "affiche_somme_versee.png" Then
iResult = iResult + 1
End If
If picDropTarget5.Tag = "somme_versee_superieure.png" Then
iResult = iResult + 1
End If
If picDropTarget6.Tag = "somme_versee_egale.png" Then
iResult = iResult + 1
End If
If picDropTarget7.Tag = "somme_versee_inferieure.png" Then
iResult = iResult + 1
End If
If picDropTarget8.Tag = "rendre_monnaie.png" Then
iResult = iResult + 1
End If
If picDropTarget9.Tag = "monnaie_rendue.png" Then
iResult = iResult + 1
End If
If picDropTarget10.Tag = "distribuer_chocolat.png" Then
iResult = iResult + 1
End If
If picDropTarget11.Tag = "chocolat_distribue.png" Then
iResult = iResult + 1
End If
'affichage du resultat arrondi à 2 decimales
Dim manote
manote = iResult * (20 / 11)
TextBox1.Text = iResult & " bonnes réponses. soit : " & " " & (FormatNumber(manote, 2) & " /20")
End Sub
' effacement
Private Sub picDropTarget_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picDropTarget9.DoubleClick, picDropTarget8.DoubleClick, picDropTarget7.DoubleClick, picDropTarget6.DoubleClick, picDropTarget5.DoubleClick, picDropTarget4.DoubleClick, picDropTarget3.DoubleClick, picDropTarget2.DoubleClick, picDropTarget11.DoubleClick, picDropTarget10.DoubleClick, picDropTarget1.DoubleClick
DirectCast(sender, PictureBox).Image = Nothing
DirectCast(sender, PictureBox).Tag = ""
End Sub
End Class |
Partager