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() { 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 TaskManager(TaskRepository repository) { _repository = repository; var items = repository.GetTasks(); _todoItems = new ObservableCollection<TodoItem>(items); }
//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); }