Beispiel #1
0
        void setupPicker()
        {
            picker               = new ABPeoplePickerNavigationController();
            picker.Delegate      = new PickerDelegate();
            picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                personViewer.DisplayedPerson = e.Person;
                picker.PushViewController(personViewer, true);
            };
            picker.PerformAction += delegate(object sender, ABPeoplePickerPerformActionEventArgs e) {
                var prop  = (ABMultiValue <string>)e.Person.GetProperty(e.Property);
                var email = prop[e.Identifier.Value].Value;
                SelectedValue.Email  = email;
                SelectedValue.Person = e.Person;
                picker.DismissModalViewControllerAnimated(true);
                this.NavigationController.PopViewControllerAnimated(false);
            };

            picker.Cancelled += delegate {
                picker.DismissModalViewControllerAnimated(true);
                this.NavigationController.PopViewControllerAnimated(false);
            };

            personViewer = new ABPersonViewController();
            personViewer.DisplayedProperties.Add(ABPersonProperty.FirstName);
            personViewer.DisplayedProperties.Add(ABPersonProperty.LastName);
            personViewer.DisplayedProperties.Add(ABPersonProperty.Email);
            personViewer.PerformDefaultAction += delegate(object sender, ABPersonViewPerformDefaultActionEventArgs e) {
                var prop  = (ABMultiValue <string>)e.Person.GetProperty(e.Property);
                var email = prop[e.Identifier.Value].Value;
                SelectedValue.Email  = email;
                SelectedValue.Person = e.Person;
                picker.DismissModalViewControllerAnimated(true);
                this.NavigationController.PopViewControllerAnimated(false);
            };
        }
        private void ShowContactPicker()
        {
            // The TableView.ReloadData() is to force the cells to reload, as they were showing as transparent.

            peoplePicker               = new ABPeoplePickerNavigationController();
            peoplePicker.Cancelled    += (sender, e) => { peoplePicker.DismissModalViewControllerAnimated(true); TableView.ReloadData(); };
            peoplePicker.SelectPerson += (sender, e) => { peoplePicker.DismissModalViewControllerAnimated(true); TableView.ReloadData(); };
            PresentModalViewController(peoplePicker, true);
        }
        private void ShowContactPicker()
        {

            // The TableView.ReloadData() is to force the cells to reload, as they were showing as transparent.

            peoplePicker = new ABPeoplePickerNavigationController();
            peoplePicker.Cancelled += (sender, e) => { peoplePicker.DismissModalViewControllerAnimated(true); TableView.ReloadData();};
            peoplePicker.SelectPerson += (sender, e) => { peoplePicker.DismissModalViewControllerAnimated(true); TableView.ReloadData();};
            PresentModalViewController(peoplePicker, true); 
        }
Beispiel #4
0
        private RootElement RenderPicker(Item values, Item pickerValues)
        {
            // build a section with all the items in the current list
            section = new Section();
            foreach (var item in currentList)
            {
                CheckboxElement ce = new CheckboxElement(item.Name);
                // set the value to true if the current item is in the values list
                ce.Value   = values.Items.IndexOf(item) < 0 ? false : true;
                ce.Tapped += delegate { Checkbox_Click(ce, new EventArgs()); };
                section.Add(ce);
            }

            Section itemTypeSection = null;

            if (itemTypeID == SystemItemTypes.Contact)
            {
                itemTypeSection = new Section()
                {
                    new StringElement("Add contact", delegate {
                        var picker           = new ABPeoplePickerNavigationController();
                        picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                            // process the contact - if it's not null, handle adding the new contact to the ListPicker
                            var contact = ContactPickerHelper.ProcessContact(e.Person);
                            if (contact != null)
                            {
                                HandleAddedContact(contact);
                            }
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        picker.Cancelled += delegate {
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        // present the contact picker
                        controller.PresentModalViewController(picker, true);
                    }),
                };
            }

            var listPickerRoot = new RootElement(caption);

            if (itemTypeSection != null)
            {
                listPickerRoot.Add(itemTypeSection);
            }
            listPickerRoot.Add(section);
            return(listPickerRoot);
        }
Beispiel #5
0
        public static void PickContact(UIViewController view, Action <ABPerson> picked)
        {
            /*
             * ABAddressBook ab = new ABAddressBook();
             * ABPerson p = new ABPerson();
             *
             * p.FirstName = "Brittani";
             * p.LastName = "Clancey";
             *
             * ABMutableMultiValue<string> phones = new ABMutableStringMultiValue();
             * phones.Add("9079470168", ABPersonPhoneLabel.Mobile);
             *
             * p.SetPhones(phones);
             *
             *
             * ab.Add(p);
             * ab.Save();
             */


            picker = new ABPeoplePickerNavigationController();
//picker.DismissModalViewControllerAnimated (true);
            //picker.Dispose();
            picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) { picked(e.Person); };

            picker.PerformAction += delegate(object sender, ABPeoplePickerPerformActionEventArgs e) { };

            picker.Cancelled += delegate {
                picker.DismissModalViewControllerAnimated(true);
                picked(null);
                picker.Dispose();
            };
            view.PresentModalViewController(picker, true);
        }
