'
' Created by SharpDevelop.
' User: Jano
' Date: 6.8.2017
' Time: 17:33
' 
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Public Partial Class FVyuka
	Public shared te As Integer=1
	Public shared ot As Integer=1
	Public shared por As Integer=0 'poradie v kurze
	Dim sposobg = ""
	Dim odp As New Module1
	
	Public Sub New(najdene As String, q As String)
		' The Me.InitializeComponent call is required for Windows Forms designer support.
		Me.InitializeComponent()
		Me.Text="Otázka z vyhľadávača pre slovo: " & q
		button1.Visible=False
		button2.Visible=False
		Dim otazkap(2) As String
		otazkap(0)=najdene
		Dim te2 As ArrayList = odp.vratTEOT(otazkap,"te")
		Dim ot2 As ArrayList = odp.vratTEOT(otazkap,"ot")
		'MsgBox(te2.Item(0))
		Dim te As Integer = te2.Item(0)
		Dim ot As Integer = ot2.Item(0)
		
		If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
				If ot>15 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		
		
	End Sub
	
	Public Sub New(sposob As String)
		' The Me.InitializeComponent call is required for Windows Forms designer support.
		Me.InitializeComponent()		
		'
		' TODO : Add constructor code after InitializeComponents
		'
		Try
			sposobg=sposob
			
			
			
			If sposob = "vybranykurz" Then
				'MsgBox(FSZKurz.vybkurzik)
				Dim kurzot As String = odp.citajKurz(FSZKurz.vybkurzik)
				Dim kurzotp As String() = kurzot.Trim().Split(New Char() {" "c})
				Dim te2 As ArrayList = odp.vratTEOT(kurzotp,"te")
				Dim ot2 As ArrayList = odp.vratTEOT(kurzotp,"ot")
				'MsgBox(te.Item(0)) 'len kontrolka nulteho testiku
				te=te2.Item(0)
				ot=ot2.Item(0)
				
				If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
				If ot>15 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
				
			End If
			
		If sposob="zakonypostupne" Then
			
			If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="zakonynahodne" Then
			te=odp.GenRandomInt(1,35)
			If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="zakonynevedel" Then
			te=odp.zistiNajpocetnejsi(odp.citajNevedel(odp.readKtojeprihl()).Split(New Char() {","c}))
			If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="znackypostupne" Then			
			ot=16
			If ot>15 And ot<24 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="znackynahodne" Then			
			ot=16
			te=odp.GenRandomInt(1,35)
			If ot>15 And ot<24 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="znackynevedel" Then			
			ot=16
			te=odp.zistiNajpocetnejsi(odp.citajNevedel(odp.readKtojeprihl()).Split(New Char() {","c}))
			If ot>15 And ot<24 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="krizovatkynevedel" Then			
			ot=24
			te=odp.zistiNajpocetnejsi(odp.citajNevedel(odp.readKtojeprihl()).Split(New Char() {","c}))
			If ot>23 And ot<28 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="krizovatkynahodne" Then			
			ot=24
			te=odp.GenRandomInt(1,35)
			If ot>23 And ot<28 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		
		If sposob="krizovatkypostupne" Then			
			ot=24
		
			If ot>23 And ot<28 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
		End If
		Catch ex As Exception
			MsgBox(ex.Message)	
		End Try
	End Sub
	
	Sub Panel1Paint(sender As Object, e As PaintEventArgs)
		
	End Sub
	
	Sub FVyukaLoad(sender As Object, e As EventArgs)
		
	End Sub
	
	Sub FVyukaFormClosed(sender As Object, e As FormClosedEventArgs)
		MainForm.okno=0
		FSZKurz.okno=0
		Me.por = 0
		Me.te=1
		Me.ot=1
	
	End Sub
	
	Sub Button2Click(sender As Object, e As EventArgs)
		'klik na talcitko nasledujuca otazka
		Try
			ot+=1
			
			If sposobg = "vybranykurz" Then
				
				Dim kurzot As String = odp.citajKurz(FSZKurz.vybkurzik)
				Dim kurzotp As String() = kurzot.Trim().Split(New Char() {" "c})
				Dim te2 As ArrayList = odp.vratTEOT(kurzotp,"te")
				Dim ot2 As ArrayList = odp.vratTEOT(kurzotp,"ot")
				
				'MsgBox(FSZKurz.vybkurzik)
				
				por+=1
				
				If por=te2.Count Then
					por = 0
				End If
												
				te=te2.Item(por)
				ot=ot2.Item(por)
												
				If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
				If ot>15 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
			End If
			
		If sposobg="zakonypostupne" Or sposobg="zakonynahodne" Or sposobg="zakonynevedel" Then			
			If ot=16 Then
				ot=1
				te=te+1
			End If
			If te=36 Then
				te=1
			End If
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
		End If
		
		If sposobg="znackypostupne" Or sposobg="znackynahodne" Or sposobg="znackynevedel" Then
			If ot=24 Then
				ot=16
				te=te+1
			End If
			If te=36 Then
				te=1
			End If
			PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
			PictureBox1.Load()
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
		End If
		
		If sposobg="krizovatkypostupne" Or sposobg="krizovatkynahodne" Or sposobg="krizovatkynevedel" Then
			If ot=28 Then
				ot=24
				te=te+1
			End If
			If te=36 Then
				te=1
			End If
			PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
			PictureBox1.Load()
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
		End If
		Catch ex As Exception
				MsgBox(ex.Message)	
		End Try
	End Sub
	
	Sub Button1Click(sender As Object, e As EventArgs)
		'klikol na tlacitko predosla otazka
		Try
			ot-=1
			
			If sposobg = "vybranykurz" Then
				
				Dim kurzot As String = odp.citajKurz(FSZKurz.vybkurzik)
				Dim kurzotp As String() = kurzot.Trim().Split(New Char() {" "c})
				Dim te2 As ArrayList = odp.vratTEOT(kurzotp,"te")
				Dim ot2 As ArrayList = odp.vratTEOT(kurzotp,"ot")
				
				'MsgBox(FSZKurz.vybkurzik)
				
				por-=1
				
				If por=-1 Then
					por = te2.Count - 1
				End If
												
				te=te2.Item(por)
				ot=ot2.Item(por)
												
				If ot<16 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/nopicture.png")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
				If ot>15 Then
					PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
					PictureBox1.Load()
					richTextBox1.Text=odp.citajOt(ot,te)
					richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
				End If
			End If
			
		If sposobg="zakonypostupne" Or sposobg="zakonynahodne" Or sposobg="zakonynevedel" Then			
			If ot=0 Then
				ot=15
				te=te-1
			End If
			If te=0 Then
				te=35
			End If
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"
		End If
		
		If sposobg="znackypostupne" Or sposobg="znackynahodne" Or sposobg="znackynevedel" Then
			If ot=15 Then
				ot=23
				te=te-1
			End If
			If te=0 Then
				te=35
			End If
			PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
			PictureBox1.Load()
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"			
		End If
		
		If sposobg="krizovatkypostupne" Or sposobg="krizovatkynahodne" Or sposobg="krizovatkynevedel" Then
			If ot=23 Then
				ot=27
				te=te-1
			End If
			If te=0 Then
				te=35
			End If
			PictureBox1.ImageLocation = (System.Windows.Forms.Application.StartupPath & "/data/znackyobr/t" & te & "o" & ot & ".jpg")
			PictureBox1.Load()
			richTextBox1.Text=odp.citajOt(ot,te)
			richTextBox1.Text = richTextBox1.Text & " Odpoveď: " & odp.citajOd(ot,te).ToString().ToUpper() & ")"			
		End If
		Catch ex As Exception
			MsgBox(ex.Message)	
		End Try
	End Sub
End Class
