コード例 #1
0
        private void ShowPicker(NSObject sender)
        {
            // This example is to be run on iOS 8.0.
            if (!DeviceHelper.IsRunningOn8())
            {
                return;
            }

            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();

            picker.SelectPerson2  += HandleSelectPerson2;
            picker.PerformAction2 += HandlePerformAction2;
            picker.Cancelled      += HandleCancelled;

            // The people picker will only display the person's name, image and email properties in ABPersonViewController.
            picker.DisplayedProperties.Add(ABPersonProperty.Email);

            // The people picker will enable selection of persons that have at least one email address.
            picker.PredicateForEnablingPerson = NSPredicate.FromFormat("emailAddresses.@count > 0");

            // The people picker will select a person that has exactly one email address and call HandleSelectPerson2,
            // otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
            picker.PredicateForSelectionOfPerson = NSPredicate.FromFormat("emailAddresses.@count = 1");

            PresentViewController(picker, true, null);
        }
コード例 #2
0
        void ShowPicker(NSObject sender)
        {
            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();

            picker.SelectPerson   += HandleSelectPerson;
            picker.SelectPerson2  += HandleSelectPerson2;
            picker.PerformAction  += HandlePerformAction;
            picker.PerformAction2 += HandlePerformAction2;
            picker.Cancelled      += HandleCancelled;

            // The people picker will only display the person's name, image and email properties in ABPersonViewController.
            picker.DisplayedProperties.Add(ABPersonProperty.Email);

            // The people picker will enable selection of persons that have at least one email address.
            if (picker.RespondsToSelector(new Selector("setPredicateForEnablingPerson:")))
            {
                picker.PredicateForEnablingPerson = NSPredicate.FromFormat("emailAddresses.@count > 0");
            }

            // The people picker will select a person that has exactly one email address and call peoplePickerNavigationController:didSelectPerson:,
            // otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
            if (picker.RespondsToSelector(new Selector("setPredicateForSelectionOfPerson:")))
            {
                picker.PredicateForSelectionOfPerson = NSPredicate.FromFormat("emailAddresses.@count = 1");
            }

            PresentViewController(picker, true, null);
        }
コード例 #3
0
        bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, ABPerson selectedPerson, int propertyId, int identifier)
        {
            RaiseEmailPicked(PersonFormatter.GetPickedEmail(selectedPerson, identifier));
            peoplePicker.DismissViewController(true, null);

            return(false);
        }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _chooseContact       = UIButton.FromType(UIButtonType.RoundedRect);
            _chooseContact.Frame = new CGRect(10, 10, 200, 50);
            _chooseContact.SetTitle("Choose a Contact", UIControlState.Normal);
            _contactName = new UILabel {
                Frame = new CGRect(10, 70, 200, 50)
            };

            View.AddSubviews(_chooseContact, _contactName);

            _contactController = new ABPeoplePickerNavigationController();

            _chooseContact.TouchUpInside += delegate {
                this.PresentModalViewController(_contactController, true);
            };

            _contactController.Cancelled += delegate {
                this.DismissModalViewController(true);
            };

            _contactController.SelectPerson2 += delegate(object sender, ABPeoplePickerSelectPerson2EventArgs e) {
                _contactName.Text = String.Format("{0} {1}", e.Person.FirstName, e.Person.LastName);

                this.DismissModalViewController(true);
            };
        }
コード例 #5
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);
            };
        }
コード例 #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);
        }
コード例 #7
0
		void ShowPicker(NSObject sender)
		{
			ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
			#pragma warning disable 618
			picker.SelectPerson += HandleSelectPerson;
			picker.SelectPerson2 += HandleSelectPerson2;
			picker.PerformAction += HandlePerformAction;
			picker.PerformAction2 += HandlePerformAction2;
			#pragma warning restore 618
			picker.Cancelled += HandleCancelled;

			// The people picker will only display the person's name, image and email properties in ABPersonViewController.
			picker.DisplayedProperties.Add (ABPersonProperty.Email);

			// The people picker will enable selection of persons that have at least one email address.
			if(picker.RespondsToSelector(new Selector("setPredicateForEnablingPerson:")))
				picker.PredicateForEnablingPerson = NSPredicate.FromFormat ("emailAddresses.@count > 0");

			// The people picker will select a person that has exactly one email address and call peoplePickerNavigationController:didSelectPerson:,
			// otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
			if(picker.RespondsToSelector(new Selector("setPredicateForSelectionOfPerson:")))
				picker.PredicateForSelectionOfPerson = NSPredicate.FromFormat ("emailAddresses.@count = 1");

			PresentViewController (picker, true, null);
		}
コード例 #8
0
       public override void ViewDidLoad ()
       {
           base.ViewDidLoad ();
           
           _chooseContact = UIButton.FromType (UIButtonType.RoundedRect);
           _chooseContact.Frame = new CGRect (10, 10, 200, 50);
           _chooseContact.SetTitle ("Choose a Contact", UIControlState.Normal);
           _contactName = new UILabel{Frame = new CGRect (10, 70, 200, 50)};
           
           View.AddSubviews (_chooseContact, _contactName);
 
           _contactController = new ABPeoplePickerNavigationController ();
           
           _chooseContact.TouchUpInside += delegate {
               this.PresentModalViewController (_contactController, true); };
           
           _contactController.Cancelled += delegate {
               this.DismissModalViewController (true); };
           
           _contactController.SelectPerson2 += delegate(object sender, ABPeoplePickerSelectPerson2EventArgs e) {
                          
               _contactName.Text = String.Format ("{0} {1}", e.Person.FirstName, e.Person.LastName);
                             
               this.DismissModalViewController (true);
           };
       }
コード例 #9
0
ファイル: AddressBook.cs プロジェクト: Clancey/ClanceyLib
        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);
        }
