示例#1
0
        public async void refreshfav()
        {
            int num;

            string[] separators = { "(", " " };
            string[] ph_num     = new string[2];
            bool     contactavailable;

            this.Favcontacts = new ObservableCollection <Favourites>();
            //favDataSource = new List<AlphaKeyGroup<AddressBook>>();
            foreach (Contact c in PhoneContacts)
            {
                foreach (ContactPhoneNumber ph in c.PhoneNumbers)
                {
                    ph_num = ph.ToString().Split(separators, StringSplitOptions.RemoveEmptyEntries);

                    if (ph_num[0].Length >= 10)
                    {
                        num       = ph_num[0].Length - 10;
                        ph_num[0] = ph_num[0].Substring(num);


                        contactavailable = await ConnectToWindowsAzure(ph_num[0]);

                        if (contactavailable)
                        {
                            Favourites fav = new Favourites()
                            {
                                Name            = c.DisplayName,
                                Favouritenumber = ph_num[0]
                            };
                            this.Favcontacts.Add(fav);
                            //favSource.Add(new AddressBook(c.DisplayName, ph_num[0]));
                        }
                    }
                }
            }
            //favDataSource = AlphaKeyGroup<AddressBook>.CreateGroups(favSource,
            //       System.Threading.Thread.CurrentThread.CurrentUICulture,
            //       (AddressBook s) => { return s.Name; }, true);
            StorageFolder appStorageFolder = IORecipes.GetAppStorageFolder();
            await IORecipes.DeleteFileInFolder(appStorageFolder, FavContactFileName);

            string      itemsAsXML = IORecipes.SerializeToString(this.Favcontacts);
            StorageFile dataFile   = await IORecipes.CreateFileInFolder(appStorageFolder, FavContactFileName);

            await IORecipes.WriteStringToFile(dataFile, itemsAsXML);
        }
示例#2
0
        public ChatData CreateNewChat(Favourites mycon)
        {
            foreach (ChatData c in Items)
            {
                if (c.ContactName == mycon.Name)
                {
                    return(c);
                }
            }

            ChatData result =
                new ChatData()
            {
                ID          = (Items.Count).ToString(),
                ContactName = mycon.Name,
                PhoneNumber = mycon.Favouritenumber
            };

            this.Items.Add(result);
            return(result);
        }