public void BookmarkPersistenceCanBeRoundTripped() { using var tmp = new TempFolder(); var position = new FileSetPosition(1234, Some.String()); var bookmark = new BookmarkFile(tmp.AllocateFilename("bookmark")); bookmark.WriteBookmark(position); var read = bookmark.TryReadBookmark(); Assert.Equal(position.NextLineStart, read.NextLineStart); Assert.Equal(position.File, read.File); }
private void buttonImportBookmarks_Click(object sender, EventArgs e) { int totalImportedBookmarksCount = 0; List <Fiche> createdTags = new List <Fiche>(); List <Fiche> complexNameTags = new List <Fiche>(); foreach (ListViewItem item in listViewBookmarks.SelectedItems) { try { BookmarkFile bookmark = item.Tag as BookmarkFile; switch (bookmark.m_type) { case BookmarkFile.BOOKMARK_TYPE.CHROME: totalImportedBookmarksCount += ImportBookmarksChrome(bookmark.m_fileName, createdTags, complexNameTags); break; } } catch (Exception _e) { BrainForm.MessageBox("An error occurred while attempting to import bookmark file!", _e); } } if (totalImportedBookmarksCount == 0) { BrainForm.MessageBox("No bookmarks were imported...", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (complexNameTags.Count == 0) { BrainForm.MessageBox((totalImportedBookmarksCount - createdTags.Count).ToString() + " bookmarks were successfully imported.\r\n" + createdTags.Count + " tags have been discovered.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Ask the user to rename the tags that were marked as "too complex" BrainForm.MessageBox((totalImportedBookmarksCount - createdTags.Count).ToString() + " bookmarks were successfully imported.\r\n" + createdTags.Count + " tags have been discovered but " + complexNameTags.Count + " of them have names that are deemed too complex." + "\r\n\r\nClick OK to open the list where you can rename them into easier-to-read tags (this is totally optional, you can use long tag names if they seem okay to you!).", MessageBoxButtons.OK, MessageBoxIcon.Warning); // Ask the user to rename complex names ComplexTagNamesForm F = new ComplexTagNamesForm(Bookmark.ms_complexNameTags.ToArray()); F.ShowDialog(this); }