コード例 #10
0
		protected override void Dispose (bool disposing)
		{
			if (p != null) {
				p.Dispose ();
				p = null;
			}
			base.Dispose (disposing);
		}
コード例 #11
0
 protected override void Dispose(bool disposing)
 {
     if (p != null)
     {
         p.Dispose();
         p = null;
     }
     base.Dispose(disposing);
 }
コード例 #12
0
        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);
        }
コード例 #13
0
        private void ShowPicker(NSObject sender)
        {
            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();

            picker.SelectPerson  += HandleSelectPerson;
            picker.SelectPerson2 += HandleSelectPerson2;
            picker.Cancelled     += HandleCancelled;

            PresentViewController(picker, true, null);
        }
コード例 #14
0
        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); 
        }
コード例 #15
0
		private void ShowPicker(NSObject sender)
		{
			ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
			#pragma warning disable 618
			picker.SelectPerson += HandleSelectPerson;
			picker.SelectPerson2 += HandleSelectPerson2;
			#pragma warning restore 618
			picker.Cancelled += HandleCancelled;

			PresentViewController (picker, true, null);
		}
コード例 #16
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Title = "Address Book Controllers";

			// displays the contact picker controller when the choose contact button is clicked
			btnChooseContact.TouchUpInside += (s, e) => {
				// create the picker control
				addressBookPicker = new ABPeoplePickerNavigationController();

				// in this case, we can call present modal view controller from the nav controller,
				// but we could have just as well called PresentModalViewController(...)
				NavigationController.PresentModalViewController(addressBookPicker, true);

				// when cancel is clicked, dismiss the controller
				// HACK: NavigationController.DismissModalViewControllerAnimated to NavigationController.DismissModalViewController
				addressBookPicker.Cancelled += (sender, eventArgs) => { NavigationController.DismissModalViewController(true); };

				// when a contact is chosen, populate the page with details and dismiss the controller
				addressBookPicker.SelectPerson2 += (sender, args) => {
					selectedPerson = args.Person;
					lblFirstName.Text = selectedPerson.FirstName;
					lblLastName.Text = selectedPerson.LastName;
					// HACK: NavigationController.DismissModalViewControllerAnimated to NavigationController.DismissModalViewController
					NavigationController.DismissModalViewController(true);
				};
			};

			// shows the view/edit contact controller when the button is clicked
			btnViewSelectedContact.TouchUpInside += (s, e) => {

				// if a contact hasn't been selected, show an alert and return out
				if(selectedPerson == null)
				{
					new UIAlertView ("Alert", "You must select a contact first.", null, "OK", null).Show ();
					return;
				}

				// instantiate a new controller
				addressBookViewPerson = new ABPersonViewController ();

				// set the contact to display
				addressBookViewPerson.DisplayedPerson = selectedPerson;

				// allow editing
				addressBookViewPerson.AllowsEditing = true;

				// push the controller onto the nav stack. the view/edit controller requires a nav
				// controller and handles it's own dismissal
				NavigationController.PushViewController (addressBookViewPerson, true);
			};
		}
コード例 #17
0
		private void ShowPicker(NSObject sender)
		{
			// This example is to be run on iOS 8.0.
			if (!DeviceHelper.IsRunningOn8())
				return;

			ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
			picker.SelectPerson2 += HandleSelectPerson2;
			picker.Cancelled += HandleCancelled;

			PresentViewController (picker, true, null);
		}
コード例 #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Address Book Controllers";

            // displays the contact picker controller when the choose contact button is clicked
            btnChooseContact.TouchUpInside += (s, e) => {
                // create the picker control
                addressBookPicker = new ABPeoplePickerNavigationController();

                // in this case, we can call present modal view controller from the nav controller,
                // but we could have just as well called PresentModalViewController(...)
                NavigationController.PresentModalViewController(addressBookPicker, true);

                // when cancel is clicked, dismiss the controller
                // HACK: NavigationController.DismissModalViewControllerAnimated to NavigationController.DismissModalViewController
                addressBookPicker.Cancelled += (sender, eventArgs) => { NavigationController.DismissModalViewController(true); };

                // when a contact is chosen, populate the page with details and dismiss the controller
                addressBookPicker.SelectPerson += (object sender, ABPeoplePickerSelectPersonEventArgs args) => {
                    selectedPerson    = args.Person;
                    lblFirstName.Text = selectedPerson.FirstName;
                    lblLastName.Text  = selectedPerson.LastName;
                    // HACK: NavigationController.DismissModalViewControllerAnimated to NavigationController.DismissModalViewController
                    NavigationController.DismissModalViewController(true);
                };
            };

            // shows the view/edit contact controller when the button is clicked
            btnViewSelectedContact.TouchUpInside += (s, e) => {
                // if a contact hasn't been selected, show an alert and return out
                if (selectedPerson == null)
                {
                    new UIAlertView("Alert", "You must select a contact first.", null, "OK", null).Show();
                    return;
                }

                // instantiate a new controller
                addressBookViewPerson = new ABPersonViewController();

                // set the contact to display
                addressBookViewPerson.DisplayedPerson = selectedPerson;

                // allow editing
                addressBookViewPerson.AllowsEditing = true;

                // push the controller onto the nav stack. the view/edit controller requires a nav
                // controller and handles it's own dismissal
                NavigationController.PushViewController(addressBookViewPerson, true);
            };
        }
コード例 #19
0
 // http://bugzilla.xamarin.com/show_bug.cgi?id=980
 public void Bug980_AddressBook_NRE()
 {
     using (ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController()) {
         // no NRE should occur
         if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
         {
             Assert.Null(picker.AddressBook);
         }
         else
         {
             Assert.NotNull(picker.AddressBook);
         }
     }
 }
コード例 #20
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);
        }
