This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathAddressBookController.xib.cs
96 lines (83 loc) · 2.39 KB
/
AddressBookController.xib.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using AddressBookUI;
using Foundation;
using UIKit;
namespace MonoCatalog {
public partial class AddressBookController : UIViewController {
ABPeoplePickerNavigationController p;
public AddressBookController () : base ("AddressBookController", null)
{
}
protected override void Dispose (bool disposing)
{
if (p != null) {
p.Dispose ();
p = null;
}
base.Dispose (disposing);
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
NavigationController.NavigationBar.Translucent = false;
}
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;
}
partial void showPicker (UIKit.UIButton sender)
{
Console.Error.WriteLine ("# Select Contacts pushed!");
PresentModalViewController (GetPicker (), true);
}
void HandlePersonSelection (AddressBook.ABPerson person)
{
Console.Error.WriteLine ("# select Person: {0}", person);
toString.Text = person.ToString ();
firstName.Text = person.FirstName;
lastName.Text = person.LastName;
property.Text = "";
identifier.Text = "";
}
void HandlePersonPropertySelection (AddressBook.ABPerson person, AddressBook.ABPersonProperty property, int? id)
{
Console.Error.WriteLine ("# perform action; person={0}", person);
toString.Text = person.ToString ();
firstName.Text = person.FirstName;
lastName.Text = person.LastName;
identifier.Text = id.ToString ();
identifier.Text = id.HasValue ? id.ToString () : "";
}
}
}