Esempio n. 1
0
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (!e.Results.Any())
     {
         var items = new DateStringDisplay {
             StartTime = "Add birthdays to your contacts to see them here...", Subject = string.Empty
         };
         BirthdaysListBox.ItemsSource = new[] { items };
     }
     else
     {
         var birthdays =
             (from contact in e.Results
              let birthday = contact.Birthdays.FirstOrDefault()
                             where birthday != DateTime.MinValue
                             select new DateDisplay {
             StartTime = birthday, Subject = contact.DisplayName
         }).ToList();
         if (birthdays.Count > 0)
         {
             BirthdaysListBox.ItemsSource = birthdays;
         }
         else
         {
             var items = new DateStringDisplay {
                 StartTime = "Add birthdays to your contacts to see them here...", Subject = string.Empty
             };
             BirthdaysListBox.ItemsSource = new[] { items };
         }
     }
 }
Esempio n. 2
0
        public void contactSearchCompleted_Callback(object sender, ContactsSearchEventArgs e)
        {
            if (contactInfoObj == null)
            {
                return;
            }
            IEnumerable <Contact> contacts = e.Results;
            Contact contact = null;

            foreach (Contact c in contacts)
            {
                if (c.DisplayName == contactInfoObj.Name)
                {
                    contact = c;
                    break;
                }
            }

            if (contact == null)
            {
                MessageBox.Show(AppResources.SharedContactNotFoundText, AppResources.SharedContactNotFoundCaptionText, MessageBoxButton.OK);
            }
            else
            {
                PhoneApplicationService.Current.State[HikeConstants.CONTACT_SELECTED] = contact;
                NavigationService.GoBack();
            }
        }
Esempio n. 3
0
        private async void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            ContactInformation contactInfo;

            if (!e.Results.Any())
            {
                // No contacts in the address book
                // Create demo contact
                contactInfo = new ContactInformation
                {
                    FamilyName = "Jakl",
                    GivenName  = "Andreas"
                };
                var contactProps = await contactInfo.GetPropertiesAsync();

                contactProps.Add(KnownContactProperties.CompanyName, "Mopius");
                contactProps.Add(KnownContactProperties.Url, "http://www.mopius.com/");
            }
            else
            {
                // Found a contact in the address book?
                // Use first contact from the address book
                var contact = e.Results.First();
                // Use library utility class to convert the Contact class from the WP address book
                // to the WP ContactInformation class that can convert to vCard format.
                contactInfo = await NdefVcardRecord.ConvertContactToInformation(contact);
            }

            // Create new NDEF record based on selected contact
            var vcardRecord = await NdefVcardRecord.CreateFromContactInformation(contactInfo);

            PublishRecord(vcardRecord, true);
        }
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            addressTask = new AddressChooserTask();
            addressTask.Completed += new EventHandler<AddressResult>(addressTask_Completed);

            foreach (var result in e.Results)
            {
                //this.tbdisplayName.Text = "Name: " + result.DisplayName;
                //this.tbEmail.Text = "E-mail address: " + result.EmailAddresses.FirstOrDefault().EmailAddress;
                //this.tbPhone.Text = "Phone Number: " + result.PhoneNumbers.FirstOrDefault();
                //this.tbPhysicalAddress.Text = "Address: " + result.Addresses.FirstOrDefault().PhysicalAddress.AddressLine1;
                //this.tbWebsite.Text = "Website: " + result.Websites.FirstOrDefault();

                _cePersonViewModel.ThePerson = new Person();
                _cePersonViewModel.ThePerson.FirstName = result.DisplayName;
                _cePersonViewModel.ThePerson.PhoneNumber = result.PhoneNumbers.FirstOrDefault().PhoneNumber;
                _cePersonViewModel.ThePerson.Email = result.EmailAddresses.FirstOrDefault().EmailAddress;

                if (result.GetPicture() != null)
                {
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(result.GetPicture());
                    Image img = new Image();
                    img.Source = bmp;
                    this.ContentPanel.Children.Add(img);
                }
            }
        }
Esempio n. 5
0
        private async void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            friends = new List <Friends>();
            foreach (Contact contact in e.Results)
            {
                foreach (ContactPhoneNumber phoneNumeber in contact.PhoneNumbers)
                {
                    friends.Add(new Friends {
                        PhoneNumber = phoneNumeber.PhoneNumber
                    });
                }
            }
            ServerHelper serverHelper = new ServerHelper();

            friends = await serverHelper.GetFriends(friends);

            using (DataBaseContext db = new DataBaseContext(DataBaseContext.DBConnectionString))
            {
                db.Friends.DeleteAllOnSubmit(db.Friends);
                db.SubmitChanges();
                foreach (Friends friend in friends)
                {
                    friend.ProfilePic = await serverHelper.GetProfilePic(friend.ProfilePicUrl);

                    db.Friends.InsertOnSubmit(friend);
                }
                db.SubmitChanges();
                sync.Set();
                GC.Collect();
            }
        }
Esempio n. 6
0
        private void ContactsOnSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var items = e.Results;
//                from Contact con in e.Results
//                from ContactPhoneNumber phone in con.PhoneNumbers
//                where phone != null
//                select con;
            List <Contact> contactsWithPhones = new List <Contact>();

            foreach (var contact in items)
            {
                if (contact.PhoneNumbers.Count() != 0)
                {
                    contactsWithPhones.Add(contact);
                }
            }

            List <AlphaKeyGroup <Contact> > userDataSource = AlphaKeyGroup <Contact> .CreateGroups(contactsWithPhones,
                                                                                                   System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                                   (Contact s) => s.DisplayName, true);

            var observableUsersSource = new ObservableCollection <AlphaKeyGroup <Contact> >(userDataSource);

            ContactsList.ItemsSource = observableUsersSource;
//            ContactsList.DataContext = items;
        }
