Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using MyDailyTaskManger.Models;
using Newtonsoft.Json;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MyDailyTaskManger
{
public partial class ListTasksPage : ContentPage
{
List<Task> listOfTasks;
public ObservableCollection<Task> Tasks { get; set; }
public ListTasksPage()
{
this.Tasks = new ObservableCollection<Task>();
this.BindingContext = this.Tasks;
InitializeComponent();
this.listOfTasks = new List<Task>();
LoadAllFilesAndDeserialize();
}
private void LoadAllFilesAndDeserialize()
{
var files = Directory.EnumerateFiles(App.FolderPath, "*.task.txt");
if (files.Count() > 0)
{
foreach (var filename in files)
{
String name = filename;
String serializedText = File.ReadAllText(filename);
Task deSerializedTask = JsonConvert.DeserializeObject<Task>(serializedText);
if (null == deSerializedTask.fileName)
{
deSerializedTask.fileName = filename;
}
listOfTasks.Add(deSerializedTask);
this.Tasks.Add(deSerializedTask);
}
this.listView.ItemsSource = this.listOfTasks.OrderBy(d => d.dateCreated).ToList();
}
}
public void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
// int pos = e.SelectedItemIndex;
Task taskSelected = (Task) e.SelectedItem;
ViewTaskPage viewTaskPage = new ViewTaskPage(taskSelected);
Navigation.PushAsync(viewTaskPage);
}
}
}