コード例 #21
0
    public override bool ShouldContinueAfterSelectingPerson(ABPeoplePickerNavigationController peoplePicker, ABRecord person)
    {
        PersonalTest.Log("Selected: " + person.CopyCompositeName());

        // 0 means person, 1 means organization
        CFType kindCFType = person.CopyValue(ABPerson.kABPersonKindProperty);

        PersonalTest.Log("Type: " + kindCFType.ToInt());

        CFType       phonesCFType = person.CopyValue(ABPerson.kABPersonPhoneProperty);
        ABMultiValue phones       = phonesCFType.Cast <ABMultiValue>();

        for (int i = 0; i < phones.GetCount(); i++)
        {
            string phoneNumStr = phones.CopyValueAtIndex(i).ToString();
            PersonalTest.Log("Phone number: " + phoneNumStr);
        }

        CFType       addressesCFType = person.CopyValue(ABPerson.kABPersonAddressProperty);
        ABMultiValue addresses       = addressesCFType.Cast <ABMultiValue>();

        for (int i = 0; i < addresses.GetCount(); i++)
        {
            Dictionary <object, object> address = addresses.CopyValueAtIndex(i).ToDictionary();
            PersonalTest.Log("Address: " + Json.Serialize(address));
        }

        CFType       emailsCFType = person.CopyValue(ABPerson.kABPersonEmailProperty);
        ABMultiValue emails       = emailsCFType.Cast <ABMultiValue>();

        for (int i = 0; i < emails.GetCount(); i++)
        {
            string emailStr = emails.CopyValueAtIndex(i).ToString();
            PersonalTest.Log("Email: " + emailStr);
        }

        CFType birthdayCFType = person.CopyValue(ABPerson.kABPersonBirthdayProperty);

        if (birthdayCFType != null)
        {
            PersonalTest.Log("Birthday: " + birthdayCFType.ToDateTime());
        }

        CFType creationDateCFType = person.CopyValue(ABPerson.kABPersonCreationDateProperty);

        PersonalTest.Log("Creation date: " + creationDateCFType.ToDateTime());

        UIApplication.deviceRootViewController.DismissViewController(true, null);
        return(false);
    }
コード例 #22
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _contactController = new ABPeoplePickerNavigationController();

            this.PresentModalViewController(_contactController, true);              //display contact chooser


            _contactController.Cancelled += delegate {
                Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync();

                this.DismissModalViewController(true);
            };

            _contactController.SelectPerson2 += delegate(object sender, ABPeoplePickerSelectPerson2EventArgs e) {
                var    getphones = e.Person.GetPhones();
                string number    = "";

                if (getphones == null)
                {
                    number = "Nothing";
                }
                else if (getphones.Count > 1)
                {
                    //il ya plus de 2 num de telephone
                    foreach (var t in getphones)
                    {
                        number = t.Value + "/" + number;
                    }
                }
                else if (getphones.Count == 1)
                {
                    //il ya 1 num de telephone
                    foreach (var t in getphones)
                    {
                        number = t.Value;
                    }
                }


                Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync();


                var twopage_renderer = new MyPage();
                MessagingCenter.Send <MyPage, string> (twopage_renderer, "num_select", number);
                this.DismissModalViewController(true);
            };
        }
コード例 #23
0
        bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, ABPerson selectedPerson)
        {
            bool shouldcontinue = false;

            using (ABMultiValue <string> emails = selectedPerson.GetEmails())
                shouldcontinue = emails.Count == 1;

            if (!shouldcontinue)
            {
                peoplePicker.DismissViewController(true, null);
                RaiseEmailPicked(PersonFormatter.GetPickedEmail(selectedPerson));
            }

            return(shouldcontinue);
        }
コード例 #24
0
 // http://bugzilla.xamarin.com/show_bug.cgi?id=980
 public void Bug980_AddressBook_NRE()
 {
     TestRuntime.AssertSystemVersion(PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);              // The AddressBook framework was introduced in Mac Catalyst 14.0
     using (ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController()) {
         // no NRE should occur
         if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
         {
             Assert.Null(picker.AddressBook);
         }
         else
         {
             Assert.NotNull(picker.AddressBook);
         }
     }
 }
コード例 #25
0
        private void ShowPicker(NSObject sender)
        {
            // This example is to be run on iOS 8.0.
            if (!DeviceHelper.IsRunningOn8())
            {
                return;
            }

            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();

            picker.SelectPerson2 += HandleSelectPerson2;
            picker.Cancelled     += HandleCancelled;

            PresentViewController(picker, true, null);
        }
コード例 #26
0
        // Opens up a contact picker and then populates the screen, based on the contact chosen
        protected void SelectContact(object s, EventArgs e)
        {
            // create the picker control
            addressBookPicker = new ABPeoplePickerNavigationController();

            NavigationController.PresentModalViewController(addressBookPicker, true);

            // wire up the cancelled event to dismiss the picker
            addressBookPicker.Cancelled += (sender, eventArgs) => { NavigationController.DismissModalViewControllerAnimated(true); };

            // when a contact is chosen, populate the page and then dismiss the picker
            addressBookPicker.SelectPerson += (object sender, ABPeoplePickerSelectPersonEventArgs args) => {
                PopulatePage(args.Person);
                NavigationController.DismissModalViewControllerAnimated(true);
            };
        }
コード例 #27
0
        void ShowPeoplePickerController()
        {
            var picker = new ABPeoplePickerNavigationController();

            // TODO: https://trello.com/c/ov8Rd2z1
            picker.PerformAction2                 += HandlePerformAction2;
            picker.PredicateForEnablingPerson      = NSPredicate.FromValue(true);         // Enable selection for any person
            picker.PredicateForSelectionOfPerson   = NSPredicate.FromValue(false);        // Don't select the person. Let me browse his properties
            picker.PredicateForSelectionOfProperty = NSPredicate.FromValue(true);         // Invoke call back when user tap on any property

            // TODO: use flags instead https://trello.com/c/c4cwIMdE
            picker.DisplayedProperties.Add(ABPersonProperty.Phone);
            picker.DisplayedProperties.Add(ABPersonProperty.Email);
            picker.DisplayedProperties.Add(ABPersonProperty.Birthday);

            PresentViewController(picker, true, null);
        }
