This repository was 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 pathAppDelegate.cs
81 lines (62 loc) · 1.96 KB
/
AppDelegate.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
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
using MonoTouch.Dialog;
namespace MTDWalkthrough {
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate {
UIWindow _window;
UINavigationController _nav;
DialogViewController _rootVC;
RootElement _rootElement;
UIBarButtonItem _addButton;
int n = 0;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
_window = new UIWindow (UIScreen.MainScreen.Bounds);
_rootElement = new RootElement ("To Do List"){
new Section ()
};
_rootVC = new DialogViewController (_rootElement);
_nav = new UINavigationController (_rootVC);
_addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
_rootVC.NavigationItem.RightBarButtonItem = _addButton;
_addButton.Clicked += (sender, e) => {
++n;
var task = new Task { Name = "task " + n, DueDate = DateTime.Now };
var element = new EntryElement (task.Name, "Enter task description", task.Description);
var dateElement = new FutureDateElement ("Due Date", task.DueDate);
var taskElement = (Element) new RootElement (task.Name){
new Section () {
element
},
new Section () {
dateElement
},
new Section ("Demo Retrieving Element Value") {
new StringElement ("Output Task Description",
delegate { Console.WriteLine (element.Value); })
}
};
_rootElement [0].Add (taskElement);
};
_window.RootViewController = _nav;
_window.MakeKeyAndVisible ();
return true;
}
}
public class FutureDateElement : DateElement {
public FutureDateElement (string caption, DateTime date) : base (caption, date)
{
}
public override UIDatePicker CreatePicker ()
{
UIDatePicker futureDatePicker = base.CreatePicker ();
futureDatePicker.BackgroundColor = UIColor.White;
futureDatePicker.MinimumDate = (NSDate) DateTime.Today;
return futureDatePicker;
}
}
}