示例#1
0
        /// <summary>
        /// Create new Note, if there is no notebooks available the show error massage.
        /// Create new Note from GroupedItemsPage (no selected notebook) then create note under the first Notebook.
        /// Create new Note from GroupDetailPage then create note under the notebook presented in GroupDetailPage.
        /// Create new Note from ItemDetailPage then create note under the current Note Notebook.
        /// </summary>
        /// <param name="item">New Note To Create</param>
        public void CreateNew(NoteDataCommon item)
        {
            if (NotesDataSource.GetGroups().Count == 0)
            {
                Helpers.ShowMessageAsync("You first need to create a notebook.", "Create Notebook");
                return;
            }

            if (this.GetType() == typeof(GroupDetailPage))
            {
                item.NoteBook = this.DefaultViewModel["Group"] as NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }
            else if (this.GetType() == typeof(ItemDetailPage))
            {
                item.NoteBook = (this.DefaultViewModel["Item"] as NoteDataCommon).NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }
            else
            {
                item.NoteBook = NotesDataSource.GetGroups()[0] as NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }

            this.Frame.Navigate(typeof(ItemDetailPage), item.UniqueId);
        }
示例#2
0
        async private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            shareOperation.ReportStarted();

            var notebook = comboNotebooks.SelectedItem as NoteBook;
            var noteType = (NoteTypes)comboType.SelectedItem;

            switch (noteType)
            {
            case NoteTypes.ToDo:
                var todo = new ToDoDataItem(txtTitle.Text.HttpEncode(), notebook);
                todo.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(todo);

                NotesDataSource.Add(todo, notebook.UniqueId);
                break;

            case NoteTypes.Food:
                var food = new FoodDataItem(txtTitle.Text.HttpEncode(), notebook);
                food.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(food);

                NotesDataSource.Add(food, notebook.UniqueId);
                break;

            default:
                var note = new NoteDataItem(txtTitle.Text.HttpEncode(), notebook);
                note.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(note);

                NotesDataSource.Add(note, notebook.UniqueId);
                break;
            }

            DataManager.Save();

            this.shareOperation.ReportCompleted();
        }