コード例 #28
0
		public AddressBookManager ()
		{
			PeoplePicker = new ABPeoplePickerNavigationController ();
			PeoplePicker.Delegate = this;

			// The people picker will only display the person's name, image and email properties in ABPersonViewController.
			PeoplePicker.DisplayedProperties.Add (ABPersonProperty.Email);

			// The people picker will enable selection of persons that have at least one email address.
			if(PeoplePicker.RespondsToSelector(new Selector("setPredicateForEnablingPerson:")))
				PeoplePicker.PredicateForEnablingPerson = NSPredicate.FromFormat ("emailAddresses.@count > 0");

			// The people picker will select a person that has exactly one email address and call peoplePickerNavigationController:didSelectPerson:,
			// otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
			if(PeoplePicker.RespondsToSelector(new Selector("setPredicateForSelectionOfPerson:")))
				PeoplePicker.PredicateForSelectionOfPerson = NSPredicate.FromFormat ("emailAddresses.@count = 1");
		}
コード例 #29
0
        ABPeoplePickerNavigationController GetPicker()
        {
            if (p != null)
            {
                return(p);
            }

            p = new ABPeoplePickerNavigationController();
            p.SelectPerson += (o, e) => {
                Console.Error.WriteLine("# select Person: {0}", e.Person);
                toString.Text   = e.Person.ToString();
                firstName.Text  = e.Person.FirstName;
                lastName.Text   = e.Person.LastName;
                property.Text   = "";
                identifier.Text = "";
                e.Continue      = selectProperty.On;
                if (!e.Continue)
                {
                    DismissModalViewControllerAnimated(true);
                }
            };
            p.PerformAction += (o, e) => {
                Console.Error.WriteLine("# perform action; person={0}", e.Person);
                toString.Text   = e.Person.ToString();
                firstName.Text  = e.Person.FirstName;
                lastName.Text   = e.Person.LastName;
                property.Text   = e.Property.ToString();
                identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString() : "";
                e.Continue      = performAction.On;
                if (!e.Continue)
                {
                    DismissModalViewControllerAnimated(true);
                }
            };
            p.Cancelled += (o, e) => {
                Console.Error.WriteLine("# select Person cancelled.");
                toString.Text   = "Cancelled";
                firstName.Text  = "";
                lastName.Text   = "";
                property.Text   = "";
                identifier.Text = "";
                DismissModalViewControllerAnimated(true);
            };
            return(p);
        }
コード例 #30
0
 static void Init()
 {
     if (picker != null)
     {
         return;
     }
     picker            = new ABPeoplePickerNavigationController();
     picker.Cancelled += (s, e) =>
     {
         picker.DismissModalViewController(true);
         _callback(null);
     };
     picker.SelectPerson2 += (s, e) =>
     {
         picker.DismissModalViewController(true);
         _callback(e.Person);
     };
 }
コード例 #31
0
        ABPeoplePickerNavigationController GetPicker()
        {
            if (p != null)
            {
                return(p);
            }

            p = new ABPeoplePickerNavigationController();
            p.SelectPerson += (o, e) => {
                HandlePersonSelection(e.Person);
                e.Continue = selectProperty.On;
                if (!e.Continue)
                {
                    DismissModalViewController(true);
                }
            };
            p.SelectPerson2 += (sender, e) => {
                HandlePersonSelection(e.Person);
            };

            p.PerformAction += (o, e) => {
                HandlePersonPropertySelection(e.Person, e.Property, e.Identifier);
                if (!e.Continue)
                {
                    DismissModalViewController(true);
                }
            };
            p.PerformAction2 += (sender, e) => {
                HandlePersonPropertySelection(e.Person, e.Property, e.Identifier);
            };

            p.Cancelled += (o, e) => {
                Console.Error.WriteLine("# select Person cancelled.");
                toString.Text   = "Cancelled";
                firstName.Text  = "";
                lastName.Text   = "";
                property.Text   = "";
                identifier.Text = "";
                DismissModalViewController(true);
            };
            return(p);
        }
コード例 #32
0
 partial void showPicker(MonoTouch.UIKit.UIButton sender)
 {
     Console.Error.WriteLine("# Select Contacts pushed!");
     using (p = new ABPeoplePickerNavigationController()) {
         p.SelectPerson += (o, e) => {
             Console.Error.WriteLine("# select Person: {0}", e.Person);
             toString.Text   = e.Person.ToString();
             firstName.Text  = e.Person.FirstName;
             lastName.Text   = e.Person.LastName;
             property.Text   = "";
             identifier.Text = "";
             e.Continue      = selectProperty.On;
             if (!e.Continue)
             {
                 DismissModalViewControllerAnimated(true);
             }
         };
         p.PerformAction += (o, e) => {
             Console.Error.WriteLine("# perform action; person={0}", e.Person);
             toString.Text   = e.Person.ToString();
             firstName.Text  = e.Person.FirstName;
             lastName.Text   = e.Person.LastName;
             property.Text   = e.Property.ToString();
             identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString() : "";
             e.Continue      = performAction.On;
             if (!e.Continue)
             {
                 DismissModalViewControllerAnimated(true);
             }
         };
         p.Cancelled += (o, e) => {
             Console.Error.WriteLine("# select Person cancelled.");
             toString.Text   = "Cancelled";
             firstName.Text  = "";
             lastName.Text   = "";
             property.Text   = "";
             identifier.Text = "";
             DismissModalViewControllerAnimated(true);
         };
         PresentModalViewController(p, true);
     }
 }
