Public Sub Show
If PagePracticar.IsInitialized = False Then
PagePracticar.Initialize("PagePracticar")
PagePracticar.RootPanel.LoadLayout("mnuPracticar")
End If
Main.NavControl.ShowPage(PagePracticar)
Play
End Sub
Private Sub PagePracticar_Resize(Width As Int, Height As Int)
blnResized=True
If sAct=CNT_FRACPAINT Then
PutImgPaint
End If
End Sub
Private Sub Play
pnlContainer.RemoveAllViews
sAct=rnd(0,10)
Select sAct
Case CNT_ABCDRAGPIECE
pnlContainer.LoadLayout("actPuzNotation")
InitABCNamePuz
Case CNT_FRACPAINT
pnlContainer.LoadLayout("actPaint")
InitFracPaint
'.
'.
'.
end select
end sub
Private Sub InitFracPaint ()
Try
If bmpWhite.IsInitialized =False Then
bmpWhite.Initialize(File.DirAssets,white.png")
End If
Dim iColor As Int
Dim strColor As String
Dim arrColors () As String
arrColors=Array As String ("blue.png","yellow.png","red.png","pink.png")
iColor=Rnd(0,arrColors.Length)
strColor=arrColors(iColor)
bmpPintar.Initialize(File.DirAssets,strColor)
If blnResized=True Then
PutImgPaint
End If
TGame.Enabled =True
Catch
Log("InitFracPaint " & LastException.Description )
End Try
End Sub
Private Sub PutImgPaint
Try
Dim iNumerador, iDenominador As Int
iDenominador =Rnd(2,11)
iNumerador =Rnd(1,iDenominador )
iAPintar =iNumerador
iPainted=0
lblTarea.Text =modUtil.GetString("Paint","Paint ") & iNumerador & "/" & iDenominador
Dim r,c As Int
Dim NumberOfRows, NumberOfColumns As Int
Dim iNumAComparar As Int
If (iDenominador>5) Then
NumberOfRows=2
If (iDenominador Mod 2) =0 Then
NumberOfColumns=iDenominador/2
Else
NumberOfColumns=(iDenominador+1)/2
End If
Else
NumberOfRows=1
NumberOfColumns=iDenominador
End If
iNumAComparar=iDenominador
Dim flWidth, flHeight As Float
flWidth= pnlOption1.Width/NumberOfColumns
flHeight = pnlOption1.Height /NumberOfRows
flWidth=Min(flWidth,flHeight)
flHeight=flWidth
Dim iCreados As Int
For r=0 To NumberOfRows -1
For c = 0 To NumberOfColumns - 1
If iCreados< iNumAComparar Then
Dim img As ImageView
img.Initialize("imgPaint")
img.Bitmap =bmpWhite
Dim mtagPaint As tagPaint
mtagPaint.Initialize
mtagPaint.iKey =c+NumberOfColumns*r
mtagPaint.blnPainted =False
img.Tag =mtagPaint
pnlOption1.AddView (img, c* flWidth,r*flHeight,flWidth,flHeight)
iCreados=iCreados+1
End If
Next
Next
pnlOption1.Left = ((pnlContainer.Width-pnlOption1.Width)/2)+(pnlOption1.Width-flWidth*NumberOfColumns)/2
Catch
Log(LastException)
End Try
End Sub