예제 #1
0
        /// <summary>
        /// The method for when the notespage appears
        /// Uses the code behind for the event forwarding
        /// </summary>
        public void OnAppearing()
        {
            SelectedNote = null;

            List <string> files = IOHelpers.EnumerateAllFiles();

            Notes?.Clear();

            foreach (var fileName in files)
            {
                string noteData = IOHelpers.ReadAllFileText(fileName);

                //Split the note into it's "parts"
                //The note will have three parts
                //Title
                //Text - can have multiple parts
                //Color
                string[] noteParts     = noteData.Split(':');
                int      notePartCount = noteParts.Count();

                //Performs some magic so that the title is the first element in the array
                //The text is from the second to the second to last element in the array (this preserves the ':')
                //The color is the final element
                string title = noteParts[0];
                string text  = string.Join(":", noteParts.Skip(1).Take(notePartCount - 2));
                string color = noteParts[notePartCount - 1];

                Note _tempNote = new Note
                {
                    Filename = fileName,
                    Title    = title,
                    Text     = text,
                    Date     = IOHelpers.GetNoteDate(fileName),
                    Color    = Color.FromHex(color)
                };

                Notes.Add(_tempNote);
            }

            //sorting the notes
            _currentSortingOption = AppSettings.OrderByOption;
            SortNotes();

            ShowCorrectView();
            ShowEditButton();
        }