示例#1
0
        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);
            }
        }
示例#2
0
		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();

			// 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 sheet = new PersonEditorSheetController(new PersonModel("Unknown","Unknown"), true);

					// Wire-up
					sheet.PersonModified += (person) => {
						controller.AddPerson(person);
					};

					// Display sheet
					sheet.ShowSheet(this);
					break;
				case SubviewType.CollectionView:
					var collection = SubviewController as SubviewCollectionViewController;
					var collectionSheet = new PersonEditorSheetController(new PersonModel("Unknown","Unknown"), true);

					// Wire-up
					collectionSheet.PersonModified += (person) => {
						collection.AddPerson(person);
					};

					// 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 ("Data Binding Type");
			TableViews.AddItem ("Simple Binding", "shoebox.png", () => {
				DisplaySubview(new SubviewSimpleBindingController(), SubviewType.SimpleBinding);
			});
			TableViews.AddItem ("Table Binding", "shoebox.png", () => {
				DisplaySubview(new SubviewTableBindingController(), SubviewType.TableBinding);
			});
			TableViews.AddItem ("Outline Binding", "shoebox.png", () => {
				DisplaySubview(new SubviewOutlineBindingController(), SubviewType.OutlineBinging);
			});
			TableViews.AddItem ("Collection View", "shoebox.png", () => {
				DisplaySubview(new SubviewCollectionViewController(), SubviewType.CollectionView);
			});
			SourceList.AddItem (TableViews);

			// Display Source List
			SourceList.ReloadData();
			SourceList.ExpandItem (null, true);
		}
示例#3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            // 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 sheet      = new PersonEditorSheetController(new PersonModel("Unknown", "Unknown"), true);

                    // Wire-up
                    sheet.PersonModified += (person) => {
                        controller.AddPerson(person);
                    };

                    // Display sheet
                    sheet.ShowSheet(this);
                    break;

                case SubviewType.CollectionView:
                    var collection      = SubviewController as SubviewCollectionViewController;
                    var collectionSheet = new PersonEditorSheetController(new PersonModel("Unknown", "Unknown"), true);

                    // Wire-up
                    collectionSheet.PersonModified += (person) => {
                        collection.AddPerson(person);
                    };

                    // 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("Data Binding Type");

            TableViews.AddItem("Simple Binding", "shoebox.png", () => {
                DisplaySubview(new SubviewSimpleBindingController(), SubviewType.SimpleBinding);
            });
            TableViews.AddItem("Table Binding", "shoebox.png", () => {
                DisplaySubview(new SubviewTableBindingController(), SubviewType.TableBinding);
            });
            TableViews.AddItem("Outline Binding", "shoebox.png", () => {
                DisplaySubview(new SubviewOutlineBindingController(), SubviewType.OutlineBinging);
            });
            TableViews.AddItem("Collection View", "shoebox.png", () => {
                DisplaySubview(new SubviewCollectionViewController(), SubviewType.CollectionView);
            });
            SourceList.AddItem(TableViews);

            // Display Source List
            SourceList.ReloadData();
            SourceList.ExpandItem(null, true);
        }
		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);
			}
		}