コード例 #33
0
		public  void ShowContactPicker()
		{
			Device.BeginInvokeOnMainThread (() => 
			{
					var firstController = UIApplication.SharedApplication.KeyWindow.RootViewController.ChildViewControllers.First().ChildViewControllers.Last().ChildViewControllers.First();

					ABPeoplePickerNavigationController _contactController = new ABPeoplePickerNavigationController ();
					_contactController.Cancelled += (object sender, EventArgs e) => 
					{
						firstController.DismissViewController( true, null );	
					};

					_contactController.SelectPerson2 += (object sender, ABPeoplePickerSelectPerson2EventArgs e) => 
					{
						AddEventsSituationsOrThoughts.contactSelectAction ( e.Person.FirstName );
					};
					firstController.PresentViewController (_contactController, true, null);		
					//_contactController.ShowController();
			});
		}
コード例 #34
0
        public AddressBookManager()
        {
            PeoplePicker          = new ABPeoplePickerNavigationController();
            PeoplePicker.Delegate = this;

            // The people picker will only display the person's name, image and email properties in ABPersonViewController.
            PeoplePicker.DisplayedProperties.Add(ABPersonProperty.Email);

            // The people picker will enable selection of persons that have at least one email address.
            if (PeoplePicker.RespondsToSelector(new Selector("setPredicateForEnablingPerson:")))
            {
                PeoplePicker.PredicateForEnablingPerson = NSPredicate.FromFormat("emailAddresses.@count > 0");
            }

            // The people picker will select a person that has exactly one email address and call peoplePickerNavigationController:didSelectPerson:,
            // otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
            if (PeoplePicker.RespondsToSelector(new Selector("setPredicateForSelectionOfPerson:")))
            {
                PeoplePicker.PredicateForSelectionOfPerson = NSPredicate.FromFormat("emailAddresses.@count = 1");
            }
        }
コード例 #35
0
    public override bool ShouldContinueAfterSelectingPerson(ABPeoplePickerNavigationController peoplePicker, ABRecord person)
    {
        PersonalTest.Log("Selected: " + person.CopyCompositeName());

        // 0 means person, 1 means organization
        CFType kindCFType = person.CopyValue(ABPerson.kABPersonKindProperty);
        PersonalTest.Log("Type: " + kindCFType.ConvertToInt());

        CFType phonesCFType = person.CopyValue(ABPerson.kABPersonPhoneProperty);
        ABMultiValue phones = phonesCFType.Cast<ABMultiValue>();
        for (int i=0; i<phones.GetCount(); i++) {
            string phoneNumStr = phones.CopyValueAtIndex(i).ConvertToString();
            PersonalTest.Log("Phone number: " + phoneNumStr);
        }

        CFType addressesCFType = person.CopyValue(ABPerson.kABPersonAddressProperty);
        ABMultiValue addresses = addressesCFType.Cast<ABMultiValue>();
        for (int i=0; i<addresses.GetCount(); i++) {
            Dictionary<object, object> address = addresses.CopyValueAtIndex(i).ConvertToObject() as Dictionary<object, object>;
            PersonalTest.Log("Address: " + Json.Serialize(address));
        }

        CFType emailsCFType = person.CopyValue(ABPerson.kABPersonEmailProperty);
        ABMultiValue emails = emailsCFType.Cast<ABMultiValue>();
        for (int i=0; i<emails.GetCount(); i++) {
            string emailStr = emails.CopyValueAtIndex(i).ConvertToString();
            PersonalTest.Log("Email: " + emailStr);
        }

        CFType birthdayCFType = person.CopyValue(ABPerson.kABPersonBirthdayProperty);
        if (birthdayCFType != null)
            PersonalTest.Log("Birthday: " + birthdayCFType.ConvertToDateTime());

        CFType creationDateCFType = person.CopyValue(ABPerson.kABPersonCreationDateProperty);
        PersonalTest.Log("Creation date: " + creationDateCFType.ConvertToDateTime());

        UIApplication.deviceRootViewController.DismissViewController(true, null);
        return false;
    }
コード例 #36
0
		ABPeoplePickerNavigationController GetPicker ()
		{
			if (p != null)
				return p;

			p = new ABPeoplePickerNavigationController ();
			p.SelectPerson += (o, e) => {
				Console.Error.WriteLine ("# select Person: {0}", e.Person);
				toString.Text   = e.Person.ToString ();
				firstName.Text  = e.Person.FirstName;
				lastName.Text   = e.Person.LastName;
				property.Text   = "";
				identifier.Text = "";
				e.Continue = selectProperty.On;
				if (!e.Continue)
					DismissModalViewControllerAnimated (true);
			};
			p.PerformAction += (o, e) => {
				Console.Error.WriteLine ("# perform action; person={0}", e.Person);
				toString.Text   = e.Person.ToString ();
				firstName.Text  = e.Person.FirstName;
				lastName.Text   = e.Person.LastName;
				property.Text   = e.Property.ToString ();
				identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString () : "";
				e.Continue = performAction.On;
				if (!e.Continue)
					DismissModalViewControllerAnimated (true);
			};
			p.Cancelled += (o, e) => {
				Console.Error.WriteLine ("# select Person cancelled.");
				toString.Text   = "Cancelled";
				firstName.Text  = "";
				lastName.Text   = "";
				property.Text   = "";
				identifier.Text = "";
				DismissModalViewControllerAnimated (true);
			};
			return p;
		}
