private void FormQuickPaste_Load(object sender, System.EventArgs e) { if (!Security.IsAuthorized(Permissions.AutoNoteQuickNoteEdit, true)) { butAddCat.Enabled = false; butDeleteCat.Enabled = false; butAddNote.Enabled = false; butUpCat.Enabled = false; butUpNote.Enabled = false; butDownCat.Enabled = false; butDownNote.Enabled = false; butAlphabetize.Enabled = false; butEditNote.Text = "View"; } if (TextToFill == null) { butDate.Visible = false; } _listCats = QuickPasteCats.GetDeepCopy(); _listCatsOld = _listCats.Select(x => x.Copy()).ToList(); FillCats(); listCat.SelectedIndex = QuickPasteCats.GetDefaultType(QuickType); _listNotes = QuickPasteNotes.GetDeepCopy(); _listNotesOld = _listNotes.Select(x => x.Copy()).ToList(); FillMain(); }
private void butAddCat_Click(object sender, System.EventArgs e) { QuickPasteCat quickCat = new QuickPasteCat(); FormQuickPasteCat FormQ = new FormQuickPasteCat(quickCat); FormQ.ShowDialog(); if (FormQ.DialogResult != DialogResult.OK) { return; } quickCat = FormQ.QuickCat; QuickPasteCats.Insert(quickCat); _hasChanges = true; //We are doing this so tha when the sync is called in FormQuickPaste_FormClosing(...) we do not re-insert. //For now the sync will still detect a change due to the item orders. _listCatsOld.Add(quickCat.Copy()); if (listCat.SelectedIndex != -1) { _listCats.Insert(listCat.SelectedIndex, quickCat); //insert at selectedindex AND selects new category when we refill grid below. } else //Will only happen if they do not have any categories. { _listCats.Add(quickCat); //add to bottom of list, will be selected when we fill grid below. } FillCats(); FillMain(); }
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 FormQuickPaste_Load(object sender, System.EventArgs e) { if (!Security.IsAuthorized(Permissions.AutoNoteQuickNoteEdit, true)) { butAddCat.Enabled = false; butDeleteCat.Enabled = false; butAddNote.Enabled = false; butEditNote.Text = "View"; } FillCats(); listCat.SelectedIndex = QuickPasteCats.GetDefaultType(QuickType); FillNotes(); }
private void butOK_Click(object sender, System.EventArgs e) { QuickCat.Description = textDescription.Text; QuickCat.DefaultForTypes = ""; for (int i = 0; i < listType.SelectedIndices.Count; i++) { if (i > 0) { QuickCat.DefaultForTypes += ","; } QuickCat.DefaultForTypes += listType.SelectedIndices[i].ToString(); } QuickPasteCats.Update(QuickCat); DialogResult = DialogResult.OK; }
private void FormQuickPaste_FormClosing(object sender, FormClosingEventArgs e) { for (int i = 0; i < _listNotes.Count; i++) { _listNotes[i].ItemOrder = i; //Fix item orders. } for (int i = 0; i < _listCats.Count; i++) { _listCats[i].ItemOrder = i; //Fix item orders. } _hasChanges |= QuickPasteCats.Sync(_listCats, _listCatsOld); if (QuickPasteNotes.Sync(_listNotes, _listNotesOld) || _hasChanges) { SecurityLogs.MakeLogEntry(Permissions.AutoNoteQuickNoteEdit, 0, "Quick Paste Notes/Cats Changed"); DataValid.SetInvalid(InvalidType.QuickPaste); } }
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; }
///<summary>Called on KeyUp from various textBoxes in the program to look for a ?abbrev and attempt to substitute. Substitutes the text if found.</summary> public static string Substitute(string text, QuickPasteType type) { int typeIndex = QuickPasteCats.GetDefaultType(type); for (int i = 0; i < List.Length; i++) { if (List[i].Abbreviation == "") { continue; } if (List[i].QuickPasteCatNum != QuickPasteCats.List[typeIndex].QuickPasteCatNum) { continue; } text = Regex.Replace(text, @"\?" + List[i].Abbreviation, List[i].Note); } return(text); }
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 listCat_DoubleClick(object sender, System.EventArgs e) { if (!Security.IsAuthorized(Permissions.AutoNoteQuickNoteEdit)) { return; } if (listCat.SelectedIndex == -1) { return; } FormQuickPasteCat FormQ = new FormQuickPasteCat(QuickPasteCats.List[listCat.SelectedIndex]); FormQ.ShowDialog(); if (FormQ.DialogResult == DialogResult.Cancel) { return; } QuickPasteCats.RefreshCache(); 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(); }
private void FormQuickPaste_Load(object sender, System.EventArgs e) { FillCats(); listCat.SelectedIndex = QuickPasteCats.GetDefaultType(QuickType); FillNotes(); }