public void DeletePerson(NSWindow window) {
			if (Table.SelectedRow == -1) {
				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Critical,
					InformativeText = "Please select the person to remove from the list of people.",
					MessageText = "Delete Person",
				};
				alert.BeginSheet (window);
			} else {
				// Grab person
				SelectedPerson = _people.GetItem<PersonModel> ((nuint)Table.SelectedRow);

				// Confirm delete
				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Critical,
					InformativeText = string.Format("Are you sure you want to delete person `{0}` from the table?",SelectedPerson.Name),
					MessageText = "Delete Person",
				};
				alert.AddButton ("Ok");
				alert.AddButton ("Cancel");
				alert.BeginSheetForResponse (window, (result) => {
					// Delete?
					if (result == 1000) {
						RemovePerson(Table.SelectedRow);
					}
				});
			}
		}
		public PersonEditorSheetController (PersonModel person, bool isNew)
		{
			// Load the .xib file for the sheet
			NSBundle.LoadNib ("PersonEditSheet", this);

			CancelButton.Hidden = !isNew;

			// Save person
			Person = person;
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Set a default person
			var Craig = new PersonModel ("Craig Dunn", "Documentation Manager");
			Craig.AddPerson (new PersonModel ("Amy Burns", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Joel Martinez", "Web & Infrastructure"));
			Craig.AddPerson (new PersonModel ("Kevin Mullins", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Mark McLemore", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Tom Opgenorth", "Technical Writer"));
			Person = Craig;
		}
		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();

			// Build list of employees
			var Craig = new PersonModel ("Craig Dunn", "Documentation Manager");
			Craig.AddPerson (new PersonModel ("Amy Burns", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Joel Martinez", "Web & Infrastructure"));
			Craig.AddPerson (new PersonModel ("Kevin Mullins", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Mark McLemore", "Technical Writer"));
			Craig.AddPerson (new PersonModel ("Tom Opgenorth", "Technical Writer"));
			AddPerson (Craig);

			var Larry = new PersonModel ("Larry O'Brien", "API Documentation Manager");
			Larry.AddPerson (new PersonModel ("Mike Norman", "API Documentor"));
			AddPerson (Larry);

		}
		public void InsertPerson(PersonModel person, nint index) {
			WillChangeValue ("personModelArray");
			_people.Insert (person, index);
			DidChangeValue ("personModelArray");
		}
		public void AddPerson(PersonModel person) {
			WillChangeValue ("personModelArray");
			_people.Add (person);
			DidChangeValue ("personModelArray");
		}
		internal void RaisePersonModified(PersonModel person) {
			if (this.PersonModified!=null) this.PersonModified(person);
		}
示例#8
0
 public void InsertPerson(PersonModel person, nint index)
 {
     WillChangeValue("personModelArray");
     _people.Insert(person, index);
     DidChangeValue("personModelArray");
 }
示例#9
0
 public void AddPerson(PersonModel person)
 {
     WillChangeValue("personModelArray");
     _people.Add(person);
     DidChangeValue("personModelArray");
 }
示例#10
0
		public void EditPerson(NSWindow window) {
			if (Table.SelectedRow == -1) {
				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Informational,
					InformativeText = "Please select the person to edit from the list of people.",
					MessageText = "Edit Person",
				};
				alert.BeginSheet (window);
			} else {
				// Grab person
				SelectedPerson = _people.GetItem<PersonModel> ((nuint)Table.SelectedRow);

				// Display editor
				PerformSegue("EditorSegue", this);
			}
		}
		public void EditPerson(NSWindow window) {
			if (SelectedPerson == null) {
				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Informational,
					InformativeText = "Please select the person to edit from the collection of people.",
					MessageText = "Edit Person",
				};
				alert.BeginSheet (window);
			} else {
				// Grab person
				SelectedPerson = _people.GetItem<PersonModel> ((nuint)View.SelectionIndex);

				var sheet = new PersonEditorSheetController(SelectedPerson, false);

				// Display sheet
				sheet.ShowSheet(window);
			}
		}
		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();

			// Build list of employees
			AddPerson (new PersonModel ("Craig Dunn", "Documentation Manager", true));
			AddPerson (new PersonModel ("Amy Burns", "Technical Writer"));
			AddPerson (new PersonModel ("Joel Martinez", "Web & Infrastructure"));
			AddPerson (new PersonModel ("Kevin Mullins", "Technical Writer"));
			AddPerson (new PersonModel ("Mark McLemore", "Technical Writer"));
			AddPerson (new PersonModel ("Tom Opgenorth", "Technical Writer"));
			AddPerson (new PersonModel ("Larry O'Brien", "API Docs Manager", true));
			AddPerson (new PersonModel ("Mike Norman", "API Documentor"));

			// Wire-up events
			View.PersonSelected += (index) => {
				try {
					SelectedPerson = _people.GetItem<PersonModel>((nuint)index);
				} catch {
					SelectedPerson = null;
				}
			};

		}