コード例 #1
0
        private void EditEntry(ViewModel_DiaryEntry entry)
        {
            //Edits an entry
            Console.WriteLine(entry);
            //Triggered when the user clicks the EditEntry or NewEntry button
            if (entry.CurrentState == ViewModel_DiaryPage.PageState.COMPLETED)
            {
                //If it was a new frame, change the first submit field
                Console.WriteLine("Setting First Submit");
                (entry.Entry).FirstSubmit = DateTime.Now;
                (entry.Entry).LastEdited  = DateTime.Now;
            }
            //Finally, change the current entry to be EDIT state
            //entry.CurrentState = ViewModel_DiaryEntry.DiaryEntryState.EDITING;
            ViewModel_DiaryEntry updatedEntry = new ViewModel_DiaryEntry()
            {
                Entry = entry.Entry, CurrentState = ViewModel_DiaryPage.PageState.EDITING
            };
            int i = DiaryEntries.IndexOf(entry);

            DiaryEntries[i] = updatedEntry;
        }
コード例 #2
0
        //Saves the Diary Entry
        public void SaveEntry(ViewModel_DiaryEntry entry)
        {
            //Saves an entry
            Console.WriteLine("Saving Entry " + entry.CurrentState);

            entry.Entry.LastEdited        = DateTime.Now;
            AppPreferences.LastDiaryEntry = entry.Entry.LastEdited;

            ViewModel_DiaryEntry updatedEntry = new ViewModel_DiaryEntry()
            {
                Entry = entry.Entry
            };

            updatedEntry.CurrentState = ViewModel_DiaryPage.PageState.COMPLETED;
            int i = DiaryEntries.IndexOf(entry);

            DiaryEntries[i] = updatedEntry;

            List <ViewModel_DiaryPage> entries = new List <ViewModel_DiaryPage>(DiaryEntries); //Adds current diary list from viewmodel

            UserDiaryFileController.Save(entries);
        }