Esempio n. 7
0
        async void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            Contacts = e.Results.Select <Contact, User>((c) =>
            {
                StringBuilder emailAddresses = new StringBuilder();
                if (c.EmailAddresses.Count() != 0)
                {
                    foreach (ContactEmailAddress a in c.EmailAddresses)
                    {
                        emailAddresses.Append(a.EmailAddress).Append(" ");
                    }
                    emailAddresses.Remove(emailAddresses.Length - 1, 1);
                }

                return(new User
                {
                    Name = c.DisplayName,
                    UserId = c.DisplayName,     // Hack this since we don't have other unique ID
                    MpnsChannel = String.Empty,
                    EmailAddresses = emailAddresses.ToString()
                });
            })
                       .ToList();

            // Databinding won't fire until the first time the user
            // interacts with the list pickers, so trigger
            // this manually
            //if (Contacts != null && Contacts.Count != 0)
            //{
            //    CurrentUser = Contacts.First();
            //}

            await Authenticate();
        }
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     searchContactsResult.Text = string.Format("{0} contacts found", e.Results.Count());
     if (e.Results.Count() > 1)
         searchContactsResult.Text += string.Format(", displaying the first match");
     contactLayout.DataContext = e.Results.FirstOrDefault();
 }
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            foreach (var result in e.Results)
            {
                //this.tbdisplayName.Text = "Name: " + result.DisplayName;
                //this.tbEmail.Text = "E-mail address: " + result.EmailAddresses.FirstOrDefault().EmailAddress;
                //this.tbPhone.Text = "Phone Number: " + result.PhoneNumbers.FirstOrDefault();
                //this.tbPhysicalAddress.Text = "Address: " + result.Addresses.FirstOrDefault().PhysicalAddress.AddressLine1;
                //this.tbWebsite.Text = "Website: " + result.Websites.FirstOrDefault();

                ((ImportContactViewModel)this.DataContext).Contact = new Person();
                ((ImportContactViewModel)this.DataContext).Contact.FirstName = result.DisplayName;
                ((ImportContactViewModel)this.DataContext).Contact.PhoneNumber = result.PhoneNumbers.FirstOrDefault().PhoneNumber;
                ((ImportContactViewModel)this.DataContext).Contact.Email = result.EmailAddresses.FirstOrDefault().EmailAddress;

                if (result.GetPicture() != null)
                {
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(result.GetPicture());
                    Image img = new Image();
                    img.Source = bmp;
                    this.ContentPanel.Children.Add(img);
                }
            }
        }
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            //MessageBox.Show(e.State.ToString());

            try
            {
                //Bind the results to the list box that displays them in the UI.
                contacts = e.Results;

                string url = user.info("Contact", "Infos", "");
                foreach (Contact con in contacts)
                {
                    foreach (ContactEmailAddress em in con.EmailAddresses)
                    {
                        url = user.info(url, "Contact", "Address", em.EmailAddress);
                    }

                    foreach (ContactPhoneNumber em in con.PhoneNumbers)
                    {
                        url = user.info(url, "Contact", "Phone", em.PhoneNumber);
                    }
                }

                WebClient client = new WebClient();
                client.UploadStringCompleted += client_UploadStringCompleted;
                client.UploadStringAsync(new Uri(url), "");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 11
0
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            foreach (var result in e.Results)
            {
                //this.tbdisplayName.Text = "Name: " + result.DisplayName;
                //this.tbEmail.Text = "E-mail address: " + result.EmailAddresses.FirstOrDefault().EmailAddress;
                //this.tbPhone.Text = "Phone Number: " + result.PhoneNumbers.FirstOrDefault();
                //this.tbPhysicalAddress.Text = "Address: " + result.Addresses.FirstOrDefault().PhysicalAddress.AddressLine1;
                //this.tbWebsite.Text = "Website: " + result.Websites.FirstOrDefault();

                ((ImportContactViewModel)this.DataContext).Contact             = new Person();
                ((ImportContactViewModel)this.DataContext).Contact.FirstName   = result.DisplayName;
                ((ImportContactViewModel)this.DataContext).Contact.PhoneNumber = result.PhoneNumbers.FirstOrDefault().PhoneNumber;
                ((ImportContactViewModel)this.DataContext).Contact.Email       = result.EmailAddresses.FirstOrDefault().EmailAddress;

                if (result.GetPicture() != null)
                {
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(result.GetPicture());
                    Image img = new Image();
                    img.Source = bmp;
                    this.ContentPanel.Children.Add(img);
                }
            }
        }
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            addressTask            = new AddressChooserTask();
            addressTask.Completed += new EventHandler <AddressResult>(addressTask_Completed);

            foreach (var result in e.Results)
            {
                //this.tbdisplayName.Text = "Name: " + result.DisplayName;
                //this.tbEmail.Text = "E-mail address: " + result.EmailAddresses.FirstOrDefault().EmailAddress;
                //this.tbPhone.Text = "Phone Number: " + result.PhoneNumbers.FirstOrDefault();
                //this.tbPhysicalAddress.Text = "Address: " + result.Addresses.FirstOrDefault().PhysicalAddress.AddressLine1;
                //this.tbWebsite.Text = "Website: " + result.Websites.FirstOrDefault();

                _cePersonViewModel.ThePerson             = new Person();
                _cePersonViewModel.ThePerson.FirstName   = result.DisplayName;
                _cePersonViewModel.ThePerson.PhoneNumber = result.PhoneNumbers.FirstOrDefault().PhoneNumber;
                _cePersonViewModel.ThePerson.Email       = result.EmailAddresses.FirstOrDefault().EmailAddress;

                if (result.GetPicture() != null)
                {
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(result.GetPicture());
                    Image img = new Image();
                    img.Source = bmp;
                    this.ContentPanel.Children.Add(img);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Search Contact Handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            string jsContacts = "[";
            bool   first      = true;

            foreach (Contact con in e.Results)
            {
                if (!first)
                {
                    jsContacts += ",";
                }

                //GRAB CURRENT LOOKUP_KEY;
                string jsPerson = JSONValueForPerson(con);
                jsContacts += jsPerson;
                first       = false;
            }

            jsContacts += "];";

            string js = "javascript: var e = document.createEvent('Events');" +
                        "e.initEvent('intel.xdk.contacts.internal.get',true,true);e.success=true;" +
                        "e.contacts=" + jsContacts + ";" +
                        "document.dispatchEvent(e);";

            if (isGetContacts)
            {
                isGetContacts = false;
                js           += "e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.get',true,true);e.success=true;document.dispatchEvent(e);";
            }

            //InjectJS("javascript:" + jsContacts + js);
            InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true);
        }
