/
taticas.vb
130 lines (126 loc) · 5.16 KB
/
taticas.vb
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
Imports system.drawing.region
Imports System.Drawing.Size
Imports System.Drawing.Drawing2D
Public Class taticas
Public tat1Alterada, tat2Alterada As Boolean
Dim tatEscolhida1, tatEscolhida2 As Integer
Public tat As String
Public tat2 As String
Private WM_NCHITTEST As Integer = &H84
Private HTCLIENT As Integer = &H1 ' arrastar
Private HTCAPTION As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case WM_NCHITTEST
If m.Result = New IntPtr(HTCLIENT) Then
m.Result = New IntPtr(HTCAPTION)
End If
End Select
End Sub
Private Sub taticas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tatEscolhida1 = -1
tatEscolhida2 = -1
If My.Computer.FileSystem.DirectoryExists("C:\jogo") Then
If My.Computer.FileSystem.FileExists("C:\jogo\tatica") Then
Dim tat As IO.StreamReader = New IO.StreamReader("C:\jogo\tatica")
ComboBox1.SelectedIndex = ComboBox1.FindString(tat.ReadLine)
tat.Close()
End If
If My.Computer.FileSystem.FileExists("C:\jogo\tatica2") Then
Dim tat As IO.StreamReader = New IO.StreamReader("C:\jogo\tatica2")
ComboBox2.SelectedIndex = ComboBox2.FindString(tat.ReadLine)
tat.Close()
End If
End If
tatEscolhida1 = ComboBox1.SelectedIndex
tatEscolhida2 = ComboBox2.SelectedIndex
End Sub
'verifica se a táctica introduzida for igual a uma anterior para activar o botão do carregador automático de equipas.
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged
If (tatEscolhida1 >= 0) Then
If (tatEscolhida1 <> ComboBox1.SelectedIndex) Then tat1Alterada = True
If (tatEscolhida1 = ComboBox1.SelectedIndex) Then tat1Alterada = False
End If
If (tatEscolhida2 >= 0) Then
If (tatEscolhida2 <> ComboBox2.SelectedIndex) Then tat2Alterada = True
If (tatEscolhida2 = ComboBox2.SelectedIndex) Then tat2Alterada = False
End If
End Sub
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If My.Computer.FileSystem.DirectoryExists("C:\jogo") Then
Dim tatica As IO.StreamWriter
tatica = New IO.StreamWriter("C:\jogo\tatica")
Dim tatica2 As IO.StreamWriter
tatica2 = New IO.StreamWriter("C:\jogo\tatica2")
Dim erro As Boolean
erro = False
If (ComboBox1.SelectedIndex > -1) Then
tat = ComboBox1.SelectedItem.ToString()
tatica.Write(tat)
Else
erro = True
End If
If (ComboBox2.SelectedIndex > -1) Then
tat2 = ComboBox2.SelectedItem.ToString()
tatica2.Write(tat2)
Else
erro = True
End If
If erro Then
MsgBox("Falta escolher uma tática.", MsgBoxStyle.Information, "Erro")
If (ComboBox1.SelectedIndex > -1) Then
ComboBox2.Focus()
Else
ComboBox1.Focus()
End If
Else
tatica.Close()
tatica2.Close()
equipas.Show()
End If
Else
MkDir("C:\jogo")
SetAttr("C:\jogo", vbHidden)
End If
Me.Close()
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
If My.Computer.FileSystem.DirectoryExists("C:\jogo") Then
Dim tatica As IO.StreamWriter
tatica = New IO.StreamWriter("C:\jogo\tatica")
Dim tatica2 As IO.StreamWriter
tatica2 = New IO.StreamWriter("C:\jogo\tatica2")
Dim erro As Boolean
erro = False
If (ComboBox1.SelectedIndex > -1) Then
tat = ComboBox1.SelectedItem.ToString()
tatica.Write(tat)
Else
erro = True
End If
If (ComboBox2.SelectedIndex > -1) Then
tat2 = ComboBox2.SelectedItem.ToString()
tatica2.Write(tat2)
Else
erro = True
End If
If erro Then
MsgBox("Falta escolher uma tática.", MsgBoxStyle.Information, "Erro")
If (ComboBox1.SelectedIndex > -1) Then
ComboBox2.Focus()
Else
ComboBox1.Focus()
End If
Else
tatica.Close()
tatica2.Close()
equipas.Show()
End If
Else
MkDir("C:\jogo")
SetAttr("C:\jogo", vbHidden)
End If
Me.Close()
End Sub
End Class