public void GenerateSource()
 {
     ContactsInfo = new ObservableCollection <ListViewContactsInfo>();
     for (int i = 0; i < 50; i++)
     {
         var details = new ListViewContactsInfo()
         {
             ContactType   = contactType[random.Next(0, 5)],
             ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
             ContactName   = CustomerNames[i],
             ContactImage  = ImageSource.FromResource("SfListViewSample.Images.Image" + random.Next(0, 28) + ".png", assembly),
         };
         ContactsInfo.Add(details);
     }
     AddCommand = new Command <object>(AddTapped);
 }
        public void GenerateSource()
        {
            Random   random   = new Random();
            Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;

            for (int i = 0; i < CustomerNames.Count(); i++)
            {
                var details = new ListViewContactsInfo()
                {
                    ContactType   = contactType[random.Next(0, 5)],
                    ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
                    ContactName   = CustomerNames[i],
                    ContactImage  = ImageSource.FromResource("SfListViewSample.Images.Image" + random.Next(0, 28) + ".png", assembly),
                };
                ContactsInfo.Add(details);
            }
        }
Example #3
0
        public ObservableCollection <ListViewContactsInfo> GetContactDetails(int count)
        {
            ObservableCollection <ListViewContactsInfo> customerDetails = new ObservableCollection <ListViewContactsInfo>();
            Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;

            for (int i = 0; i < count; i++)
            {
                var details = new ListViewContactsInfo()
                {
                    ContactType   = contactType[random.Next(0, 5)],
                    ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
                    ContactName   = CustomerNames[i],
                    ContactImage  = ImageSource.FromResource("SfListViewSample.Images.Image" + random.Next(0, 28) + ".png", assembly),
                };
                customerDetails.Add(details);
            }
            return(customerDetails);
        }
        public async void GenerateContactDetails(int count)
        {
            customerDetails = new ObservableCollection <ListViewContactsInfo>();
            ListViewContactsInfo details;

            for (int i = 0; i < 3; i++)
            {
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory          = "Media\\Pictures",
                    Name               = "Image" + i,
                    SaveToAlbum        = false,
                    CompressionQuality = 75,
                    CustomPhotoSize    = 50,
                    MaxWidthHeight     = 2000,
                });

                details = new ListViewContactsInfo()
                {
                    ContactType   = contactType[random.Next(0, 5)],
                    ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
                    ContactName   = CustomerNames[0],
                    ContactImage  = ImageSource.FromStream(() =>
                    {
                        if (file == null)
                        {
                            return(null);
                        }
                        var stream = file.GetStream();
                        file.Dispose();
                        return(stream);
                    })
                };
                customerDetails.Add(details);
            }
        }