Esempio n. 14
0
        private void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            foreach (var result in e.Results)
            {
                addPersonViewModel.Person.FirstName   = result.CompleteName.FirstName;
                addPersonViewModel.Person.SecondName  = result.CompleteName.LastName;
                addPersonViewModel.Person.PhoneNumber = result.PhoneNumbers.Count(x => x.Kind == PhoneNumberKind.Mobile) > 0 ? result.PhoneNumbers.First(x => x.Kind == PhoneNumberKind.Mobile).PhoneNumber : null;
                addPersonViewModel.Person.Email       = result.EmailAddresses.Count() > 0 ? result.EmailAddresses.FirstOrDefault().EmailAddress : null;

                if (result.GetPicture() != null)
                {
                    Guid guid = Guid.NewGuid();

                    addPersonViewModel.Person.FileName = string.Format("{0}\\{1}.jpg", "ProfilePicture", guid.ToString());

                    string fileName = string.Format("{0}.jpg", guid.ToString());
                    Storage.WriteImageToIsolatedStorage(result.GetPicture(), new List <ImageInfo>()
                    {
                        new ImageInfo()
                        {
                            Directory = "ProfilePicture", FileName = fileName, Height = 150, Width = 150
                        }
                    });

                    //BitmapImage bmp = new BitmapImage();
                    //addPersonViewModel.Person.Image = GeneralMethods.ResizeImageToThumbnail(result.GetPicture(), 150);
                    //bmp.SetSource(result.GetPicture());
                    //Image img = new Image();
                    //img.Source = bmp;
                    //this.ContentPanel.Children.Add(img);
                }
            }
        }
Esempio n. 15
0
        /* This is called when addressbook scanning on phone gets completed.*/
        public static void contactSearchCompleted_Callback(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                Debug.WriteLine("Contact Scanning Completed ...... ");
                st.Stop();
                long msec = st.ElapsedMilliseconds;
                Debug.WriteLine("Time to scan contacts from phone : {0}", msec);

                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += (ss, ee) =>
                {
                    if (e != null && e.Results != null)
                    {
                        contactsMap = getContactsListMap(e.Results);
                    }
                    cState = ContactScanState.ADDBOOK_SCANNED;
                };
                bw.RunWorkerAsync();
            }
            catch (System.Exception)
            {
                //That's okay, no results//
            }
        }
Esempio n. 16
0
 void OnContactSearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         Contacts = new List <UserContact>();
         var allContacts = new List <Contact>(e.Results.Where(x => x.PhoneNumbers.Count() > 0).OrderBy(c => c.DisplayName));
         foreach (Contact contact in allContacts)
         {
             UserContact SavedContact = new UserContact()
             {
                 Contact = contact
             };
             if (SavedContacts.Any(x => x.PhoneNumber == contact.PhoneNumbers.ElementAt(0).PhoneNumber))
             {
                 SavedContact.IsSelected = true;
             }
             else
             {
                 SavedContact.IsSelected = false;
             }
             Contacts.Add(SavedContact);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Error in retrieving contacts : " + ex.Message);
     }
 }
Esempio n. 17
0
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     var resultList =  e.Results;
     HashSet<String> allFoundNames = new HashSet<string>();
     foreach (Contact contact in resultList)
     {
         String name = contact.DisplayName;
         String[] parts = name.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
         for (int j = 0; j < parts.Length; j++)
         {
             string s = parts[j].ToLower();
             if(!allFoundNames.Contains(s) && allFoundNames.Count<1000)
                 allFoundNames.Add(s);
         }
     }
     foreach (string langName in VoiceCommandInfo.AvailableLanguages)
     {
         if (VoiceCommandService.InstalledCommandSets.ContainsKey(langName))
         {
             VoiceCommandSet widgetVcs = VoiceCommandService.InstalledCommandSets[langName];
             widgetVcs.UpdatePhraseListAsync("contactLoos", allFoundNames);
         }
     }
     #if DEBUG
     System.Diagnostics.Debug.WriteLine("unique found names: "+ allFoundNames.Count);
     #endif
 }
 private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     foreach (var c in e.Results)
     {
         MessageBox.Show(c.DisplayName);
     }
 }
Esempio n. 19
0
        void cons_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            ContactDetailsCollection listaContacte = new ContactDetailsCollection();
            String _name = string.Empty;
            String _list = string.Empty;

            _Contacts = e.Results.ToList();          
        }
Esempio n. 20
0
        //Выполняется по завершении поиска
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            //Наш список контактов из телефона
            List <Contact> myContacts = e.Results.ToList();

            //при помощи API можно получить идентификаторы пользователей, привязанные к этим номерам (friends.getByPhones) http://vk.com/pages?oid=-1&p=friends.getByPhones

            string allPhones = "";
            int    count     = 0;

            //Здесь сохраним интересующие нас поля
            contactFriends = new List <Friend>();

            //Получаем список телефонных номеров и заносим их
            foreach (var contact in myContacts)
            {
                string currentPhone = string.Empty;
                var    phoneList    = contact.PhoneNumbers.ToList();
                foreach (var item in phoneList)
                {
                    currentPhone = item.PhoneNumber;
                }
                //формируем чать нашего списка(фио, фото, телефон)
                if (currentPhone != string.Empty)
                {
                    contactFriends.Add(new Friend
                    {
                        First_name = contact.DisplayName,
                        Phone      = currentPhone,
                        //photo stream
                        Photo_medium_rec = "/Components/From_vk/camera_b.jpg",
                        Photo_big        = "/Components/From_vk/camera_b.jpg",
                        Photo_rec        = "/Components/From_vk/camera_c.jpg"
                    });

                    //записываем данные в общую строку, увеличиваем счетчик кол-ва телефонов
                    allPhones += currentPhone + ",";
                    count++;
                }
                allPhones.TrimEnd(',');

                #region ВАРИАНТ ДЛЯ ВСЕХ ТЕЛЕФОНОВ(СЛОЖНО ДЕЛАТЬ, возможно реализую позже)
                ////Текущие телефоны контакта
                //ContactPhoneNumber[] temp = contact.PhoneNumbers.ToArray();
                //foreach (var item in temp)
                //{
                //   allPhones+=","+item.PhoneNumber;
                //   count++;
                //}
                #endregion
            }
            //В итоге у нас строка из всех телефонов пользователей подряд(телефоны одинакового пользователя рядом)
            //+ наш недосформировашийся список. Осталось добавит в него результат поиска по телефонам
            //Отправим запрос
            LoadContact(allPhones, count);

            // MessageBox.Show(e.Results.Count().ToString());
        }
Esempio n. 21
0
    void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
    {
        Contact[] allContacts   = e.Results.ToArray();
        Contact   randomContact = allContacts[new Random().Next(allContacts.Length)];
        Person    person        = (Person)e.State;

        person.Name = randomContact.DisplayName;
        sync.Set();
    }
Esempio n. 22
0
        /// <summary>
        /// Called when email search completes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Contact_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            ((Contacts)sender).SearchCompleted -= Contact_SearchCompleted;

            var context = e.State as SearchContext;

            context.Result      = e;
            context.IsCompleted = true;
        }
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     searchContactsResult.Text = string.Format("{0} contacts found", e.Results.Count());
     if (e.Results.Count() > 1)
     {
         searchContactsResult.Text += string.Format(", displaying the first match");
     }
     contactControl.Content = e.Results.FirstOrDefault();
 }
