Sub CreateListItem(Contact As cuContact) As Panel
Dim EventName As String = "Contact"
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
' Display name
Dim lblName As Label : lblName.Initialize(EventName)
p.AddView(lblName, 0, 0, clvRubrica.Width - mPhotoSide , mEmailLabelHeight)
lblName.Text = Contact.DisplayName
' Photo
Dim imvPhoto As ImageView : imvPhoto.Initialize(EventName)
p.AddView(imvPhoto, clvRubrica.Width - mPhotoSide, 0, mPhotoSide, mPhotoSide)
Dim bmp As Bitmap = mContactsUtils.GetPhoto(Contact.Id)
If bmp.IsInitialized Then
imvPhoto.SetBackgroundImage(bmp)
Else
imvPhoto.SetBackgroundImage(Null)
End If
Dim lstEmails As List = mContactsUtils.GetEmails(Contact.Id)
Dim lstPhones As List = mContactsUtils.GetPhones(Contact.Id)
Dim EmailsCount As Int = lstEmails.Size
Dim PhonesCount As Int = lstPhones.Size
Dim LastPhoneBottom As Int
For i = 0 To PhonesCount -1
Dim lblPhone As Label : lblPhone.Initialize(EventName)
p.AddView(lblPhone, 0, lblName.Height + i * mEmailLabelHeight, (clvRubrica.Width - mPhotoSide) / 2, mEmailLabelHeight)
Dim PhoneNum As cuPhone = lstPhones.Get(i)
lblPhone.Text = PhoneNum.Number
LastPhoneBottom = lblPhone.Top + lblPhone.Height
Next
For i = 0 To EmailsCount -1
Dim lblEmail As Label : lblEmail.Initialize("Contact")
p.AddView(lblEmail, 0, LastPhoneBottom + i * mEmailLabelHeight, (clvRubrica.Width - mPhotoSide) / 2, mEmailLabelHeight)
Dim Email As cuEmail = lstEmails.Get(i)
lblEmail.Text = Email.Email
Next
Return p
End Sub