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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
Public nf20, nf21, nf22, nf23, nf24 As New Form2
Public nf25, nf26, nf27, nf28, nf29 As New Form2
Sub socketReception()
Do While Deconnecter = False
Try
Dim ipAdressServer As Net.IPAddress = Net.IPAddress.Parse(Net.Dns.GetHostAddresses(Net.Dns.GetHostName())(0).ToString)
s = New Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Stream, Net.Sockets.ProtocolType.Tcp)
s.Bind(New Net.IPEndPoint(ipAdressServer, 2030))
s.Listen(10)
Dim s2 As Net.Sockets.Socket = s.Accept()
Dim rbuf(1024) As Byte
Dim chaine As New System.Text.StringBuilder
ret = s2.Receive(rbuf, 0, 1024, Net.Sockets.SocketFlags.None)
chaine.Append(System.Text.Encoding.ASCII.GetString(rbuf, 0, ret))
texte = System.Text.Encoding.ASCII.GetString(rbuf, 0, ret)
debut = texte.Length - 3
Do While Mid(texte, debut, 3).ToString <> "///"
debut = debut - 1
If debut = 0 Then
Exit Do
End If
Loop
If Mid(texte, debut, 3) = "///" Then
implanter(texte, debut)
End If
s.Close()
Catch ex As Exception
If ex.Message = "Une opération de blocage a été interrompue par un appel à WSACancelBlockingCall" Then
Me.ToolStripStatusLabel1.Text = "Connecté"
Else
MsgBox(ex.Message)
End If
s.Close()
End Try
Loop
End Sub
Private Sub Listbox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Listbox1.DoubleClick
If Item_Selectionne <> "" Then
Select_Form()
End If
End Sub
Private Sub Listbox1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles Listbox1.ItemSelectionChanged
Item_Selectionne = e.Item.Text
End Sub
Public Sub Ouvrir_Form()
Modifier_nf()
Select Case "vide"
Case nf20.Name
nf20.Show()
nf20.Name = Mid(texte, debut + 3, texte.Length - (debut + 2))
nf20.Text = Mid(texte, debut + 3, texte.Length - (debut + 2))
nf20.ListBox1.Items.Add(Mid(texte, debut + 3, texte.Length - (debut + 2)) & " à dit :")
nf20.ListBox1.Items.Add(" " & Mid(texte, 1, debut - 1))
Case nf21.Name
nf21.Show()
nf21.Name = Mid(texte, debut + 3, texte.Length)
nf21.Text = Mid(texte, debut + 3, texte.Length)
Case nf22.Name
nf22.Show()
nf22.Name = Mid(texte, debut + 3, texte.Length)
nf22.Text = Mid(texte, debut + 3, texte.Length)
Case nf23.Name
nf23.Show()
nf23.Name = Mid(texte, debut + 3, texte.Length)
nf23.Text = Mid(texte, debut + 3, texte.Length)
Case nf24.Name
nf24.Show()
nf24.Name = Mid(texte, debut + 3, texte.Length)
nf24.Text = Mid(texte, debut + 3, texte.Length)
Case nf25.Name
nf25.Show()
nf25.Name = Mid(texte, debut + 3, texte.Length)
nf25.Text = Mid(texte, debut + 3, texte.Length)
Case nf26.Name
nf26.Show()
nf26.Name = Mid(texte, debut + 3, texte.Length)
nf26.Text = Mid(texte, debut + 3, texte.Length)
Case nf27.Name
nf27.Show()
nf27.Name = Mid(texte, debut + 3, texte.Length)
nf27.Text = Mid(texte, debut + 3, texte.Length)
Case nf28.Name
nf28.Show()
nf28.Name = Mid(texte, debut + 3, texte.Length)
nf28.Text = Mid(texte, debut + 3, texte.Length)
Case nf29.Name
nf29.Show()
nf29.Name = Mid(texte, debut + 3, texte.Length)
nf29.Text = Mid(texte, debut + 3, texte.Length)
End Select
End Sub
Public Sub Select_Form()
Modifier_nf()
Verification_Existance()
If Annuler_Ouverture = False Then
Select Case "vide"
Case nf20.Name
nf20.Show()
nf20.Name = Item_Selectionne
nf20.Text = Item_Selectionne
Case nf21.Name
nf21.Show()
nf21.Name = Item_Selectionne
nf21.Text = Item_Selectionne
Case nf22.Name
nf22.Show()
nf22.Name = Item_Selectionne
nf22.Text = Item_Selectionne
Case nf23.Name
nf23.Show()
nf23.Name = Item_Selectionne
nf23.Text = Item_Selectionne
Case nf24.Name
nf24.Show()
nf24.Name = Item_Selectionne
nf24.Text = Item_Selectionne
Case nf25.Name
nf25.Show()
nf25.Name = Item_Selectionne
nf25.Text = Item_Selectionne
Case nf26.Name
nf26.Show()
nf26.Name = Item_Selectionne
nf26.Text = Item_Selectionne
Case nf27.Name
nf27.Show()
nf27.Name = Item_Selectionne
nf27.Text = Item_Selectionne
Case nf28.Name
nf28.Show()
nf28.Name = Item_Selectionne
nf28.Text = Item_Selectionne
Case nf29.Name
nf29.Show()
nf29.Name = Item_Selectionne
nf29.Text = Item_Selectionne
Case Else
MsgBox("Vous ne pouvez pas ouvrir de fenêtre supplémentaire", MsgBoxStyle.Exclamation, "Limite dépassée")
End Select
End If
End Sub
Public Sub Nouvelle_Instance()
nf20.Name = "vide"
nf21.Name = "vide"
nf22.Name = "vide"
nf23.Name = "vide"
nf24.Name = "vide"
nf25.Name = "vide"
nf26.Name = "vide"
nf27.Name = "vide"
nf28.Name = "vide"
nf29.Name = "vide"
End Sub
Public Sub Modifier_nf()
If nf20.Name = Nothing Then
nf20 = New Form2
nf20.Name = "vide"
End If
If nf21.Name = Nothing Then
nf21 = New Form2
nf21.Name = "vide"
End If
If nf22.Name = Nothing Then
nf22 = New Form2
nf22.Name = "vide"
End If
If nf23.Name = Nothing Then
nf23 = New Form2
nf23.Name = "vide"
End If
If nf24.Name = Nothing Then
nf24 = New Form2
nf24.Name = "vide"
End If
If nf25.Name = Nothing Then
nf25 = New Form2
nf25.Name = "vide"
End If
If nf26.Name = Nothing Then
nf26 = New Form2
nf26.Name = "vide"
End If
If nf27.Name = Nothing Then
nf27 = New Form2
nf27.Name = "vide"
End If
If nf28.Name = Nothing Then
nf28 = New Form2
nf28.Name = "vide"
End If
If nf29.Name = Nothing Then
nf29 = New Form2
nf29.Name = "vide"
End If
End Sub
Public Sub Verification_Existance()
Annuler_Ouverture = False
If Item_Selectionne = nf20.Name Or Item_Selectionne = nf21.Name Or Item_Selectionne = nf22.Name Or Item_Selectionne = nf23.Name Or Item_Selectionne = nf24.Name Or Item_Selectionne = nf25.Name Or Item_Selectionne = nf26.Name Or Item_Selectionne = nf27.Name Or Item_Selectionne = nf28.Name Or Item_Selectionne = nf29.Name Then
MsgBox("Cette fenêtre de communication est déjà ouverte", MsgBoxStyle.Information, "Fenêtre ouverte.")
Annuler_Ouverture = True
End If
End Sub |
Partager