private void FormMain_NoteTagsChanged(object sender, EventArgs e) { try { var note = sender as PNote; if (note == null || _Notes.Count == 0) { return; } var item = _Notes.FirstOrDefault(n => n.Id == note.ID); var tags = _Tags.Where(t => t.Selected).Select(t => t.Tag); if (item == null) //note was not in list { if (!note.Tags.Any(nt => tags.Any(t => t == nt))) { return; } var key = PNNotesOperations.GetNoteImage(note); _Notes.Add(new FoundNote(key, note.Name, note.Tags.ToCommaSeparatedString(), note.ID)); } else //note was in list { if (!note.Tags.Any(nt => tags.Any(t => t == nt))) { _Notes.Remove(item); } } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void changeNodeImage(PNote note) { try { foreach ( var tn in tvwResults.Items.OfType <PNTreeItem>().Where(tn => tn.Tag != null && (string)tn.Tag == note.ID)) { tn.SetImageResource(PNNotesOperations.GetNoteImage(note)); break; } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void FormMain_NoteBooleanChanged(object sender, NoteBooleanChangedEventArgs e) { try { var note = sender as PNote; if (note == null || _Notes.Count == 0) { return; } var item = _Notes.FirstOrDefault(n => n.Id == note.ID); if (item == null) { return; } item.IconSource = PNNotesOperations.GetNoteImage(note); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void findNotes() { try { _Notes.Clear(); var tags = _Tags.Where(t => t.Selected).Select(t => t.Tag); var notes = PNStatic.Notes.Where(n => n.GroupID != (int)SpecialGroups.RecycleBin); foreach (var note in notes) { if (!note.Tags.Any(nt => tags.Any(t => t == nt))) { continue; } var key = PNNotesOperations.GetNoteImage(note); _Notes.Add(new FoundNote(key, note.Name, note.Tags.ToCommaSeparatedString(), note.ID)); } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void addNote(PNote note) { try { var key = PNNotesOperations.GetNoteImage(note); _Notes.Add(new Result { IconSource = key, Created = note.DateCreated, Saved = note.DateSaved, Deleted = note.DateDeleted, Name = note.Name, Received = note.DateReceived, Sent = note.DateSent, Id = note.ID }); } catch (Exception ex) { PNStatic.LogException(ex); } }
private void findInNoteAtLeastOneWord(PNote note, string searchString, System.Windows.Forms.RichTextBoxFinds options, ref int count) { try { var foundTitle = false; PNRichEditBox edit; var strings = searchString.Split(' '); var counter = 0; var key = PNNotesOperations.GetNoteImage(note); var tn = new PNTreeItem(key, note.Name, note.ID); switch (_Scope) { case SearchScope.Titles: if (!strings.Any(s => note.Name.Contains(s))) { return; } count++; _FoundItems.Add(tn); return; case SearchScope.TextAndTitles: if (strings.Any(s => note.Name.Contains(s))) { count++; foundTitle = true; } break; } if (note.Visible) { edit = note.Dialog.Edit; } else { var path = Path.Combine(PNPaths.Instance.DataDir, note.ID + PNStrings.NOTE_EXTENSION); _HiddenEdit.Size = note.EditSize; PNNotesOperations.LoadNoteFile(_HiddenEdit, path); edit = _HiddenEdit; } var stop = edit.TextLength; foreach (var s in strings) { var start = 0; var index = edit.Find(s, start, options); if (index <= -1) { continue; } counter++; var current = 0; while (index > -1 && current <= index) { count++; current = index; var line = edit.GetLineFromCharIndex(index); var col = index - edit.GetFirstCharIndexFromLine(line); var t = new PNTreeItem("searchloc", s + " (" + _Line + " " + (line + 1).ToString(CultureInfo.InvariantCulture) + ", " + _Column + " " + (col + 1).ToString(CultureInfo.InvariantCulture) + ")", new[] { index, s.Length }); tn.Items.Add(t); if (s.Length > 1) { start = index + s.Length - 1; } else { start = index + s.Length; } if (start >= stop) { break; } index = edit.Find(s, start, options); } } if (counter > 0 || foundTitle) { if (_Scope == SearchScope.TextAndTitles) { if (counter > 0 && foundTitle) { tn.Text += @" " + _TextAndTitle; } else if (counter > 0) { tn.Text += @" " + _TextOnly; } else { tn.Text += @" " + _TitleOnly; } } _FoundItems.Add(tn); return; } count = 0; } catch (Exception ex) { PNStatic.LogException(ex); } }