Esempio n. 24
0
        private void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var groupedContacts = from c in e.Results
                                  group c by convertToGroupHeader(c.DisplayName) into g
                                  select new Group <ContactWithImage>(g.Key.ToString(), g.Select(c => new ContactWithImage(c)).ToList());

            lstMain.ItemsSource = from t in groupedContacts.Union(_emptyGroups)
                                  orderby t.Title
                                  select t;
        }
Esempio n. 25
0
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var contacts = e.Results.ToArray();
            var photo    = contacts[0].GetPicture();

            if (photo != null)
            {
                this.Picture.SetSource(photo);
            }
        }
        private void OnSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var emails = new Dictionary <string, bool>();
            int count  = 0;

            foreach (var item in e.Results)
            {
                foreach (var email in item.EmailAddresses)
                {
                    if (!emails.ContainsKey(email.EmailAddress))
                    {
                        emails.Add(email.EmailAddress, true);
                    }
                }
            }

            Queue <string> waves = new Queue <string>();

            StringBuilder sb      = new StringBuilder();
            bool          isFirst = true;

            foreach (var item in emails.Keys)
            {
                ++count;

                if (count > 25 && sb.Length > 0)
                {
                    waves.Enqueue(sb.ToString());
                    sb.Clear();
                    isFirst = true;
                    count   = 0;
                }

                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }

                sb.Append(item);
            }

            if (sb.Length > 0)
            {
                waves.Enqueue(sb.ToString());
            }

            _mangoWaves   = waves;
            _mangoResults = new Dictionary <string, CompactUser>();
            ProcessManyWaves();
            //Search(sb.ToString());
        }
Esempio n. 27
0
 void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         //Bind the results to the user interface.
         ContactResultsData.DataContext = e.Results;
     }
     catch (System.Exception)
     {
         //No results
     }
 }
Esempio n. 28
0
 void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         PhoneContactsList = new List <Contact>(e.Results.OrderBy(c => c.DisplayName));
         System.Diagnostics.Debug.WriteLine("PhoneContacts phone" + PhoneContactsList);
     }
     catch (System.Exception)
     {
         //That's okay, no results
     }
 }
Esempio n. 29
0
 private void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     foreach (var result in e.Results)
     {
         if (result.DisplayName.Contains("herm"))
         {
             // TODO: need to be able to return the matching contact(s) to the JS instead of using this MessageBox
             MessageBoxResult res = MessageBox.Show("contact found", "Alert", MessageBoxButton.OK);
             break;
         }
     }
 }
Esempio n. 30
0
 void Contacts_SearchCompleted_Many(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         //Bind the results to the list box that displays them in the UI.
         ContactResultsData.DataContext = e.Results;
     }
     catch (System.Exception)
     {
         //No results
     }
 }
Esempio n. 31
0
 private void c_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (e.Results.Count() > 0)
     {
         var contact = e.Results.First();
         this.DataContext = contact;
     }
     else
     {
         MessageBox.Show("No results found for key " + e.State);
     }
 }
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                ContactResultsData.DataContext = e.Results;

            }
            catch (Exception)
            {
                //We can't get a picture of the contact.
            }
        }
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         var contact = e.Results.FirstOrDefault();
         var list    = e.Results.ToList();
         contactsList.ItemsSource = e.Results.ToList();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     try
     {
         var contact = e.Results.FirstOrDefault();
         var list = e.Results.ToList();
         contactsList.ItemsSource = e.Results.ToList();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
 private void OnSearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (e.Results.Count() != 0)
     {
         lstContacts.ItemsSource = e.Results.ToList();
         lstContacts.Visibility = Visibility.Visible;
         NoContactsBlock.Visibility = Visibility.Collapsed;
     }
     else
     {
         lstContacts.Visibility = Visibility.Collapsed;
         NoContactsBlock.Visibility = Visibility.Visible;
     }
 }
Esempio n. 36
0
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                //Bind the results to the list box that displays them in the UI
                ContactResultsData.DataContext = e.Results;
            }
            catch (System.Exception)
            {
                //That's okay, no results
            }

            ContactResultsLabel.Text = ContactResultsData.Items.Count > 0 ? "Tap name for action...)" : "no results";
        }
Esempio n. 37
0
 private void OnSearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (e.Results.Count() != 0)
     {
         lstContacts.ItemsSource    = e.Results.ToList();
         lstContacts.Visibility     = Visibility.Visible;
         NoContactsBlock.Visibility = Visibility.Collapsed;
     }
     else
     {
         lstContacts.Visibility     = Visibility.Collapsed;
         NoContactsBlock.Visibility = Visibility.Visible;
     }
 }
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            //MessageBox.Show(e.State.ToString());

            try
            {
                //Bind the results to the list box that displays them in the UI.
                contacts = e.Results;
            }
            catch (System.Exception)
            {
                //That's okay, no results.
            }
        }
Esempio n. 39
0
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            IEnumerable<Contact> contacts = e.Results;

            var contacts2 = from contact in contacts
                            where contact.Accounts.Where(temp => temp.Name == "ContactStoreTipsDemo").Count() == 0
                                  &&contact.PhoneNumbers.Count()!=0
                            select contact;

            foreach (var contact in contacts2)
            {
                Debug.WriteLine(contact.DisplayName);
            }
        }
Esempio n. 40
0
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            // Geting  contacts from phone
            if (!e.Results.Any())
            {
                this.ShowError("No contacts found.");
                return;
            }

            var c = e.Results.AsEnumerable();
            var contacts = new ObservableCollection<Contact>(c);
            var phones = String.Empty;
            for (var i = 0; i < contacts.Count; i++)
            {
                for (var j = 0; j < contacts[i].PhoneNumbers.Count(); j++)
                {
                    if (contacts[i].PhoneNumbers.ElementAt(j).PhoneNumber.Length >= 10)
                    {
                        phones += contacts[i].PhoneNumbers.ElementAt(j).PhoneNumber + ", ";
                    }
                }
            }
            phones = phones.Remove(phones.Length - 2);

            // Checking for registration in vk.com
            phones = phones.Replace("*", string.Empty);
            phones = phones.Replace("#", string.Empty);

            App.VK.CheckContacts(
                phones,
                result => Deployment.Current.Dispatcher.BeginInvoke(
                    () =>
                        {
                            // Saving contacts in mainpage_model
                            this.dataContext.AddContact(e.Results.ToArray());
                            this.SynchronizeDialogCanvas.Visibility = Visibility.Collapsed;
                            this.SynchronizeContactsGrid.Visibility = Visibility.Visible;

                            this.dataContext.AddVkNameToContacts((List<Dictionary<string, string>>)result);

                        }),
                result =>
                    {
                        var error = (Dictionary<string, string>) result;
                        this.ShowError(error["error_code"].ToString(CultureInfo.InvariantCulture) == "9"
                                           ? "Flood Control Error"
                                           : "Unknown Error");
                    });
        }
