private void butDeleteCat_Click(object sender, System.EventArgs e) { if (listCat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a category first.")); return; } if (MessageBox.Show(Lan.g(this, "Are you sure you want to delete the entire category and all notes in it?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } for (int i = 0; i < notesForCat.Length; i++) { QuickPasteNotes.Delete(notesForCat[i]); } QuickPasteCats.Delete(QuickPasteCats.List[listCat.SelectedIndex]); for (int i = listCat.SelectedIndex; i < QuickPasteCats.List.Length; i++) { //yes, the first update won't work because already deleted QuickPasteCats.List[i].ItemOrder--; QuickPasteCats.Update(QuickPasteCats.List[i]); } QuickPasteNotes.Refresh(); QuickPasteCats.Refresh(); FillCats(); FillNotes(); localChanged = true; }
private void listCat_DoubleClick(object sender, System.EventArgs e) { if (listCat.SelectedIndex == -1) { return; } FormQuickPasteCat FormQ = new FormQuickPasteCat(QuickPasteCats.List[listCat.SelectedIndex]); FormQ.ShowDialog(); if (FormQ.DialogResult == DialogResult.Cancel) { return; } QuickPasteCats.Refresh(); FillCats(); FillNotes(); localChanged = true; }
private void butDownCat_Click(object sender, System.EventArgs e) { if (listCat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a category first.")); return; } if (listCat.SelectedIndex == QuickPasteCats.List.Length - 1) { return; //can't go down any more } QuickPasteCats.List[listCat.SelectedIndex].ItemOrder++; QuickPasteCats.Update(QuickPasteCats.List[listCat.SelectedIndex]); QuickPasteCats.List[listCat.SelectedIndex + 1].ItemOrder--; QuickPasteCats.Update(QuickPasteCats.List[listCat.SelectedIndex + 1]); listCat.SelectedIndex++; QuickPasteCats.Refresh(); FillCats(); FillNotes(); localChanged = true; }
private void butAddCat_Click(object sender, System.EventArgs e) { QuickPasteCat quickCat = new QuickPasteCat(); if (listCat.SelectedIndex == -1) { quickCat.ItemOrder = listCat.Items.Count; //one more than list will hold. } else { quickCat.ItemOrder = listCat.SelectedIndex; } QuickPasteCats.Insert(quickCat); FormQuickPasteCat FormQ = new FormQuickPasteCat(quickCat); FormQ.ShowDialog(); if (FormQ.DialogResult == DialogResult.OK) { if (listCat.SelectedIndex != -1) { //move other items down in list to make room for new one. for (int i = listCat.SelectedIndex; i < QuickPasteCats.List.Length; i++) { QuickPasteCats.List[i].ItemOrder++; QuickPasteCats.Update(QuickPasteCats.List[i]); } } localChanged = true; } else { QuickPasteCats.Delete(quickCat); } QuickPasteCats.Refresh(); FillCats(); FillNotes(); }