protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            var sqliteFilename = "TaskDB.db3";
            string libraryPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var path = Path.Combine(libraryPath, sqliteFilename);
            var conn = new Connection(path);

            var taskRepository = new TaskRepository(conn, "");
            taskManager = new TaskManager(taskRepository);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.addButton);

            button.Click += delegate {
                var todoText = FindViewById<EditText> (Resource.Id.todoItemText);
                taskManager.NewTodoItem.Text = todoText.Text;
                taskManager.AddTodoItem();
                todoText.Text = "";
                StartService(new Intent(CustomActions.TODO_SET_GEOFENCE));

            };

            var taskListView = FindViewById<ListView> (Resource.Id.listTasks);
            var taskListAdapter = new TaskListAdapter (this, taskManager);
            taskListView.Adapter = taskListAdapter;

            //Intent intent = new Intent (this, typeof(GeofencingHelper));
            StartService(new Intent(CustomActions.TODO_START_LOCATION_MONITORING));
        }
        public override void ViewDidLoad()
        {
            taskManager = new TaskManager();
            base.ViewDidLoad ();

            addButton.TouchUpInside += (object sender, EventArgs e) => {
                AddNewTask ();
            };

            newTaskText.EditingDidEnd += (object sender, EventArgs e) => {
                AddNewTask ();
            };
            newTaskText.Delegate = new CatchEnterDelegate ();

            tableTasks.Source = new TasksTableViewSource (tableTasks, taskManager.TodoItems);
        }
        public TasksTableViewSource(UITableView tableView, TaskManager taskManager)
        {
            _taskManager = taskManager;
            _taskManager.TodoItems.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
            //				if (e.OldItems != null)
            //				{
            //					NSIndexPath[] oldPaths = e.OldItems.OfType<TodoItem>().Select(oi => NSIndexPath.FromRowSection(tasks.IndexOf(oi), 0)).ToArray();
            //					tableView.DeleteRows(oldPaths, UITableViewRowAnimation.Top);
            //				}

                if (e.NewItems != null)
                {
                    var newPaths = e.NewItems.OfType<TodoItem>().Select(ni => NSIndexPath.FromRowSection(_taskManager.TodoItems.Count - 1, 0)).ToArray();
                    tableView.InsertRows(newPaths, UITableViewRowAnimation.Top);
                }
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            taskManager = new TaskManager();

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.addButton);

            button.Click += delegate {
                var todoText = FindViewById<EditText> (Resource.Id.todoItemText);
                taskManager.NewTodoItem.Text = todoText.Text;
                taskManager.AddTodoItem();
                todoText.Text = "";
            };

            var taskListView = FindViewById<ListView> (Resource.Id.listTasks);
            var taskListAdapter = new TaskListAdapter (this, taskManager.TodoItems);
            taskListView.Adapter = taskListAdapter;
        }
        public override void ViewDidLoad()
        {
            var sqliteFilename = "TaskDB.db3";
            // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
            // (they don't want non-user-generated data in Documents)
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            string libraryPath = Path.Combine(documentsPath, "../Library/"); // Library folder
            var path = Path.Combine(libraryPath, sqliteFilename);
            var conn = new Connection(path);
            var taskRepository = new TaskRepository(conn, "");
            taskManager = new TaskManager(taskRepository);
            base.ViewDidLoad ();

            addButton.TouchUpInside += (object sender, EventArgs e) => {
                AddNewTask ();
            };

            newTaskText.EditingDidEnd += (object sender, EventArgs e) => {
                AddNewTask ();
            };
            newTaskText.Delegate = new CatchEnterDelegate ();

            tableTasks.Source = new TasksTableViewSource (tableTasks, taskManager);
        }
 public TodoListViewModel(TodoItem[] items)
 {
     taskManager = new TaskManager(items);
 }
 public TodoListViewModel()
 {
     taskManager = new TaskManager();
 }
 //TODO: 4.0 - Add 2 new ctors and instantiate taskManager in each.
 //  Don't create taskManager inline.
 //  First new ctor is a default ctor and instantiates taskManager
 //  Second new ctor accepts an array of TodoItems and instantiates taskManager passing its ctor the items
 public TodoListViewModel()
 {
     var taskRepository = new TaskRepository(new Connection("TaskDB.db3"), "");
     taskManager = new TaskManager(taskRepository);
 }