private void showNotes() { idList.Clear(); this.listViewNoiDung.Items.Clear(); List <Note> get = NoteControllers.getAllNotes(); for (int i = (get.Count() - 1); i >= 0; i--) { Note note = get[i]; if (note.Rac == false && note.PintoTop == true) { ListViewItem show = new ListViewItem(note.TieuDe.Trim()); show.SubItems.Add(new ListViewItem.ListViewSubItem(show, "o")); this.listViewNoiDung.Items.Add(show); idList.Add(note.SoThuTu); } } for (int i = (get.Count() - 1); i >= 0; i--) { Note note = get[i]; if (note.Rac == false && note.PintoTop == false) { ListViewItem show2 = new ListViewItem(note.TieuDe.Trim()); show2.SubItems.Add(new ListViewItem.ListViewSubItem(show2, "")); this.listViewNoiDung.Items.Add(show2); idList.Add(note.SoThuTu); } } }
//hien thi danh sach note trong All Notes theo note.Tittle tren listview lv //dong thoi cap nhat idtemp private void displayAllNotes() { idtemp.Clear(); this.lv.Items.Clear(); List <Note> notes = NoteControllers.getAllNotes(); //hien thi cac note duoc pin truoc for (int i = (notes.Count() - 1); i >= 0; i--) { Note note = notes[i]; if (note.isTrash == false && note.isPin == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "x")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } //cac note khong duoc pin for (int i = (notes.Count() - 1); i >= 0; i--) { Note note = notes[i]; if (note.isTrash == false && note.isPin == false) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } }
private void showRac() { idList.Clear(); this.listViewNoiDung.Items.Clear(); List <Note> get = NoteControllers.getAllNotes(); for (int i = (get.Count() - 1); i >= 0; i--) { Note source = get[i]; if (source.Rac == true) { ListViewItem show = new ListViewItem(source.TieuDe.Trim()); show.SubItems.Add(new ListViewItem.ListViewSubItem(show, "")); this.listViewNoiDung.Items.Add(show); idList.Add(source.SoThuTu); } } }
//hien thi danh sach note trong Trash theo note.Tittle tren listview lv //dong thoi cap nhat idtemp private void displayTrash() { idtemp.Clear(); this.lv.Items.Clear(); List <Note> notes = NoteControllers.getAllNotes(); for (int i = (notes.Count() - 1); i >= 0; i--) { Note note = notes[i]; if (note.isTrash == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } }
//tim kiem note, theo noi dung va theo tag private void txbFind_TextChanged(object sender, EventArgs e) { this.lv.SelectedIndices.Clear(); this.lbInfo.Text = ""; this.rtb.Clear(); this.rtb1.Clear(); if (this.txbFind.Text == "") { if (mode == true) { displayAllNotes(); } else { displayTrash(); } return; } this.lv.Items.Clear(); List <Note> notes = NoteControllers.getAllNotes(this.txbFind.Text); List <Tag> tags = TagControllers.getAllTags(this.txbFind.Text); //khi o che do All Notes if (mode == true) { idtemp.Clear(); //tim kiem theo noi dung ListViewItem eVent2 = new ListViewItem("### Search by content:"); this.lv.Items.Add(eVent2); idtemp.Add(-1); //note duoc pin hien truoc foreach (Note note in notes) { if (note.isTrash == false && note.isPin == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "x")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } //note khong duoc pin foreach (Note note in notes) { if (note.isTrash == false && note.isPin == false) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } //tim kiem theo tag ListViewItem eVent1 = new ListViewItem("### Search by tag:"); this.lv.Items.Add(eVent1); idtemp.Add(-1); foreach (Tag tag in tags) { //note duoc pin hien truoc foreach (Note note in tag.Note) { if (note.isTrash == false && note.isPin == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "x")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } //note khong duoc pin foreach (Note note in tag.Note) { if (note.isTrash == false && note.isPin == false) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } } } //khi o che do Trash if (mode == false) { idtemp.Clear(); //tim kiem theo noi dung ListViewItem eVent2 = new ListViewItem("### Search by content:"); this.lv.Items.Add(eVent2); idtemp.Add(-1); foreach (Note note in notes) { if (note.isTrash == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } //tim kiem theo tag ListViewItem eVent1 = new ListViewItem("### Search from tag:"); this.lv.Items.Add(eVent1); idtemp.Add(-1); foreach (Tag tag in tags) { foreach (Note note in tag.Note) { if (note.isTrash == true) { ListViewItem eVent = new ListViewItem(note.Tittle.Trim()); eVent.SubItems.Add(new ListViewItem.ListViewSubItem(eVent, "")); this.lv.Items.Add(eVent); idtemp.Add(note.Id); } } } } }