-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewController.cs
More file actions
executable file
·107 lines (91 loc) · 2.66 KB
/
MainViewController.cs
File metadata and controls
executable file
·107 lines (91 loc) · 2.66 KB
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
97
98
99
100
101
102
103
104
105
106
107
// This file has been autogenerated from a class added in the UI designer.
using System;
using Foundation;
using AppKit;
namespace MacDatabinding
{
public partial class MainViewController : NSViewController
{
#region Private Variables
private SubviewType _viewType = SubviewType.None;
#endregion
#region Computed Properties
public MainWindowController WindowController { get; set;}
public NSView Content {
get { return ContentView; }
}
public NSViewController ContentController { get; set; }
public SubviewType ViewType {
get { return _viewType; }
set {
_viewType = value;
WindowController?.UpdateUI ();
}
}
#endregion
#region Constructors
public MainViewController (IntPtr handle) : base (handle)
{
}
#endregion
#region Override Methods
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Populate Source List
SourceList.Initialize ();
var TableViews = new SourceListItem ("Data Binding Type");
TableViews.AddItem ("Simple Binding", "shoebox.png", () => {
ViewType = SubviewType.SimpleBinding;
PerformSegue("SimpleSegue", this);
});
TableViews.AddItem ("Table Binding", "shoebox.png", () => {
ViewType = SubviewType.TableBinding;
PerformSegue("TableSegue", this);
});
TableViews.AddItem ("Outline Binding", "shoebox.png", () => {
ViewType = SubviewType.OutlineBinging;
PerformSegue("OutlineSegue", this);
});
TableViews.AddItem ("Collection View", "shoebox.png", () => {
ViewType = SubviewType.CollectionView;
PerformSegue("CollectionSegue", this);
});
SourceList.AddItem (TableViews);
// Display Source List
SourceList.ReloadData();
SourceList.ExpandItem (null, true);
}
public override void PrepareForSegue (NSStoryboardSegue segue, NSObject sender)
{
base.PrepareForSegue (segue, sender);
// Take action based on type
switch (segue.Identifier) {
case "AddSegue":
var editor = segue.DestinationController as PersonEditorViewController;
editor.Presentor = this;
editor.Person = new PersonModel();
// Wire-up
editor.PersonModified += (person) => {
// Take action based on type
switch(ViewType) {
case SubviewType.TableBinding:
var controller = ContentController as TableViewController;
controller.AddPerson(person);
break;
case SubviewType.CollectionView:
// var collection = SubviewController as SubviewCollectionViewController;
// collection.EditPerson(this);
break;
}
};
break;
default:
// Save link to child controller
ContentController = segue.DestinationController as NSViewController;
break;
}
}
#endregion
}
}