private void removeThumbnail(ThumbnailButton thb) { try { var note = PNStatic.Notes.FirstOrDefault(n => n.ID == thb.Id); thb.Click -= Thumbnail_Click; thb.MouseEnter -= Thumbnail_MouseEnter; thb.MouseLeave -= Thumbnail_MouseLeave; thb.MouseDoubleClick -= Thumbnail_MouseDoubleClick; Thumbnails.Remove(thb); if (note == null) { return; } note.Thumbnail = false; PNNotesOperations.SaveNoteThumbnail(note); if (note.Dialog == null) { return; } note.PlaceOnScreen(); } catch (Exception ex) { PNStatic.LogException(ex); } }
internal int RemoveThumbnail(PNote note, bool resetProperty = true) { try { var index = 0; var thb = Thumbnails.FirstOrDefault(t => t.Id == note.ID); if (thb != null) { index = Thumbnails.IndexOf(thb); thb.Click -= Thumbnail_Click; thb.MouseEnter -= Thumbnail_MouseEnter; thb.MouseLeave -= Thumbnail_MouseLeave; thb.MouseDoubleClick -= Thumbnail_MouseDoubleClick; Thumbnails.Remove(thb); } if (resetProperty) { note.Thumbnail = false; PNNotesOperations.SaveNoteThumbnail(note); } if (note.Dialog == null) { return(index); } note.PlaceOnScreen(); return(index); } catch (Exception ex) { PNStatic.LogException(ex); return(0); } }