Imports System.Runtime.InteropServices
Public Class ArrangeDiceForm
Dim lucky_3_1_str As String = "Lucky 3-Card Bonus"
Dim lucky_3_2_str As String = "Lucky 3-Card Bonus"
Dim lucky_4_1_str As String = "Lucky 4-Card Bonus"
Dim lucky_4_2_str As String = "Lucky 4-Card Bonus"
Dim lucky_5_1_str As String = "Lucky 5-Card Bonus"
Dim lucky_5_2_str As String = "Lucky 5-Card Bonus"
Dim lucky3 As Boolean = False
Dim lucky11 As Boolean = False
Dim lucky_3_1_bool As Boolean = False
Dim lucky_3_2_bool As Boolean = False
Dim lucky_4_1_bool As Boolean = False
Dim lucky_4_2_bool As Boolean = False
Dim lucky_5_1_bool As Boolean = False
Dim lucky_5_2_bool As Boolean = False
Dim pinzoro_int As Integer = 0
Dim turn As Integer = 0
Dim random As Random = New Random()
Dim cardOrder() As Integer 'Called at Form1_Load
'##########END DIMS########'
'######ArrangeDice LOAD######
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
PictureBox2.AllowDrop = True
PictureBox3.AllowDrop = True
PictureBox4.AllowDrop = True
PictureBox5.AllowDrop = True
PictureBox6.AllowDrop = True
PictureBox7.AllowDrop = True
PictureBox8.AllowDrop = True
PictureBox9.AllowDrop = True
PictureBox1.Tag = 3
PictureBox2.Tag = 4
PictureBox3.Tag = 5
PictureBox4.Tag = 6
PictureBox5.Tag = 7
PictureBox6.Tag = 8
PictureBox7.Tag = 9
PictureBox8.Tag = 10
PictureBox9.Tag = 11
cardOrder = (From pb In Me.Controls.OfType(Of PictureBox)() _
Order By pb.Left _
Select CInt(pb.Tag)).ToArray
End Sub
'######ARRANGE DICE LOAD END'#######
'##########CARD SWAP########'
#Region "Card Swap"
Private Sub PictureBoxes_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragDrop, PictureBox3.DragDrop, PictureBox4.DragDrop, PictureBox5.DragDrop, PictureBox6.DragDrop, PictureBox7.DragDrop, PictureBox8.DragDrop, PictureBox1.DragDrop, PictureBox9.DragDrop
Dim target As PictureBox = DirectCast(sender, PictureBox)
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
Dim sourceCardTag As Integer = CInt(source.Tag)
source.Image = target.Image
target.Image = DirectCast(e.Data.GetData(DataFormats.Bitmap), Bitmap)
target.Tag = sourceCardTag
cardOrder = (From pb In Me.Controls.OfType(Of PictureBox)() _
Order By pb.Left _
Select CInt(pb.Tag)).ToArray
End If
End Sub
Private Sub PictureBoxes_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragOver, PictureBox3.DragOver, PictureBox4.DragOver, PictureBox5.DragOver, PictureBox6.DragOver, PictureBox7.DragOver, PictureBox8.DragOver, PictureBox1.DragDrop, PictureBox9.DragOver, PictureBox1.DragOver
'make sure drag drop data can be used
If e.Data.GetDataPresent(DataFormats.Bitmap) And e.AllowedEffect = DragDropEffects.Move Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub
Dim source As PictureBox
Dim image As Bitmap
Private Sub card_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown, PictureBox3.MouseDown, PictureBox4.MouseDown, PictureBox5.MouseDown, PictureBox6.MouseDown, PictureBox7.MouseDown, PictureBox8.MouseDown, PictureBox9.MouseDown, PictureBox1.MouseDown
source = DirectCast(sender, PictureBox)
image = DirectCast(source.Image.Clone, Bitmap)
source.DoDragDrop(image, DragDropEffects.Move)
End Sub
Public Sub PictureBoxes_giveFeedback(ByVal sender As Object, ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles PictureBox2.GiveFeedback, PictureBox3.GiveFeedback, PictureBox4.GiveFeedback, PictureBox5.GiveFeedback, PictureBox6.GiveFeedback, PictureBox7.GiveFeedback, PictureBox8.GiveFeedback, PictureBox1.GiveFeedback, PictureBox9.GiveFeedback
e.UseDefaultCursors = False
Dim EffectCursor As New Cursor(New IO.MemoryStream(My.Resources.Move))
Dim img As New Bitmap(15 + image.Width, 26 + image.Height)
Dim gr As Graphics = Graphics.FromImage(img)
gr.FillRectangle(Brushes.Magenta, img.GetBounds(Drawing.GraphicsUnit.Pixel))
EffectCursor.Draw(gr, New Rectangle(50, 50, _
EffectCursor.Size.Width, EffectCursor.Size.Height))
gr.DrawImage(image, 15, 26, image.Width, image.Height)
img.MakeTransparent(Color.Magenta)
Cursor.Current = CreateCursor(img)
End Sub
#Region " CreateIconIndirect"
Private Structure IconInfo
Public fIcon As Boolean
Public xHotspot As Int32
Public yHotspot As Int32
Public hbmMask As IntPtr
Public hbmColor As IntPtr
End Structure
<DllImport("user32.dll", EntryPoint:="CreateIconIndirect")> _
Private Shared Function CreateIconIndirect(ByVal iconInfo As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("gdi32.dll")> _
Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Boolean
End Function
'''<summary>
''' CreateCursor
''' </summary>
''' <param name="bmp"></param>
''' <returns>custom Cursor</returns>
'''<remarks>creates a custom cursor from a bitmap</remarks>
Public Function CreateCursor(ByVal bmp As Bitmap) As Cursor
'Setup the Cursors IconInfo
Dim tmp As New IconInfo
tmp.xHotspot = 50
tmp.yHotspot = 50
tmp.fIcon = False
tmp.hbmMask = bmp.GetHbitmap()
tmp.hbmColor = bmp.GetHbitmap()
'Create the Pointer for the Cursor Icon
Dim pnt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tmp))
Marshal.StructureToPtr(tmp, pnt, True)
Dim curPtr As IntPtr = CreateIconIndirect(pnt)
'Clean Up
DestroyIcon(pnt)
DeleteObject(tmp.hbmMask)
DeleteObject(tmp.hbmColor)
Return New Cursor(curPtr)
End Function
#End Region
#End Region
Private Sub Label11_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.MouseEnter, Label8.MouseEnter, Label7.MouseEnter, Label6.MouseEnter, Label5.MouseEnter, Label4.MouseEnter, Label3.MouseEnter, Label11.MouseEnter, Label10.MouseEnter
Label3.Text = PictureBox1.Tag
Label4.Text = PictureBox2.Tag
Label5.Text = PictureBox3.Tag
Label6.Text = PictureBox4.Tag
Label7.Text = PictureBox5.Tag
Label8.Text = PictureBox6.Tag
Label9.Text = PictureBox7.Tag
Label10.Text = PictureBox8.Tag
Label11.Text = PictureBox9.Tag
End Sub
End Class