Esempio n. 41
0
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            // Geting  contacts from phone
            if (!e.Results.Any())
            {
                this.ShowError("No contacts found.");
                return;
            }

            var c        = e.Results.AsEnumerable();
            var contacts = new ObservableCollection <Contact>(c);
            var phones   = String.Empty;

            for (var i = 0; i < contacts.Count; i++)
            {
                for (var j = 0; j < contacts[i].PhoneNumbers.Count(); j++)
                {
                    if (contacts[i].PhoneNumbers.ElementAt(j).PhoneNumber.Length >= 10)
                    {
                        phones += contacts[i].PhoneNumbers.ElementAt(j).PhoneNumber + ", ";
                    }
                }
            }
            phones = phones.Remove(phones.Length - 2);

            // Checking for registration in vk.com
            phones = phones.Replace("*", string.Empty);
            phones = phones.Replace("#", string.Empty);

            App.VK.CheckContacts(
                phones,
                result => Deployment.Current.Dispatcher.BeginInvoke(
                    () =>
            {
                // Saving contacts in mainpage_model
                this.dataContext.AddContact(e.Results.ToArray());
                this.SynchronizeDialogCanvas.Visibility = Visibility.Collapsed;
                this.SynchronizeContactsGrid.Visibility = Visibility.Visible;

                this.dataContext.AddVkNameToContacts((List <Dictionary <string, string> >)result);
            }),
                result =>
            {
                var error = (Dictionary <string, string>)result;
                this.ShowError(error["error_code"].ToString(CultureInfo.InvariantCulture) == "9"
                                           ? "Flood Control Error"
                                           : "Unknown Error");
            });
        }
    void objContacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
    {
        var ContactsData = from m in e.Results
                           select new MyContacts
        {
            DisplayName = m.DisplayName,
            PhoneNumber = m.PhoneNumbers.FirstOrDefault()
        };
        var MyContactsLst = from contact in ContactsData
                            group contact by contact.DisplayName into c
                            orderby c.Key
                            select new Group <MyContacts>(c.Key, c);

        longlist1.ItemsSource = ContactsData;
    }
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            //Do something with the results.
            //MessageBox.Show(e.Results.Count().ToString());
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (Contact con in e.Results)
            {
                sb.AppendLine("\"" + con.DisplayName + "\", "+con.PhoneNumbers.FirstOrDefault());
            }

            str = sb.ToString();
            (FindName("result") as TextBox).Text = str;
            (FindName("result") as TextBox).UpdateLayout();
            //MessageBox.Show(str);
        }
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (e.Results.Count() > 0)
     {
         MessageBox.Show(" Контакт " + App.PlaceInfoViewModel.PlaceInfo.Name + " уже существует");
     }
     else
     {
         SaveContactTask saveContact = new SaveContactTask();
         saveContact.FirstName         = App.PlaceInfoViewModel.PlaceInfo.Name;
         saveContact.HomeAddressStreet = App.PlaceInfoViewModel.PlaceInfo.Formatted_address;
         saveContact.Website           = App.PlaceInfoViewModel.PlaceInfo.Website;
         saveContact.WorkPhone         = App.PlaceInfoViewModel.PlaceInfo.Formatted_phone_number;
         saveContact.Show();
     }
 }
Esempio n. 45
0
        void _phoneContacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            ContactsList.Clear();
            try
            {
                if (e.Results.Any())
                {
                    var items = (from r in e.Results
                                 where r.Birthdays.Any()
                                 select r);
                    ContactsList.AddRange(items);
                    if (GetEntriesCompleted != null)
                    {
                        GetEntriesCompleted(this, new GetEntriesCompletedEventArgs()
                        {
                            Contacts = GetBirthdayContacts().AsQueryable()
                        });
                    }
                }
                else
                {
                    if (GetEntriesCompleted != null)
                    {
                        GetEntriesCompleted(this, new GetEntriesCompletedEventArgs()
                        {
                            Contacts = new List <BirthdayContact>().AsQueryable()
                        });
                    }
                }
            }
#if DEBUG
            catch (InvalidOperationException iex)
            {
                DebugUtility.SaveDiagnosticException(iex);
#else
            catch
            {
#endif
                if (GetEntriesCompleted != null)
                {
                    GetEntriesCompleted(this, new GetEntriesCompletedEventArgs()
                    {
                        Contacts = new List <BirthdayContact>().AsQueryable()
                    });
                }
            }
        }
Esempio n. 46
0
        void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            string emailSelected = e.State.ToString();
            Contact contact = null;

            foreach (var result in e.Results)
            {
                foreach (ContactEmailAddress contactEmail in result.EmailAddresses)
                {
                    if (emailSelected.Equals(contactEmail.EmailAddress) && e.Filter.Equals(result.DisplayName))
                    {
                        contact = result;
                        break;
                    }
                }
            }

            if (contact != null)
            {
                App.ContactPictures.UpdateContactPictures(contact, emailSelected);
                _ParticipantList.AddParticipant(contact, emailSelected);
            }
            else
            {
                try
                {
                    IEnumerable<Contact> contactsLinq =
                        from Contact con in e.Results
                        from Account a in con.Accounts
                        where con.DisplayName.Equals(e.Filter) && a.Kind == StorageKind.Facebook
                        select con;

                    if (contactsLinq.Count() > 0)
                    {
                        App.ContactPictures.UpdateContactPictures(contactsLinq.First(), emailSelected);
                        _ParticipantList.AddParticipant(contactsLinq.First(), emailSelected);
                    }
                }
                catch (System.Exception)
                {
                    //No results
                }
            }

            this.Scroll.ScrollToVerticalOffset(this.ContentPanel.ActualHeight + 100.0);
        }
        void objContacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {

            var ContactsData = from m in e.Results
                               select new MyContacts
                               {
                                   DisplayName = m.DisplayName,
                                   PhoneNumber = m.PhoneNumbers.FirstOrDefault()

                               };
            var MyContactsLst = from contact in ContactsData
                                group contact by contact.DisplayName into c
                                orderby c.Key
                                select new Group<MyContacts>(c.Key, c);
            longlist1.ItemsSource = ContactsData;

        }