コード例 #37
0
	  partial void showPicker (MonoTouch.UIKit.UIButton sender)
		{
			Console.Error.WriteLine ("# Select Contacts pushed!");
			using (p = new ABPeoplePickerNavigationController ()) {
				p.SelectPerson += (o, e) => {
					Console.Error.WriteLine ("# select Person: {0}", e.Person);
					toString.Text   = e.Person.ToString ();
					firstName.Text  = e.Person.FirstName;
					lastName.Text   = e.Person.LastName;
					property.Text   = "";
					identifier.Text = "";
					e.Continue = selectProperty.On;
					if (!e.Continue)
						DismissModalViewControllerAnimated (true);
				};
				p.PerformAction += (o, e) => {
					Console.Error.WriteLine ("# perform action; person={0}", e.Person);
					toString.Text   = e.Person.ToString ();
					firstName.Text  = e.Person.FirstName;
					lastName.Text   = e.Person.LastName;
					property.Text   = e.Property.ToString ();
					identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString () : "";
					e.Continue = performAction.On;
					if (!e.Continue)
						DismissModalViewControllerAnimated (true);
				};
				p.Cancelled += (o, e) => {
					Console.Error.WriteLine ("# select Person cancelled.");
					toString.Text   = "Cancelled";
					firstName.Text  = "";
					lastName.Text   = "";
					property.Text   = "";
					identifier.Text = "";
					DismissModalViewControllerAnimated (true);
				};
				PresentModalViewController (p, true);
			}
		}
コード例 #38
0
		private void ShowPicker(NSObject sender)
		{
			// This example is to be run on iOS 8.0.
			if (!DeviceHelper.IsRunningOn8())
				return;

			ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
			picker.SelectPerson2 += HandleSelectPerson2;
			picker.PerformAction2 += HandlePerformAction2;
			picker.Cancelled += HandleCancelled;

			// The people picker will only display the person's name, image and email properties in ABPersonViewController.
			picker.DisplayedProperties.Add (ABPersonProperty.Email);

			// The people picker will enable selection of persons that have at least one email address.
			picker.PredicateForEnablingPerson = NSPredicate.FromFormat ("emailAddresses.@count > 0");

			// The people picker will select a person that has exactly one email address and call HandleSelectPerson2,
			// otherwise the people picker will present an ABPersonViewController for the user to pick one of the email addresses.
			picker.PredicateForSelectionOfPerson = NSPredicate.FromFormat ("emailAddresses.@count = 1");

			PresentViewController (picker, true, null);
		}
コード例 #39
0
		ABPeoplePickerNavigationController GetPicker ()
		{
			if (p != null)
				return p;

			p = new ABPeoplePickerNavigationController ();
			p.SelectPerson += (o, e) => {
				HandlePersonSelection(e.Person);
				e.Continue = selectProperty.On;
				if (!e.Continue)
					DismissModalViewController (true);
			};
			p.SelectPerson2 += (sender, e) => {
				HandlePersonSelection(e.Person);
			};

			p.PerformAction += (o, e) => {
				HandlePersonPropertySelection(e.Person, e.Property, e.Identifier);
				if (!e.Continue)
					DismissModalViewController (true);
			};
			p.PerformAction2 += (sender, e) => {
				HandlePersonPropertySelection(e.Person, e.Property, e.Identifier);
			};

			p.Cancelled += (o, e) => {
				Console.Error.WriteLine ("# select Person cancelled.");
				toString.Text = "Cancelled";
				firstName.Text = "";
				lastName.Text = "";
				property.Text = "";
				identifier.Text = "";
				DismissModalViewController (true);
			};
			return p;
		}
コード例 #40
0
 public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson)
 {
     return(true);
 }
コード例 #41
0
ファイル: ListViewController.cs プロジェクト: ogazitt/zaplify
        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;
        }
コード例 #42
0
 private void OnPickPhotoActionSheetClicked(object sender, UIButtonEventArgs e)
 {
     switch (e.ButtonIndex) {
     case 0:
         var cameraPicker = new UIImagePickerController ();
         cameraPicker.SourceType = UIImagePickerControllerSourceType.Camera;
         cameraPicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
         cameraPicker.FinishedPickingMedia += this.OnFinishedPickingPhoto;
         cameraPicker.AllowsEditing = true;
         cameraPicker.Canceled += this.OnCanceledPickingPhoto;
         this.NavigationController.PresentViewController (cameraPicker, true, null);
         break;
     case 1:
         var libraryPicker = new UIImagePickerController ();
         libraryPicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
         libraryPicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
         libraryPicker.FinishedPickingMedia += this.OnFinishedPickingPhoto;
         libraryPicker.Canceled += this.OnCanceledPickingPhoto;
         this.NavigationController.PresentViewController(libraryPicker, true, null);
         break;
     case 2:
         var addressBookPicker = new ABPeoplePickerNavigationController ();
         addressBookPicker.Cancelled += this.OnCanceledPickingContact;
         addressBookPicker.SelectPerson += this.OnPersonSelected;
         this.NavigationController.PresentViewController (addressBookPicker, true, null);
         break;
     }
 }
コード例 #43
0
ファイル: AddressBook.cs プロジェクト: Clancey/ClanceyLib
        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);
            };
        }
コード例 #44
0
		void ShowPeoplePickerController ()
		{
			var picker = new ABPeoplePickerNavigationController ();
			// TODO: https://trello.com/c/ov8Rd2z1
			picker.PerformAction2 += HandlePerformAction2;
			picker.PredicateForEnablingPerson = NSPredicate.FromValue (true); // Enable selection for any person
			picker.PredicateForSelectionOfPerson = NSPredicate.FromValue (false); // Don't select the person. Let me browse his properties
			picker.PredicateForSelectionOfProperty = NSPredicate.FromValue (true); // Invoke call back when user tap on any property

			// TODO: use flags instead https://trello.com/c/c4cwIMdE
			picker.DisplayedProperties.Add (ABPersonProperty.Phone);
			picker.DisplayedProperties.Add (ABPersonProperty.Email);
			picker.DisplayedProperties.Add (ABPersonProperty.Birthday);

			PresentViewController (picker, true, null);
		}
