public void EditPerson(NSWindow window) { if (View.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)View.SelectedRow); var sheet = new PersonEditorSheetController(SelectedPerson, false); // Display sheet sheet.ShowSheet(window); } }
public override void AwakeFromNib () { base.AwakeFromNib (); // Get access to database DatabaseConnection = GetDatabaseConnection (); // Wire-up controls AddButton.Active = false; AddButton.Activated += (sender, e) => { // Take action based on type switch(ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; var person = new PersonModel("Unknown","Unknown"); var sheet = new PersonEditorSheetController(person, true); // Wire-up sheet.PersonModified += (p) => { // Save person to database p.Create(DatabaseConnection); controller.AddPerson(p); }; // Display sheet sheet.ShowSheet(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; var collectionPerson = new PersonModel("Unknown","Unknown"); var collectionSheet = new PersonEditorSheetController(collectionPerson, true); // Wire-up collectionSheet.PersonModified += (p) => { // Save person to database p.Create(DatabaseConnection); collection.AddPerson(p); }; // Display sheet collectionSheet.ShowSheet(this); break; } }; EditButton.Active = false; EditButton.Activated += (sender, e) => { // Take action based on type switch(ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.EditPerson(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.EditPerson(this); break; } }; DeleteButton.Active = false; DeleteButton.Activated += (sender, e) => { // Take action based on type switch(ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.DeletePerson(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.DeletePerson(this); break; } }; Search.Enabled = false; Search.EditingEnded += (sender, e) => { // Take action based on type switch(ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.FindPerson(Search.StringValue); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.FindPerson(Search.StringValue); break; } }; // Populate Source List SourceList.Initialize (); var TableViews = new SourceListItem ("Direct SQLite"); TableViews.AddItem ("Simple Binding", "shoebox.png", () => { DisplaySubview(new SubviewSimpleBindingController(DatabaseConnection), SubviewType.SimpleBinding); }); TableViews.AddItem ("Table Binding", "shoebox.png", () => { DisplaySubview(new SubviewTableBindingController(DatabaseConnection), SubviewType.TableBinding); }); TableViews.AddItem ("Outline Binding", "shoebox.png", () => { DisplaySubview(new SubviewOutlineBindingController(DatabaseConnection), SubviewType.OutlineBinging); }); TableViews.AddItem ("Collection View", "shoebox.png", () => { DisplaySubview(new SubviewCollectionViewController(DatabaseConnection), SubviewType.CollectionView); }); SourceList.AddItem (TableViews); var ORMViews = new SourceListItem ("SQLite.Net ORM"); ORMViews.AddItem ("Table Binding", "shoebox.png", () => { DisplaySubview(new SubviewTableORMController(), SubviewType.TableORM); }); SourceList.AddItem (ORMViews); // Display Source List SourceList.ReloadData(); SourceList.ExpandItem (null, true); }
public override void AwakeFromNib() { base.AwakeFromNib(); // Get access to database DatabaseConnection = GetDatabaseConnection(); // Wire-up controls AddButton.Active = false; AddButton.Activated += (sender, e) => { // Take action based on type switch (ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; var person = new PersonModel("Unknown", "Unknown"); var sheet = new PersonEditorSheetController(person, true); // Wire-up sheet.PersonModified += (p) => { // Save person to database p.Create(DatabaseConnection); controller.AddPerson(p); }; // Display sheet sheet.ShowSheet(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; var collectionPerson = new PersonModel("Unknown", "Unknown"); var collectionSheet = new PersonEditorSheetController(collectionPerson, true); // Wire-up collectionSheet.PersonModified += (p) => { // Save person to database p.Create(DatabaseConnection); collection.AddPerson(p); }; // Display sheet collectionSheet.ShowSheet(this); break; } }; EditButton.Active = false; EditButton.Activated += (sender, e) => { // Take action based on type switch (ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.EditPerson(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.EditPerson(this); break; } }; DeleteButton.Active = false; DeleteButton.Activated += (sender, e) => { // Take action based on type switch (ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.DeletePerson(this); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.DeletePerson(this); break; } }; Search.Enabled = false; Search.EditingEnded += (sender, e) => { // Take action based on type switch (ViewType) { case SubviewType.TableBinding: var controller = SubviewController as SubviewTableBindingController; controller.FindPerson(Search.StringValue); break; case SubviewType.CollectionView: var collection = SubviewController as SubviewCollectionViewController; collection.FindPerson(Search.StringValue); break; } }; // Populate Source List SourceList.Initialize(); var TableViews = new SourceListItem("Direct SQLite"); TableViews.AddItem("Simple Binding", "shoebox.png", () => { DisplaySubview(new SubviewSimpleBindingController(DatabaseConnection), SubviewType.SimpleBinding); }); TableViews.AddItem("Table Binding", "shoebox.png", () => { DisplaySubview(new SubviewTableBindingController(DatabaseConnection), SubviewType.TableBinding); }); TableViews.AddItem("Outline Binding", "shoebox.png", () => { DisplaySubview(new SubviewOutlineBindingController(DatabaseConnection), SubviewType.OutlineBinging); }); TableViews.AddItem("Collection View", "shoebox.png", () => { DisplaySubview(new SubviewCollectionViewController(DatabaseConnection), SubviewType.CollectionView); }); SourceList.AddItem(TableViews); var ORMViews = new SourceListItem("SQLite.Net ORM"); ORMViews.AddItem("Table Binding", "shoebox.png", () => { DisplaySubview(new SubviewTableORMController(), SubviewType.TableORM); }); SourceList.AddItem(ORMViews); // Display Source List SourceList.ReloadData(); SourceList.ExpandItem(null, true); }
public void EditPerson(NSWindow window) { if (View.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)View.SelectedRow); var sheet = new PersonEditorSheetController(SelectedPerson, false); // Display sheet sheet.ShowSheet(window); } }