Beispiel #6
0
        public static void PickContact(UIViewController view, Action<ABPerson> picked)
        {
            /*
            ABAddressBook ab = new ABAddressBook();
            ABPerson p = new ABPerson();

            p.FirstName = "Brittani";
            p.LastName = "Clancey";

            ABMutableMultiValue<string> phones = new ABMutableStringMultiValue();
            phones.Add("9079470168", ABPersonPhoneLabel.Mobile);

            p.SetPhones(phones);

            ab.Add(p);
            ab.Save();
            */

            picker = new ABPeoplePickerNavigationController ();
            //picker.DismissModalViewControllerAnimated (true);
                //picker.Dispose();
            picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) { picked (e.Person); };

            picker.PerformAction += delegate(object sender, ABPeoplePickerPerformActionEventArgs e) { };

            picker.Cancelled += delegate {
                picker.DismissModalViewControllerAnimated (true);
                picked (null);
                picker.Dispose ();
            };
            view.PresentModalViewController (picker, true);
        }
Beispiel #7
0
        private RootElement RenderPicker(Item values, Item pickerValues)
        {
            // build a section with all the items in the current list
            section = new Section();
            foreach (var item in currentList)
            {
                CheckboxElement ce = new CheckboxElement(item.Name);
                // set the value to true if the current item is in the values list
                ce.Value = values.Items.IndexOf(item) < 0 ? false : true;
                ce.Tapped += delegate { Checkbox_Click(ce, new EventArgs()); };
                section.Add(ce);
            }

            Section itemTypeSection = null;
            if (itemTypeID == SystemItemTypes.Contact)
            {
                itemTypeSection = new Section()
                {
                    new StringElement("Add contact", delegate {
                        var picker = new ABPeoplePickerNavigationController();
                        picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                            // process the contact - if it's not null, handle adding the new contact to the ListPicker
                            var contact = ContactPickerHelper.ProcessContact(e.Person);
                            if (contact != null)
                                HandleAddedContact(contact);
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        picker.Cancelled += delegate {
                            picker.DismissModalViewControllerAnimated(true);
                        };

                        // present the contact picker
                        controller.PresentModalViewController(picker, true);
                    }),
                };
            }

            var listPickerRoot = new RootElement(caption);
            if (itemTypeSection != null)
                listPickerRoot.Add(itemTypeSection);
            listPickerRoot.Add(section);
            return listPickerRoot;
        }
Beispiel #8
0
        void setupPicker()
        {
            picker = new ABPeoplePickerNavigationController ();
            picker.Delegate = new PickerDelegate ();
            picker.SelectPerson	+= delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                personViewer.DisplayedPerson = e.Person;
                picker.PushViewController (personViewer, true);
            };
            picker.PerformAction += delegate(object sender, ABPeoplePickerPerformActionEventArgs e) {
                var prop = (ABMultiValue<string>)e.Person.GetProperty (e.Property);
                var phone = prop[e.Identifier.Value].Value;
                SelectedValue.PhoneNumber = phone;
                SelectedValue.Person = e.Person;
                picker.DismissModalViewControllerAnimated (true);
                this.NavigationController.PopViewControllerAnimated (false);
            };

            picker.Cancelled += delegate {
                picker.DismissModalViewControllerAnimated (true);
                this.NavigationController.PopViewControllerAnimated (false);

            };

            personViewer = new ABPersonViewController ();
            personViewer.DisplayedProperties.Add (ABPersonProperty.FirstName);
            personViewer.DisplayedProperties.Add (ABPersonProperty.LastName);
            personViewer.DisplayedProperties.Add (ABPersonProperty.Phone);
            personViewer.PerformDefaultAction += delegate(object sender, ABPersonViewPerformDefaultActionEventArgs e) {
                var prop = (ABMultiValue<string>)e.Person.GetProperty (e.Property);
                var phone = prop[e.Identifier.Value].Value;
                SelectedValue.PhoneNumber = phone;
                SelectedValue.Person = e.Person;
                picker.DismissModalViewControllerAnimated (true);
                this.NavigationController.PopViewControllerAnimated (false);
            };
        }
Beispiel #9
0
        private void AddButton_Click()
        {
            if (Source.List.ItemTypeID == SystemItemTypes.Contact)
            {
                var picker = new ABPeoplePickerNavigationController();
                picker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                    // process the contact - add the new contact or update the existing contact's info from the address book
                    var contact = ContactPickerHelper.ProcessContact(e.Person);
                    if (contact != null)
                        App.ViewModel.SyncWithService();
                    picker.DismissModalViewControllerAnimated(true);
                };

                picker.Cancelled += delegate {
                    picker.DismissModalViewControllerAnimated(true);
                };

                // present the contact picker
                NavigationController.PresentModalViewController(picker, true);
                return;
            }

            // if there is no itemtype-specific action, navigate to the generic Add page
            var addController = App.TabBarController.ViewControllers[0] as UINavigationController;
            if (addController != null)
                addController.PopToRootViewController(false);
            App.TabBarController.SelectedIndex = 0;
        }