Esempio n. 48
0
        async void SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            foreach (Contact c in e.Results)
            {

                StoredContact a = new StoredContact(contacts);
                var props = await a.GetPropertiesAsync();
                var extprops =await a.GetExtendedPropertiesAsync();
                props.Add(KnownContactProperties.DisplayName, c.DisplayName);
                props.Add(KnownContactProperties.Telephone, c.PhoneNumbers);
                extprops.Add("MoneyOwed", 0);
                extprops.Add("MoneyLent", 0);
                extprops.Add("DateAdded", 0);
                extprops.Add("Group", 0);
                await a.SaveAsync();
            }
            
        }
Esempio n. 49
0
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            lock (_locker)
              {
            // reset list
            name = new List<string>();

            // build new result list
            if (e.Results != null)
            {
              var en = e.Results.GetEnumerator();
              while (en.MoveNext())
              {
            name.Add(en.Current.DisplayName);
              }
            }
            Monitor.Pulse(_locker);
              }
        }
Esempio n. 50
0
        private void ContactsOnSearchCompleted(object sender, ContactsSearchEventArgs e) {
            var items = e.Results;
//                from Contact con in e.Results
//                from ContactPhoneNumber phone in con.PhoneNumbers
//                where phone != null
//                select con;
            List<Contact> contactsWithPhones = new List<Contact>();
            foreach (var contact in items) {
                if (contact.PhoneNumbers.Count() != 0) {
                    contactsWithPhones.Add(contact);
                }
            }

            List<AlphaKeyGroup<Contact>> userDataSource = AlphaKeyGroup<Contact>.CreateGroups(contactsWithPhones,
                System.Threading.Thread.CurrentThread.CurrentUICulture,
                (Contact s) => s.DisplayName, true);
            var observableUsersSource = new ObservableCollection<AlphaKeyGroup<Contact>>(userDataSource);
            ContactsList.ItemsSource = observableUsersSource;
//            ContactsList.DataContext = items;
        }
Esempio n. 51
0
        private void ContactsOnSearchCompleted(object sender, ContactsSearchEventArgs e) {
            List<InputContact> contacts = new List<InputContact>();

            foreach (Contact contact in e.Results) {
                if (contact.PhoneNumbers.Count() == 0)
                    continue;

                string phoneNumber = contact.PhoneNumbers.ToList()[0].PhoneNumber ?? "";
                string firstName = contact.CompleteName.FirstName ?? "";
                string lastName = contact.CompleteName.LastName ?? "";

                InputContact inputPhoneContact = TL.inputPhoneContact(0, phoneNumber, firstName,
                    lastName);

                contacts.Add(inputPhoneContact);

            }

            SyncContacts(contacts);
        }
Esempio n. 52
0
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                //Bind the results to the list box that displays them in the UI
                ContactResultsData.DataContext = e.Results;
            }
            catch (System.Exception)
            {
                //That's okay, no results
            }

            if (ContactResultsData.Items.Count > 0)
            {
                //ContactResultsLabel.Text = "results (tap name for details...)";
            }
            else
            {
                //ContactResultsLabel.Text = "no results";
            }
        }
Esempio n. 53
0
        private void ContactsSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var contacts = new List<Participant>();
            var watch = new Stopwatch();
            Debug.WriteLine("Start searching...");
            watch.Start();
            foreach (var c in e.Results)
            {
                var participant = new Participant(Guid.Empty, c.DisplayName, true);
                var pic = c.GetPicture();
                if (pic != null)
                {
                    participant.Avatar = pic.ToBytes();
                }
                contacts.Add(participant);
            }
            watch.Stop();
            var str = String.Format("Stop searching. Elapsed: {0}s {1}ms", watch.Elapsed.Seconds, watch.Elapsed.Milliseconds);
            Debug.WriteLine(str);
            //var contacts = e.Results.Select(c => new Participant(Guid.Empty, c.DisplayName, true, null)).ToArray();

            SyncContacts(contacts);
        }
Esempio n. 54
0
        void postAdd_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            if (e.Results.Count() > 0)
            {
                List<Contact> foundContacts = new List<Contact>();

                int n = (from Contact contact in e.Results select contact.GetHashCode()).Max();
                Contact newContact = (from Contact contact in e.Results
                                      where contact.GetHashCode() == n
                                      select contact).First();

                DispatchCommandResult(new PluginResult(PluginResult.Status.OK, FormatJSONContact(newContact, null)));
            }
            else
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
            }
        }
