public App()
        {
            // This loads all the existing .note files.
            NoteFolder = new NoteFolder();

            // Make call to method in MultiPageRestorableApp.
            Startup(typeof(NoteTakerHomePage));
        }
        public App()
        {
            // This loads all the existing .note files.
            NoteFolder = new NoteFolder();

            // Make call to method in MultiPageRestorableApp.
            Startup(typeof(NoteTakerHomePage));
        }
示例#3
0
文件: App.cs 项目: areestlc/xamarin
        public App()
        {
            Xamarin.FormsBook.Platform.Toolkit.Init();

            // This loads all the existing .note files.
            NoteFolder = new NoteFolder();

            // Make call to method in MultiPageRestorableApp.
            Startup(typeof(NoteTakerHomePage));
        }
        async protected override void OnDisappearing()
        {
            base.OnDisappearing();

            // Special code for iOS:
            //      Do not save note when program is terminating.
            if (isInSleepState)
            {
                return;
            }

            // Only save the note if there's some text somewhere.
            if (!String.IsNullOrWhiteSpace(Note.Title) ||
                !String.IsNullOrWhiteSpace(Note.Text))
            {
                // Save the note to a file.
                await Note.SaveAsync();

                // Add it to the collection if it's a new note.
                NoteFolder noteFolder = ((App)App.Current).NoteFolder;

                // IndexOf method finds match based on Filename property
                //      based on implementation of IEquatable in Note.
                int index = noteFolder.Notes.IndexOf(note);
                if (index == -1)
                {
                    // No match -- add it.
                    noteFolder.Notes.Add(note);
                }
                else
                {
                    // Match -- replace it.
                    noteFolder.Notes[index] = note;
                }
            }
        }