コード例 #45
0
		public ChooseCotactViewController () : base ("ChooseCotactViewController", null)
		{
			_contactController = new ABPeoplePickerNavigationController ();
		}
コード例 #46
0
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            
            //direct use of ABAddressBook
//            ABAddressBook ab = new ABAddressBook ();
//            
//            ABPerson[] people = ab.GetPeople ();
//            
//            foreach (ABPerson person in people) {
//                
//                Console.WriteLine("{0} {1}", person.FirstName, person.LastName);
//                
//                var phones = person.GetPhones ();
//                
//                if (phones.Count > 0) {
//
//                    foreach(var phone in phones)
//                        Console.WriteLine ("  {0}, {1}", phone.Label.ToString(), phone.Value);
//                }  
//            }
            
            _peoplePicker = new ABPeoplePickerNavigationController ();
            
            showPeoplePicker.TouchUpInside += delegate { this.PresentModalViewController (_peoplePicker, true); };
            
            _peoplePicker.Cancelled += delegate { this.DismissModalViewControllerAnimated (true); };
            
            _peoplePicker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                
                // Setting Continue to true allows the picker to navigate to the person details,
                // in which case you wouldn't dimiss the controller below.
                //e.Continue = true;
                
                _person = e.Person;
                
                nameLabel.Text = String.Format ("{0} {1}", _person.FirstName, _person.LastName);
                
                var phones = _person.GetPhones ();
                
                if (phones.Count > 0) {
                    //just using the first phone for demo
                    _phoneNumber = phones[0].Value;
                    phoneLabel.Text = _phoneNumber;
                } else {
                    _phoneNumber = String.Empty;
                }
                
                this.DismissModalViewControllerAnimated (true);
            };
            
            callPerson.TouchUpInside += delegate {
                
                if (!String.IsNullOrEmpty (_phoneNumber)) {
                    
                    NSUrl phoneUrl = new NSUrl (String.Format ("tel:{0}", EscapePhoneNumber (_phoneNumber)));
                    
                    if (UIApplication.SharedApplication.CanOpenUrl (phoneUrl))
                        UIApplication.SharedApplication.OpenUrl (phoneUrl);
                }
            };
        }
コード例 #47
0
ファイル: AddressBook.cs プロジェクト: Clancey/ClanceyLib
 public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson)
 {
     return true;
 }
コード例 #48
0
 void DidSelectPerson(ABPeoplePickerNavigationController peoplePicker, ABPerson selectedPerson)
 {
     RaiseEmailPicked(PersonFormatter.GetPickedEmail(selectedPerson));
 }
コード例 #49
0
ファイル: AddressBook.cs プロジェクト: Clancey/ClanceyLib
 public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson, int propertyId, int identifier)
 {
     return true;
 }
コード例 #50
0
 public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson, int propertyId, int identifier)
 {
     return(true);
 }
コード例 #51
0
ファイル: RegressionTest.cs プロジェクト: jorik041/Touch.Unit
        // http://bugzilla.xamarin.com/show_bug.cgi?id=980
        public void Bug980_AddressBook_NRE()
        {
            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();

            Assert.NotNull(picker.AddressBook);              // no NRE should occur
        }
コード例 #52
0
 public override void DidCancel(ABPeoplePickerNavigationController peoplePicker)
 {
     PersonalTest.Log("Cancel button pressed");
     UIApplication.deviceRootViewController.DismissViewController(true, null);
 }
コード例 #53
0
		bool ShouldContinue (ABPeoplePickerNavigationController peoplePicker, ABPerson selectedPerson)
		{
			bool shouldcontinue = false;
			using (ABMultiValue<string> emails = selectedPerson.GetEmails ())
				shouldcontinue = emails.Count == 1;

			if (!shouldcontinue) {
				peoplePicker.DismissViewController (true, null);
				RaiseEmailPicked (PersonFormatter.GetPickedEmail (selectedPerson));
			}

			return shouldcontinue;
		}
コード例 #54
0
        // Opens up a contact picker and then populates the screen, based on the contact chosen
        protected void SelectContact(object s, EventArgs e)
        {
            // create the picker control
            addressBookPicker = new ABPeoplePickerNavigationController ();

            NavigationController.PresentModalViewController (addressBookPicker, true);

            // wire up the cancelled event to dismiss the picker
            addressBookPicker.Cancelled += (sender, eventArgs) => {
                NavigationController.DismissModalViewControllerAnimated (true);
            };

            // when a contact is chosen, populate the page and then dismiss the picker
            addressBookPicker.SelectPerson += (object sender, ABPeoplePickerSelectPersonEventArgs args) => {
                PopulatePage (args.Person);
                EnableTextFields (true);
                NavigationController.DismissModalViewControllerAnimated (true);
            };
        }