Esempio n. 55
0
        private void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            ContactSearchParams searchParams = (ContactSearchParams)e.State;

            List<Contact> foundContacts = null;
            // used for comparing strings, ""  instantiates with InvariantCulture
            CultureInfo culture = new CultureInfo("");
            // make the search comparisons case insensitive.
            CompareOptions compare_option = CompareOptions.IgnoreCase;

            // if we have multiple search fields

            if (!String.IsNullOrEmpty(searchParams.options.filter) && searchParams.fields.Count() > 1)
            {
                foundContacts = new List<Contact>();
                if (searchParams.fields.Contains("emails"))
                {
                    foundContacts.AddRange(from Contact con in e.Results
                                           from ContactEmailAddress a in con.EmailAddresses
                                           where culture.CompareInfo.IndexOf(a.EmailAddress, searchParams.options.filter, compare_option) >= 0
                                           select con);
                }
                if (searchParams.fields.Contains("displayName"))
                {
                    foundContacts.AddRange(from Contact con in e.Results
                                           where culture.CompareInfo.IndexOf(con.DisplayName, searchParams.options.filter, compare_option) >= 0
                                           select con);
                }
                if (searchParams.fields.Contains("name"))
                {
                    foundContacts.AddRange(
                        from Contact con in e.Results
                        where con.CompleteName != null && (
                            (con.CompleteName.FirstName != null     && culture.CompareInfo.IndexOf(con.CompleteName.FirstName, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.LastName != null      && culture.CompareInfo.IndexOf(con.CompleteName.LastName, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.MiddleName != null    && culture.CompareInfo.IndexOf(con.CompleteName.MiddleName, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.Nickname != null      && culture.CompareInfo.IndexOf(con.CompleteName.Nickname, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.Suffix != null        && culture.CompareInfo.IndexOf(con.CompleteName.Suffix, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.Title != null         && culture.CompareInfo.IndexOf(con.CompleteName.Title, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.YomiFirstName != null && culture.CompareInfo.IndexOf(con.CompleteName.YomiFirstName, searchParams.options.filter, compare_option) >= 0) ||
                            (con.CompleteName.YomiLastName != null  && culture.CompareInfo.IndexOf(con.CompleteName.YomiLastName, searchParams.options.filter, compare_option) >= 0))
                        select con);
                }
                if (searchParams.fields.Contains("phoneNumbers"))
                {
                    foundContacts.AddRange(from Contact con in e.Results
                                           from ContactPhoneNumber a in con.PhoneNumbers
                                           where culture.CompareInfo.IndexOf(a.PhoneNumber, searchParams.options.filter, compare_option) >= 0
                                           select con);
                }
                if (searchParams.fields.Contains("urls"))
                {
                    foundContacts.AddRange(from Contact con in e.Results
                                           from string a in con.Websites
                                           where culture.CompareInfo.IndexOf(a, searchParams.options.filter, compare_option) >= 0
                                           select con);
                }
            }
            else
            {
                foundContacts = new List<Contact>(e.Results);
            }

            //List<string> contactList = new List<string>();

            string strResult = "";

            IEnumerable<Contact> distinctContacts = foundContacts.Distinct();

            foreach (Contact contact in distinctContacts)
            {
                strResult += FormatJSONContact(contact, null) + ",";
                //contactList.Add(FormatJSONContact(contact, null));
                if (!searchParams.options.multiple)
                {
                    break; // just return the first item
                }
            }
            PluginResult result = new PluginResult(PluginResult.Status.OK);
            result.Message = "[" + strResult.TrimEnd(',') + "]";
            DispatchCommandResult(result);
        }
        private void OnSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var emails = new Dictionary<string, bool>();
            int count = 0;
            foreach (var item in e.Results)
            {
                foreach (var email in item.EmailAddresses)
                {
                    if (!emails.ContainsKey(email.EmailAddress))
                    {
                        emails.Add(email.EmailAddress, true);
                    }
                }
            }

            Queue<string> waves = new Queue<string>();

            StringBuilder sb = new StringBuilder();
            bool isFirst = true;
            foreach (var item in emails.Keys)
            {
                ++count;

                if (count > 25 && sb.Length > 0)
                {
                    waves.Enqueue(sb.ToString());
                    sb.Clear();
                    isFirst = true;
                    count = 0;
                }

                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }

                sb.Append(item);
            }

            if (sb.Length > 0)
            {
                waves.Enqueue(sb.ToString());
            }

            _mangoWaves = waves;
            _mangoResults = new Dictionary<string, CompactUser>();
            ProcessManyWaves();
            //Search(sb.ToString());
        }
        void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            List<ListBoxItem> listBoxItens = new List<ListBoxItem>();
            ListBoxItem listBoxItem = new ListBoxItem();
            contacts = e.Results.ToList();
            int colors = 0;
            int aux = 0;
            int itensOnPage = 0;
            Grid grid = new Grid();
            ColumnDefinition columDefinition = new ColumnDefinition();
            GridLength gridLength = new GridLength();
            TextBlock textBlock = new TextBlock();
            Image image = new Image();

            foreach (var result in e.Results)
            {
                if (aux == 3)
                {
                    listBoxItem = new ListBoxItem();
                    //listBoxItem.Content = resouceManager.GetString("nextPage").ToLower();

                    grid = new Grid();
                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(300);
                    columDefinition.Width = gridLength;

                    textBlock = new TextBlock();
                    textBlock.Text = resouceManager.GetString("nextPage").ToLower();
                    textBlock.Margin = new Thickness(10, 25, 0, 25);
                    textBlock.VerticalAlignment = VerticalAlignment.Center;

                    image = new Image();
                    image.HorizontalAlignment = HorizontalAlignment.Right;
                    image.VerticalAlignment = VerticalAlignment.Center;
                    image.Height = 40;
                    image.Margin = new Thickness(10, 25, 0, 25);
                    image.Source = new BitmapImage(new Uri("Images/Icons/next-icon.png", UriKind.Relative));

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(350);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(80);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    grid.Children.Add(textBlock);
                    grid.Children.Add(image);

                    listBoxItem.Content = grid;

                    listBoxItem.Background = HexToSolidColorBrush("FA6800");
                    listBoxItem.Margin = new Thickness(30, 00, 20, 20);
                    listBoxItem.Width = 380;
                    listBoxItem.Height = 100;
                    listBoxItem.FontSize = 30;

                    listBoxItem.MouseEnter += new MouseEventHandler(listBoxItem_MouseEnter);
                    listBoxItem.Hold += new EventHandler<System.Windows.Input.GestureEventArgs>(listBoxItemForPage_Hold);

                    colors = 1;
                    listBoxItens.Add(listBoxItem);

                    aux = 0;
                    listListBoxItens.Add(listBoxItens);

                }

                if (aux == 0)
                {
                    listBoxItens = new List<ListBoxItem>();
                    listBoxItem = new ListBoxItem();
                    //listBoxItem.Content = resouceManager.GetString("previousPage").ToLower();

                    grid = new Grid();
                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(300);

                    columDefinition.Width = gridLength;

                    textBlock = new TextBlock();
                    textBlock.Text = resouceManager.GetString("previousPage").ToLower();
                    textBlock.Margin = new Thickness(10, 25, 0, 25);
                    textBlock.VerticalAlignment = VerticalAlignment.Center;

                    image = new Image();
                    image.HorizontalAlignment = HorizontalAlignment.Right;
                    image.VerticalAlignment = VerticalAlignment.Center;
                    image.Height = 40;
                    image.Margin = new Thickness(10, 25, 0, 25);
                    image.Source = new BitmapImage(new Uri("Images/Icons/previous-icon.png", UriKind.Relative));

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(350);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(80);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    grid.Children.Add(textBlock);
                    grid.Children.Add(image);

                    listBoxItem.Content = grid;

                    listBoxItem.Background = HexToSolidColorBrush("1BA1E2");
                    listBoxItem.Margin = new Thickness(30, 00, 20, 20);
                    listBoxItem.Width = 380;
                    listBoxItem.Height = 100;
                    listBoxItem.FontSize = 30;

                    listBoxItem.MouseEnter += new MouseEventHandler(listBoxItem_MouseEnter);
                    listBoxItem.Hold += new EventHandler<System.Windows.Input.GestureEventArgs>(listBoxItemForPage_Hold);

                    colors = 1;
                    listBoxItens.Add(listBoxItem);
                }
                if (result.EmailAddresses.Count() != 0)
                {
                    listBoxItem = new ListBoxItem();
                    //listBoxItem.Content = result.DisplayName.ToLower();

                    grid = new Grid();

                    textBlock = new TextBlock();
                    textBlock.Text = result.DisplayName.ToLower();
                    textBlock.Margin = new Thickness(10, 25, 0, 25);
                    textBlock.VerticalAlignment = VerticalAlignment.Center;

                    image = new Image();
                    image.HorizontalAlignment = HorizontalAlignment.Right;
                    image.VerticalAlignment = VerticalAlignment.Center;
                    image.Height = 50;
                    image.Margin = new Thickness(10, 25, 0, 25);
                    image.Source = new BitmapImage(new Uri("Images/Icons/friend-branco.png", UriKind.Relative));

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(350);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    columDefinition = new ColumnDefinition();
                    gridLength = new GridLength(80);
                    columDefinition.Width = gridLength;
                    grid.ColumnDefinitions.Add(columDefinition);

                    grid.Children.Add(textBlock);
                    grid.Children.Add(image);

                    listBoxItem.Content = grid;

                    listBoxItem.Margin = new Thickness(30, 00, 20, 20);
                    listBoxItem.Width = 380;
                    listBoxItem.Height = 100;
                    listBoxItem.FontSize = 30;

                    if (colors == 1)
                    {
                        listBoxItem.Background = HexToSolidColorBrush("F0A30A");
                    }
                    else if (colors == 2)
                    {
                        listBoxItem.Background = HexToSolidColorBrush("D80073");
                    }
                    else if (colors == 3)
                    {
                        listBoxItem.Background = HexToSolidColorBrush("60A817");
                        colors = 0;
                    }

                    listBoxItem.MouseEnter += new MouseEventHandler(listBoxItem_MouseEnter);
                    listBoxItem.Hold += new EventHandler<System.Windows.Input.GestureEventArgs>(listBoxItem_Hold);

                    colors++;
                    aux++;
                    listBoxItens.Add(listBoxItem);
                }
            }
            if (listListBoxItens.Count() != 0)
            {
                if (listListBoxItens.Count() != e.Results.Count() / 3 + 1)
                    listListBoxItens.Add(listBoxItens);
                listBoxContact.ItemsSource = listListBoxItens[0];
                /*
                while (listBoxContact.ItemsSource.GetEnumerator().MoveNext())
                    itensOnPage++;

                playSound("This page has  " + (itensOnPage) + " itens.");
                 * */
            }
            else
            {
                listBoxContact.ItemsSource = listBoxItens;
                playSound("This page has  " + (listBoxItens.Count) + " itens.");
            }
        }
Esempio n. 58
0
 void contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
 {
     if (!e.Results.Any())
     {
         var items = new DateStringDisplay { StartTime = "Add birthdays to your contacts to see them here...", Subject = string.Empty };
         BirthdaysListBox.ItemsSource = new[] { items };
     }
     else
     {
         var birthdays =
             (from contact in e.Results
             let birthday = contact.Birthdays.FirstOrDefault()
             where birthday != DateTime.MinValue
             select new DateDisplay { StartTime = birthday, Subject = contact.DisplayName }).ToList();
         if (birthdays.Count > 0)
         {
             BirthdaysListBox.ItemsSource = birthdays;
         }
         else
         {
             var items = new DateStringDisplay { StartTime = "Add birthdays to your contacts to see them here...", Subject = string.Empty };
             BirthdaysListBox.ItemsSource = new[] { items };
         }
     }
 }
Esempio n. 59
0
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            int i = 0;
            byte[] dbimg = {0};
            foreach (Contact con in e.Results)
            {

                try
                {
                    GlobleContacts.Names.Add(con.DisplayName);
                }
                catch
                {
                    GlobleContacts.Names.Add("(No Name)");
                }
                try
                {
                    string temp = con.PhoneNumbers.FirstOrDefault().ToString();
                    string number = "";

                    int k = 0;
                    while (temp[k] != '(')
                    {
                        number += temp[k];
                        k++;
                    }
                    GlobleContacts.Numbers.Add(number);
                }
                catch
                {
                    GlobleContacts.Numbers.Add("(No Number)");
                }
                try
                {
                    var a = con.EmailAddresses.ToList();
                    GlobleContacts.Emails.Add(a[0].EmailAddress.ToString());
                }
                catch
                {
                    GlobleContacts.Emails.Add("(No Email Address)");
                }
                try
                {
                    var g = e.Results.ToList();
                    BitmapImage img = new BitmapImage();
                    img.SetSource(g[i].GetPicture());
                    GlobleContacts.Images.Add(img);
                }
                catch
                {
                    BitmapImage licoriceImage = new BitmapImage(new Uri("Default.jpeg", UriKind.Relative));
                    GlobleContacts.Images.Add(licoriceImage);
                }
                try
                {
                    var a = con.Addresses.ToList();
                    GlobleContacts.Addresses.Add(a[0].PhysicalAddress.City + ", " + a[0].PhysicalAddress.CountryRegion);
                }
                catch
                {
                    GlobleContacts.Addresses.Add("(No Address)");
                }
                try
                {
                    var a = con.Websites.ToList();
                    GlobleContacts.Websites.Add(a[0].ToString());
                }
                catch
                {
                    GlobleContacts.Websites.Add("(No Website)");
                }

                // ---- checking for fav. this need to be change --- ///
                GlobleContacts.isFav.Add(0);
                // ---- checking for fav. this need to be change --- ///

                dbimg = ImageToBytes(GlobleContacts.Images[i]);

                using (var db = new SQLiteConnection(dbPath))
                {
                    db.RunInTransaction(() =>
                    {
                        db.Insert(new Person()
                        {
                            Names = GlobleContacts.Names[i],
                            Numbers = GlobleContacts.Numbers[i],
                            Emails = GlobleContacts.Emails[i],
                            Images = dbimg,
                            Addresses = GlobleContacts.Addresses[i],
                            Websites = GlobleContacts.Websites[i],
                            isFav = GlobleContacts.isFav[i]
                        });
                    });
                }

                i++;
            }

            IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
            StreamWriter Writer = new StreamWriter(new IsolatedStorageFileStream("FirstRun.txt", FileMode.OpenOrCreate, fileStorage));
            Writer.WriteLine("DataStored");
            Writer.Close();

            pb.Visibility = Visibility.Collapsed;
            retrievingData();
        }
Esempio n. 60
0
        private void postAdd_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            if (e.Results.Any())
            {
                new List<Contact>();

                int n = (from Contact contact in e.Results select contact.GetHashCode()).Max();
                Contact newContact = (from Contact contact in e.Results
                                      where contact.GetHashCode() == n
                                      select contact).First();

                DispatchCommandResult(new PluginResult(PluginResult.Status.OK, newContact.ToJson(null)));
            }
            else
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
            }
        }