コード例 #1
0
        public async void DeleteNotebook(Notebook notebook)
        {
            await DatabaseHelper.Delete(notebook);

            Notebooks.Remove(notebook);
            // ReadNotebooks();
        }
コード例 #2
0
        public async void ReadNotebooks()
        {
            //{
            //    using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            //    {
            //        conn.CreateTable<NotebookModel>(); //Make sure the table exists...
            //        var notebooks = conn.Table<NotebookModel>().ToList();

            //        Notebooks.Clear();
            //        foreach (var notebook in notebooks)
            //        {
            //            Notebooks.Add(notebook);
            //        }
            //    }


            try
            {
                //Ver que ahora ya sólo leemos los notebooks del usuario que se ha logado...
                var notebooks = await App.MobileServiceClient.GetTable <NotebookModel>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }

                //selectedNotebook= Notebooks.FirstOrDefault(); //weird behavbour
            }
            catch (Exception ex)
            {
            }
        }
コード例 #3
0
ファイル: NotesVM.cs プロジェクト: Gust2007/NotesApp
        public async void ReadNotebooks()
        {
#if USEAZURE
            try
            {
                Notebooks.Clear();

                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
            }
#else
            using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile)) {
                var notebooks = conn.Table <Notebook>().ToList();

                Notebooks.Clear();

                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
#endif
        }
コード例 #4
0
 private void OnApplicationUnlocked(ApplicationUnlocked obj)
 {
     if (SelectedMenuItem == null)
     {
         SelectedItemChangedCommand.Execute(Notebooks.FirstOrDefault());
     }
 }
コード例 #5
0
ファイル: ShellViewModel.cs プロジェクト: BartiDev/NotesApp
        public void ConfirmNewNotebookName(string newNotebookName)
        {
            NewNotebookClicked = false;

            NotebookModel notebook = Notebooks.ToList <NotebookModel>().Find(n => n.Name == newNotebookName);

            if (notebook == null)
            {
                try
                {
                    DBDataAccessInsert.InsertNotebook(new NotebookModel()
                    {
                        UserId = User.Id,
                        Name   = newNotebookName
                    });

                    Notebooks.Clear();
                    Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id));
                }
                catch (SQLiteException)
                {
                    MessageBox.Show("Invalid Name");
                }
            }
            else
            {
                MessageBox.Show("Notebook with this name already exists");
            }
        }
コード例 #6
0
        public void AddNotebookFromBind(AddNotebookBm bind)
        {
            Notebooks notebook = Mapper.Map <AddNotebookBm, Notebooks>(bind);

            Context.Items.Add(notebook);
            Context.SaveChanges();
        }
コード例 #7
0
        private void CreateNotebook(object arg)
        {
            MainWindowInstance.ShowInputAsync("Add notebook", "Name:").ContinueWith(delegate(Task <string> task)
            {
                string newName = task.Result;
                if (string.IsNullOrEmpty(newName))
                {
                    return;
                }

                Notebook nb = new Notebook
                {
                    Name    = newName,
                    Created = DateTime.Now
                };
                nb.Save();

                var newNotebook = ViewModelLocator.Instance.GetNotebookViewModel(nb);

                List <NotebookViewModel> temp = new List <NotebookViewModel>();
                temp.AddRange(Notebooks.ToArray());
                temp.Add(newNotebook);
                temp.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal));

                Notebooks.Clear();
                temp.ForEach(Notebooks.Add);

                SelectedNotebook            = newNotebook;
                SelectedNotebook.IsSelected = true;
            });
        }
