コード例 #1
0
 private string ExtractEmail(ABMultiValue<string> aBMultiValue)
 {
     foreach (var abMultiValueEntry in aBMultiValue)
     {
         if (string.IsNullOrEmpty(abMultiValueEntry.Value))
         {
             return abMultiValueEntry.Value;
         }
     }
     return null;
 }
コード例 #2
0
 private string ExtractPhoneNumber(ABMultiValue<string> aBMultiValue)
 {
     foreach (var abMultiValueEntry in aBMultiValue)
     {
         if (abMultiValueEntry.Label == "_$!<Mobile>!$_" && !string.IsNullOrEmpty(abMultiValueEntry.Value))
         {
             return abMultiValueEntry.Value;
         }
     }
     return null;
 }
コード例 #3
0
ファイル: MyObject.cs プロジェクト: Monobjc/monobjc-samples
        private static bool FindFirstMatch(ABMultiValue multiValue, NSString label, ref uint index)
        {
            uint mvCount;

            mvCount = multiValue.Count;
            if (mvCount > 0)
            {
                for (uint x = 0; x < mvCount; x++)
                {
                    NSString text = multiValue.LabelAtIndex(x);
                    NSComparisonResult result = text.Compare(label);

                    if (result == NSComparisonResult.NSOrderedSame)
                    {
                        index = x;
                        return true;
                    }
                }
            }
            return false;
        }
コード例 #4
0
 public PhoneNumberTableSource(ABMultiValue<string> phoneNumbers)
 {
     this.phoneNumbers = phoneNumbers;
     if (labels == null)
         labels = new List<string> ();
     else
         labels.Clear ();
     if (numbers == null)
         numbers = new List<string> ();
     else
         numbers.Clear ();
     for (int i = 0; i < phoneNumbers.Count; i++) {
         labels.Add (phoneNumbers [i].Label.Description);
         numbers.Add (phoneNumbers [i].Value);
     }
 }
コード例 #5
0
			public PhoneNumberTableSource(ABMultiValue<string> phoneNumbers)
			{ this.phoneNumbers = phoneNumbers; }
コード例 #6
0
 public ABMutableDateMultiValue()
     : base(ABMultiValue.CreateMutable(ABPropertyType.MultiDateTime), true)
 {
 }
コード例 #7
0
 public bool RemoveAt(nint index)
 {
     return(ABMultiValue.RemoveValueAndLabelAtIndex(Handle, index));
 }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Address Book";

            // add a button to the nav bar that will select a contact to edit
            UIButton btnSelectContact = UIButton.FromType(UIButtonType.RoundedRect);

            btnSelectContact.SetTitle("Select Contact", UIControlState.Normal);
            NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Action, SelectContact), false);

            // disable first two fields until the user select a contact
            EnableTextFields(false);

            // wire up keyboard hiding
            txtPhoneLabel.ShouldReturn += (t) => {
                t.ResignFirstResponder();
                return(true);
            };
            txtPhoneNumber.ShouldReturn += (t) => {
                t.ResignFirstResponder();
                return(true);
            };
            txtFirstName.ShouldReturn += (t) => {
                t.ResignFirstResponder();
                return(true);
            };
            txtLastName.ShouldReturn += (t) => {
                t.ResignFirstResponder();
                return(true);
            };

            // wire up event handlers
            btnSaveChanges.TouchUpInside    += BtnSaveChangesTouchUpInside;
            btnAddPhoneNumber.TouchUpInside += BtnAddPhoneNumberTouchUpInside;

            #region -= Sample code showing how to loop through all the records =-
            //==== This block of code writes out each person contact in the address book and
            // each phone number for that person to the console, just to illustrate the code
            // neccessary to access each item

            // instantiate a reference to the address book
            NSError err;
            addressBook = ABAddressBook.Create(out err);
            if (err != null)
            {
                return;
            }

            // if you want to subscribe to changes
            addressBook.ExternalChange += (object sender, ExternalChangeEventArgs e) => {
                // code to deal with changes
            };

            addressBook.RequestAccess(delegate(bool granted, NSError error) {
                if (!granted || error != null)
                {
                    return;
                }

                // for each record
                foreach (ABRecord item in addressBook)
                {
                    Console.WriteLine(item.Type.ToString() + " " + item.Id);
                    // there are two possible record types, person and group
                    if (item.Type == ABRecordType.Person)
                    {
                        // since we've already tested it to be a person, just create a shortcut to that
                        // type
                        ABPerson person = item as ABPerson;
                        Console.WriteLine(person.FirstName + " " + person.LastName);

                        // get the phone numbers
                        ABMultiValue <string> phones = person.GetPhones();
                        foreach (ABMultiValueEntry <string> val in phones)
                        {
                            Console.Write(val.Label + ": " + val.Value);
                        }
                    }
                }

                // save changes (if you were to have made any)
                //addressBook.Save();
                // or cancel them
                //addressBook.Revert();
            });
            //====
            #endregion

            #region -= keyboard stuff =-

            // wire up our keyboard events
            NSNotificationCenter.DefaultCenter.AddObserver(
                UIKeyboard.WillShowNotification, delegate(NSNotification n) {
                KeyboardOpenedOrClosed(n, "Open");
            });
            NSNotificationCenter.DefaultCenter.AddObserver(
                UIKeyboard.WillHideNotification, delegate(NSNotification n) {
                KeyboardOpenedOrClosed(n, "Close");
            });

            #endregion
        }
コード例 #9
0
		string GetValue(ABMultiValue<string> multiProperty, int identifier)
		{
			nint i = multiProperty.GetIndexForIdentifier (identifier);
			string[] values = multiProperty.GetValues ();
			return values [(int)i];
		}
コード例 #10
0
 public PhoneNumberTableSource(ABMultiValue <string> phoneNumbers)
 {
     this._phoneNumbers = phoneNumbers;
 }