private void pictureBoxTrash_Click(object sender, EventArgs e) { for (int i = 0; i < flpNote.Controls.Count; i++) { if (flpNote.Controls[i].BackColor == Color.LightGray) { Trash trash = new Trash(); Note note = NoteController.GetNote(i); trash.ID = TrashController.GetListTrash().Count; trash.description = note.description; trash.dateCreated = note.dateCreated; trash.tags = note.tags; trash.isPinned = note.isPinned; TrashController.AddTrash(trash); NoteController.RemoveNote(note); NoteController.RefreshNote(); flpNote.Controls.Remove(flpNote.Controls[i]); this.richTextBoxDescription.Text = ""; break; } } for (int i = this.flpTags.Controls.Count - 1; i >= 0; i--) { Control c = this.flpTags.Controls[i]; if (c.GetType() != typeof(TextBox)) { this.flpTags.Controls.RemoveAt(i); } } }
private void textBoxTrashNoteSearch_TextChanged(object sender, EventArgs e) { var searchText = this.textBoxTrashNoteSearch.Text.Split(' '); for (int i = 0; i < TrashController.GetListTrash().Count; i++) { bool isVisible = true; foreach (var text in searchText) { if (!text.Contains("tag:")) { if (!TrashController.GetListTrash()[i].description.Contains(text)) { isVisible = false; } } else { var t = text.Remove(0, ("tag:").Length); bool isContain = false; var tags = TrashController.GetListTrash()[i].tags.Split(' '); foreach (var tag in tags) { if (tag == t) { isContain = true; } } if (!isContain) { isVisible = false; } /*if (!NoteController.GetListNote()[i].tags.Contains(t)) * isVisible = false;*/ } } if (!isVisible) { this.flpTrash.Controls[i].Hide(); } else { this.flpTrash.Controls[i].Show(); } } }
private void frmTrash_Load(object sender, EventArgs e) { if (this.richTextBoxTrashDescription.ReadOnly == true) { this.richTextBoxTrashDescription.BackColor = Color.White; } foreach (Trash trash in TrashController.GetListTrash()) { Button btn = new Button(); btn.Dock = DockStyle.Top; btn.Width = 340; btn.Height = 50; btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderSize = 0; btn.TextAlign = ContentAlignment.MiddleLeft; btn.Font = new Font("Open Sans", 12, FontStyle.Regular); btn.Padding = new Padding(10, 0, 0, 0); btn.Text = trash.description; btn.Click += Btn_Click; CheckBox checkbox = new CheckBox(); if (trash.isPinned == true) { checkbox.Checked = true; } checkbox.Text = ""; checkbox.AutoSize = true; checkbox.Dock = DockStyle.Left; checkbox.Enabled = false; btn.Controls.Add(checkbox); this.flpTrash.Controls.Add(btn); if (checkbox.Checked) { TrashController.MoveToFirst(trash.ID); this.flpTrash.Controls.SetChildIndex(checkbox.Parent, 0); } } }