Imports System
Imports System.IO
Imports System.Collections
Imports System.IO.File
Public Class Form1
'Program Variables
Dim mywidth As String = My.Computer.Screen.WorkingArea.Width
Dim myheight As String = My.Computer.Screen.WorkingArea.Height
Dim h As String = AppDomain.CurrentDomain.BaseDirectory.ToString
Dim flist As String = File.ReadAllText(h & "flist.txt")
Dim priArray() As String = flist.Split(Environment.NewLine)
Dim ad As String = AppDomain.CurrentDomain.BaseDirectory
Dim thefile1 As String
Dim thefile2 As String
Dim thefile3 As String
Dim spore As String
Dim ispore As Boolean
Dim score As String = 0
'Mushroom Variables
Dim chose As String = Nothing
Public Sub tryans()
If LstAns.SelectedIndex > -1 Then
If LstAns.SelectedItem.ToString.Trim() = LblAns.Text.Trim() Then
score = score + 10
'MsgBox("AWESOME YOU GOT IT RIGHT!")
LblScore.Text = score
Dim curline As String = File.ReadAllLines(ad & "flist.txt").FirstOrDefault(Function(x) x.Contains(chose.Trim()))
Dim chArray As String() = curline.Split(",")
MsgBox(chArray(0) & " " & chArray(1))
LstAns.Text = chArray(1)
FindMush()
Else
'MsgBox("Woops, try again!")
score = score - 7
For i As Integer = 0 To LstAns.SelectedIndices.Count - 1
LstAns.Items.RemoveAt(LstAns.SelectedIndex)
Next
LblScore.Text = score
End If
End If
End Sub
'Functions
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MaximizeBox = False
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedToolWindow
LblAns.Hide()
Me.CenterToScreen()
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
FindMush()
End Sub
Public Sub FindMush()
Try
PictureBox1.Image.Dispose()
PictureBox2.Image.Dispose()
PictureBox3.Image.Dispose()
Catch ex As Exception
End Try
Dim T As Integer = 0
Dim M As String = 0
Dim list As New ArrayList
Dim used As String = ""
Dim pic As Integer = 0
Dim Rand1 As New Random()
chose = Nothing
Do Until T = 5
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(Environment.NewLine)
Dim nocommon() As String = gethere(0).Split(",")
If used.Contains(nocommon(0).ToString) = False Then
list.Add(nocommon(0).ToString)
used &= nocommon(0).ToString & ","
T = T + 1
pic = pic + 1
End If
Loop
Dim posans() As String = used.Split(",")
Dim RandChoose As New Random()
Dim MyPic As Integer = RandChoose.Next(0, posans.Length - 1)
LblAns.Text = posans(MyPic)
chose = LblAns.Text
LstAns.Items.Clear()
LstAns.Items.Add(list(0).ToString)
LstAns.Items.Add(list(1).ToString)
LstAns.Items.Add(list(2).ToString)
LstAns.Items.Add(list(3).ToString)
LstAns.Items.Add(list(4).ToString)
If ispore = True Then
thefile1 = ad & LblAns.Text.Trim() & "\mush1.jpg"
thefile2 = ad & LblAns.Text.Trim() & "\mush2.jpg"
Else
thefile1 = ad & LblAns.Text.Trim() & "\mush2.jpg"
thefile2 = ad & LblAns.Text.Trim() & "\mush1.jpg"
End If
thefile3 = ad & LblAns.Text.Trim() & "\mush3.jpg"
spore = ad & LblAns.Text.Trim() & "\spore1.jpg"
If File.Exists(thefile1) = True Then
Try
Me.PictureBox1.Image = Bitmap.FromFile(thefile1.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Me.PictureBox2.Image = Bitmap.FromFile(thefile2.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
If File.Exists(spore) = True Then
ispore = True
Try
Me.PictureBox3.Image = Bitmap.FromFile(spore)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
Try
Me.PictureBox3.Image = Bitmap.FromFile(thefile3)
Catch ex As Exception
MsgBox(ex.Message)
End Try
ispore = False
End If
Else
Me.PictureBox1.Image = Bitmap.FromFile(ad & "notdone.jpg")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPick.Click
FindMush()
End Sub
Private Sub BtnFinalAns_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFinalAns.Click
tryans()
End Sub
Private Sub LstAns_DoubleClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstAns.DoubleClick
tryans()
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim todo As String = Chr(34) & "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll" & Chr(34) & "," & Chr(34) & thefile1 & Chr(34)
Windows.Forms.Clipboard.SetText(todo)
Process.Start("C:\Windows\explorer.exe", thefile1)
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
Process.Start("C:\Windows\explorer.exe", thefile2)
End Sub
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
If ispore = True Then
Process.Start("C:\Windows\explorer.exe", spore)
Else
Process.Start("C:\Windows\explorer.exe", thefile3)
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
FindMush()
Timer1.Enabled = False
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
AddNew.Show()
End Sub
End Class