コード例 #8
0
        public async void ReadNoteBooks()
        {
            #region Commented Code
            //using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile))
            //{
            //    conn.CreateTable<NoteBook>();

            //    //int userid = int.Parse(App.UserId);
            //    var notebooks = conn.Table<NoteBook>().ToList();
            //    Notebooks.Clear();
            //    if (notebooks != null)
            //    {
            //        foreach (var notebook in notebooks)
            //        {
            //            Notebooks.Add(notebook);
            //        }
            //    }

            //}
            #endregion

            var notebooks = await App.mobileServiceClient.GetTable <NoteBook>().OrderBy(n => n.Name).ToListAsync();

            Notebooks.Clear();
            if (notebooks != null)
            {
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
        }
コード例 #9
0
        public async void ReadNotebooks()
        {
            //using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.GetFileLocation()))
            //{
            //	//int userId;
            //	//bool isLogged = int.TryParse(App.UserId, out userId);
            //	var notebooks = conn.Table<Notebook>()/*.Where(n => isLogged && n.UserId == userId)*/.ToList();

            //	Notebooks.Clear();
            //	foreach (var notebook in notebooks)
            //	{
            //		Notebooks.Add(notebook);
            //	}
            //}

            try
            {
                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #10
0
        public async void ReadNotebooks()
        {
            ////using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            ////{
            ////    var notebooks = conn.Table<Notebook>().ToList();

            ////    Notebooks.Clear();
            ////    foreach(var notebook in notebooks)
            ////    {
            ////        Notebooks.Add(notebook);
            ////    }
            ////}

            try
            {
                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #11
0
ファイル: NotesVM.cs プロジェクト: JonathanMiz/NotesApp
        private async void NewNotebook()
        {
            await App.MobileServiceClient.GetTable <Notebook>().InsertAsync(CreateNewNotebook());

            Notebooks.Clear();

            ReadNotebooks();
        }
コード例 #12
0
 public void ReadNotebooks()
 {
     using (SQLiteConnection connection = new SQLiteConnection(DataBaseHelper.dbFile))
     {
         var notebooks = connection.Table <Notebook>().ToList();
         Notebooks.Clear();
         notebooks.ForEach(x => Notebooks.Add(x));
     }
 }
コード例 #13
0
        public DetailsNotebookVm GetDetailNotebookVM(int id)
        {
            Notebooks notebook = Context.Items.OfType <Notebooks>().FirstOrDefault(book => book.Id == id);

            DetailsNotebookVm vm = Mapper.Map <Notebooks, DetailsNotebookVm>(notebook);


            return(vm);
        }
コード例 #14
0
 public void DeleteNotebook(NoteBook noteBook)
 {
     if (noteBook != null)
     {
         DatabaseHelper.Delete(noteBook);
         Notebooks.Remove(noteBook);
         ReadNoteBooks();
     }
 }
コード例 #15
0
        public async void ReadNotebooks()
        {
            //using (var connection = new SQLite.SQLiteConnection(DatabaseHelper.DatabaseFile))
            //{
            //    try
            //    {
            //        string userId = App.UserId;
            //        if (!string.IsNullOrEmpty(userId))
            //        {
            //            var notebooks = connection.Table<Notebook>().Where(x => x.UserId == userId).ToList();

            //            Notebooks.Clear();
            //            foreach (var notebook in notebooks)
            //            {
            //                Notebooks.Add(notebook);
            //            }
            //        }
            //        else
            //        {
            //            Notebooks.Clear();
            //        }
            //    }
            //    catch (SQLite.SQLiteException)
            //    {
            //        // TODO logging or information should get shown here?

            //        Notebooks.Clear();
            //    }
            //}

            try
            {
                string userId = App.UserId;
                if (!string.IsNullOrEmpty(userId))
                {
                    var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == userId).ToListAsync();

                    Notebooks.Clear();
                    foreach (var notebook in notebooks)
                    {
                        Notebooks.Add(notebook);
                    }

                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Notebooks)));
                }
                else
                {
                    Notebooks.Clear();
                }
            }
            catch (Exception e)
            {
            }

            // Refreshing now
            ReadNotes();
        }
コード例 #16
0
ファイル: NotesVM.cs プロジェクト: Creapermann/C-sharp
        public async void getNotebooks()
        {
            var notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList();

            Notebooks.Clear();
            foreach (var o in notebooks)
            {
                Notebooks.Add(o);
            }
        }
コード例 #17
0
        public void ReadNotebooks()
        {
            var notebooks = DatabaseHelper.Table <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
コード例 #18
0
ファイル: NotesVM.cs プロジェクト: nestoram29/EvernoteClone
        private void GetNotebooks()
        {
            var notebooks = DatabaseHelper.Read <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
コード例 #19
0
        public async Task GetNotebooks()
        {
            IEnumerable <Notebook> notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserID).ToList();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
コード例 #20
0
ファイル: NotesVM.cs プロジェクト: Alword/EvernoteClone
        public void CreateNewNotebook()
        {
            Notebook notebook = new Notebook()
            {
                Name = "New notebook",
                Id   = int.Parse(App.userID)
            };

            DatabaseHelper.Insert(notebook);
            Notebooks.Add(notebook);
        }
コード例 #21
0
        private void GetNotebooks()
        {
            var notebooks = DatabaseHelper.Read <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
                //Observable collection a ekleniyor
            }
        }
コード例 #22
0
ファイル: ShellViewModel.cs プロジェクト: BartiDev/NotesApp
 public void Handle(string message)
 {
     if (message == "Sign out")
     {
         User       = null;
         IsLoggedIn = false;
         Notes.Clear();
         SelectedNotebook = null;
         Notebooks.Clear();
     }
 }
 public NotebookViewModel()
 {
     Notebook.Default.Notes.Add(Note.MyScriptNoteDefault);
     Notebooks.Add(Notebook.Default);
     Notebook.MyNotebookEn.Notes.Add(Note.ChinaNoteEn);
     Notebook.MyNotebookEn.Notes.Add(Note.FranceNoteEn);
     Notebooks.Add(Notebook.MyNotebookEn);
     Notebook.MyNotebookZh.Notes.Add(Note.ChinaNoteZh);
     Notebook.MyNotebookZh.Notes.Add(Note.FranceNoteZh);
     Notebooks.Add(Notebook.MyNotebookZh);
 }
コード例 #24
0
        public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            if (Notebooks.Count == 0)
            {
                var notebooks = await NotebooksService.GetNotebooksAsync();

                Notebooks.AddRange(notebooks);
            }

            await Task.CompletedTask;
        }
コード例 #25
0
 public void ReadNotebooks()
 {
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
     {
         var notebooks = conn.Table <Notebook>().ToList();
         Notebooks.Clear();
         foreach (var notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
     }
 }
コード例 #26
0
 public async void GetNotebooks()
 {
     try
     {
         var notebooks = (await Database.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList();
         Notebooks.Clear();
         foreach (var notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
     }
     catch (ArgumentNullException) { }
 }
コード例 #27
0
ファイル: NotesVM.cs プロジェクト: geestaq/WpfEverNoteApp
        public void ReadNotebooks()
        {
            using (SQLite.SQLiteConnection cn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                var notebooks = cn.Table <Notebook>().ToList();
                //TODO: pobieranie notatnikow dla zalogowanego usera

                Notebooks.Clear();
                foreach (var item in notebooks)
                {
                    Notebooks.Add(item);
                }
            }
        }
コード例 #28
0
ファイル: NotesVM.cs プロジェクト: monemonesi/NotesApp
 public void ReadNotebooks()
 {
     using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
     {
         //TODO: handle this exception (When a table of notebook does not exists)
         var notebooks = connection.Table <Notebook>().ToList();
         Notebooks.Clear();
         foreach (Notebook notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
         SelectedNotebook = Notebooks.FirstOrDefault();
     }
 }
コード例 #29
0
ファイル: Search.cs プロジェクト: MichaelAquilina/tomboy
		/// <summary>
		/// Search the notes! A match number of
		/// <see cref="int.MaxValue"/> indicates that the note
		/// title contains the search term.
		/// </summary>
		/// <param name="query">
		/// A <see cref="System.String"/>
		/// </param>
		/// <param name="case_sensitive">
		/// A <see cref="System.Boolean"/>
		/// </param>
		/// <param name="selected_notebook">
		/// A <see cref="Notebooks.Notebook"/>.  If this is not
		/// null, only the notes of the specified notebook will
		/// be searched.
		/// </param>
		/// <returns>
		/// A <see cref="IDictionary`2"/> with the relevant Notes
		/// and a match number. If the search term is in the title,
		/// number will be <see cref="int.MaxValue"/>.
		/// </returns>
		public IDictionary<Note,int> SearchNotes (
				string query,
				bool case_sensitive,
				Notebooks.Notebook selected_notebook)
		{
			string [] words = Search.SplitWatchingQuotes (query);

			// Used for matching in the raw note XML
			string [] encoded_words = SplitWatchingQuotes (XmlEncoder.Encode (query));
			Dictionary<Note,int> temp_matches = new Dictionary<Note,int>();
			
			// Skip over notes that are template notes
			Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);

			foreach (Note note in manager.Notes) {
				// Skip template notes
				if (note.ContainsTag (template_tag))
					continue;
				
				// Skip notes that are not in the
				// selected notebook
				if (selected_notebook != null
						&& selected_notebook.ContainsNote (note) == false)
					continue;
				
				// First check the note's title for a match,
				// if there is no match check the note's raw
				// XML for at least one match, to avoid
				// deserializing Buffers unnecessarily.

				if (0 < FindMatchCountInNote (note.Title,
						                      words,
						                      case_sensitive))
					temp_matches.Add(note,int.MaxValue);
				else if (CheckNoteHasMatch (note,
					               encoded_words,
					               case_sensitive)){
					int match_count =
						FindMatchCountInNote (note.TextContent,
						                      words,
						                      case_sensitive);

					if (match_count > 0)
						// TODO: Improve note.GetHashCode()
						temp_matches.Add(note,match_count);
				}
			}
			return temp_matches;
		}
コード例 #30
0
        public void ReadNoteBooks()
        {
            using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                //var notebooks = connection.Table<NoteBook>().ToList();
                var notebooks = connection.Table <NoteBook>().Where(n => n.UserID == App.UserID).ToList();

                Notebooks.Clear();

                foreach (var noteBook in notebooks)
                {
                    Notebooks.Add(noteBook);
                }
            }
        }
コード例 #31
0
ファイル: NotesVM.cs プロジェクト: ghood97/EvernoteClone
        public void ReadNotebooks()
        {
            // get all Notebooks from the database
            using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                connection.CreateTable <Notebook>();
                var notebooks = connection.Table <Notebook>().ToList();

                Notebooks.Clear();
                foreach (Notebook nb in notebooks)
                {
                    Notebooks.Add(nb);
                }
            }
        }
コード例 #32
0
		private void OnNoteRemovedFromNotebook (Note note, Notebooks.Notebook notebook)
		{
			RestoreMatchesWindow ();
			UpdateResults ();
		}
コード例 #33
0
		private void OnNoteAddedToNotebook (Note note, Notebooks.Notebook notebook)
		{
			RestoreMatchesWindow ();
			UpdateResults ();
		}