public async Task PopulateNotes()
        {
            Notes.Clear();//delete notes
            StorageFolder directory = ApplicationData.Current.LocalFolder;

            //Create folder for notes, or get folder for notes.
            if (NotesFolder == null)
            {
                try
                {
                    NotesFolder = await directory.GetFolderAsync("Notes");

                    Search();
                }
                catch
                {
                    NotesFolder = await directory.CreateFolderAsync("Notes");
                }
            }
            IReadOnlyList <StorageFile> files = await NotesFolder.GetFilesAsync();

            int id = 0;

            foreach (StorageFile currentFile in files)
            {
                LocalNoteModel noteToAdd = new LocalNoteModel(id, currentFile.Name.Substring(0, currentFile.Name.LastIndexOf(".")), await FileIO.ReadTextAsync(currentFile));
                noteToAdd.File = currentFile;
                Notes.Add(noteToAdd);
                id++;
            }
        }
Exemple #2
0
        public async Task add(string inTitle)
        {
            LocalNoteModel createdNote = new LocalNoteModel(mpd.Notes.Count, inTitle);
            StorageFile    newNoteFile = await mpd.NotesFolder.CreateFileAsync(createdNote.Title + ".txt");

            createdNote.File = newNoteFile;
            mpd.Notes.Add(createdNote);
            mpd.SelectedNote = createdNote;
            mpd.Search();
        }