コード例 #55
0
ファイル: PersonalTest.cs プロジェクト: RainbowMin/CameraApp
    private void OnGUI()
    {
        KitchenSink.OnGUIBack();

        GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50));

        //this is the original way of how objective C use call back functions: Delegates using separate files.
        //in this case the file is PeoplePickerNavigationControllerDelegate.cs
        //we have have it easier to use delegates instead of creating new files for each delegate.
        //see examples above.  Ex: PersonalXT.CalendarAccess += delegate( ....
        if (GUILayout.Button("pick/select from contacts", GUILayout.ExpandHeight(true))) {
            ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController();
            if (pickerDelegate == null)
                pickerDelegate = new PeoplePickerNavigationControllerDelegate();
            picker.peoplePickerDelegate = pickerDelegate;
            UIApplication.deviceRootViewController.PresentViewController(picker, true, null);
        }

        if (GUILayout.Button("get all contacts", GUILayout.ExpandHeight(true)))	{
            //this will get you the contact records in which you can manipulate, etc
            //ABRecord[] contacts = PersonalXT.GetAllContactRecords();

            //convienent function to get the names of the contacts
            string[] contactList = PersonalXT.GetAllContactNames();
            for(int i=0; i < contactList.Length; i++){
                Log("Contact " + i + ": " +  contactList[i]);
            }
        }

        if (GUILayout.Button("add new contacts", GUILayout.ExpandHeight(true)))	{
            addNewContact();
        }

        if (GUILayout.Button("init Calendar and show events within 30 days", GUILayout.ExpandHeight(true))) {
            checkEventStoreAccessForCalendar();
        }

        if (GUILayout.Button("add an event for tomorrow", GUILayout.ExpandHeight(true))) {
            addEventForTomorrow();
        }

        if (GUILayout.Button("add alarm to events", GUILayout.ExpandHeight(true))) {
            createAlarmForEvents();
        }

        if (GUILayout.Button("add reminder with geolocation of current location", GUILayout.ExpandHeight(true))) {
            PersonalXT.RequestReminderAccess();
        }

        if (GUILayout.Button("reverse geocode happiest place on earth", GUILayout.ExpandHeight(true))) {
            CLLocation location = new CLLocation(33.809, -117.919);
            CLGeocoder geocoder = new CLGeocoder();
            geocoder.ReverseGeocodeLocation(location, delegate(object[] placemarks, NSError error) {
                if (error != null)
                    Debug.Log(error.LocalizedDescription());
                else {
                    foreach (var p in placemarks) {
                        var placemark = p as CLPlacemark;

                        Debug.Log("placemark: " + placemark.name + "\n"
                            + ABAddressFormatting.ABCreateString(placemark.addressDictionary, true));
                    }
                }
            });
        }

        if (GUILayout.Button("Significant location change", GUILayout.ExpandHeight(true))) {
            if (!CLLocationManager.LocationServicesEnabled() || !CLLocationManager.SignificantLocationChangeMonitoringAvailable()) {
                Debug.Log("Significant change monitoring not available.");
            } else {
        //				CLLocationManager manager = new CLLocationManager();

                manager.StartMonitoringSignificantLocationChanges();
            }
        }

        //commented out remove all events and reminders so users don't accidentally remove important events
        /*
        if (GUILayout.Button("remove all Events", GUILayout.ExpandHeight(true))) {
            PersonalXT.RemoveAllEvents();
            Log ("Removed events");
        }

        if (GUILayout.Button("remove all Reminders", GUILayout.ExpandHeight(true))) {
            PersonalXT.GetAllReminders(); //you can get all the reminders and handle them in line 59 above
            //PersonalXT.RemoveAllReminders(); //or you can simply call removeAllReminders
        }*/

        GUILayout.EndArea();
        OnGUILog();
    }
コード例 #56
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //direct use of ABAddressBook
//            ABAddressBook ab = new ABAddressBook ();
//
//            ABPerson[] people = ab.GetPeople ();
//
//            foreach (ABPerson person in people) {
//
//                Console.WriteLine("{0} {1}", person.FirstName, person.LastName);
//
//                var phones = person.GetPhones ();
//
//                if (phones.Count > 0) {
//
//                    foreach(var phone in phones)
//                        Console.WriteLine ("  {0}, {1}", phone.Label.ToString(), phone.Value);
//                }
//            }

            _peoplePicker = new ABPeoplePickerNavigationController();

            showPeoplePicker.TouchUpInside += delegate { this.PresentModalViewController(_peoplePicker, true); };

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

            _peoplePicker.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
                // Setting Continue to true allows the picker to navigate to the person details,
                // in which case you wouldn't dimiss the controller below.
                //e.Continue = true;

                _person = e.Person;

                nameLabel.Text = String.Format("{0} {1}", _person.FirstName, _person.LastName);

                var phones = _person.GetPhones();

                if (phones.Count > 0)
                {
                    //just using the first phone for demo
                    _phoneNumber    = phones[0].Value;
                    phoneLabel.Text = _phoneNumber;
                }
                else
                {
                    _phoneNumber = String.Empty;
                }

                this.DismissModalViewControllerAnimated(true);
            };

            callPerson.TouchUpInside += delegate {
                if (!String.IsNullOrEmpty(_phoneNumber))
                {
                    NSUrl phoneUrl = new NSUrl(String.Format("tel:{0}", EscapePhoneNumber(_phoneNumber)));

                    if (UIApplication.SharedApplication.CanOpenUrl(phoneUrl))
                    {
                        UIApplication.SharedApplication.OpenUrl(phoneUrl);
                    }
                }
            };
        }
コード例 #57
0
 void DidSelectPersonProperty(ABPeoplePickerNavigationController peoplePicker, ABPerson selectedPerson, int propertyId, int identifier)
 {
     Console.WriteLine(identifier);
     RaiseEmailPicked(PersonFormatter.GetPickedEmail(selectedPerson, identifier));
 }
コード例 #58
0
ファイル: ListPickerPage.cs プロジェクト: ogazitt/zaplify
        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;
        }
コード例 #59
0
 public override bool ShouldContinueAfterSelectingPersonWithPropertyAndIdentifier(ABPeoplePickerNavigationController peoplePicker, ABRecord person, int property, int identifier)
 {
     PersonalTest.Log("ShouldContinueAfterSelectingPerson: " + person.CopyCompositeName() + ", " + property + ", " + identifier);
     return false;
 }
コード例 #60
0
		// http://bugzilla.xamarin.com/show_bug.cgi?id=980
		public void Bug980_AddressBook_NRE ()
		{
			ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
			Assert.NotNull (picker.AddressBook); // no NRE should occur
		}