private void Duplicate() { if (SelectedBookmark != null) { // edit a copy var duplicateBmk = new BookmarkViewModel(SelectedBookmark); var dlg = new BookmarkDetailWindow { DataContext = duplicateBmk, Owner = ownerWnd }; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { duplicateBmk.UpdateSectionIndex(); duplicateBmk.SetExtendedProperties(); var newBmk = new Bookmark(duplicateBmk.SearchFor, duplicateBmk.ReplaceWith, duplicateBmk.FilePattern) { Description = duplicateBmk.Description, IgnoreFilePattern = duplicateBmk.IgnoreFilePattern, TypeOfFileSearch = duplicateBmk.TypeOfFileSearch, TypeOfSearch = duplicateBmk.TypeOfSearch, CaseSensitive = duplicateBmk.CaseSensitive, WholeWord = duplicateBmk.WholeWord, Multiline = duplicateBmk.Multiline, Singleline = duplicateBmk.Singleline, BooleanOperators = duplicateBmk.BooleanOperators, IncludeSubfolders = duplicateBmk.IncludeSubfolders, MaxSubfolderDepth = duplicateBmk.MaxSubfolderDepth, IncludeHiddenFiles = duplicateBmk.IncludeHidden, IncludeBinaryFiles = duplicateBmk.IncludeBinary, UseGitignore = duplicateBmk.UseGitignore, SkipRemoteCloudStorageFiles = duplicateBmk.SkipRemoteCloudStorageFiles, IncludeArchive = duplicateBmk.IncludeArchive, FollowSymlinks = duplicateBmk.FollowSymlinks, CodePage = duplicateBmk.CodePage, ApplyFileSourceFilters = duplicateBmk.ApplyFileSourceFilters, ApplyFilePropertyFilters = duplicateBmk.ApplyFilePropertyFilters, ApplyContentSearchFilters = duplicateBmk.ApplyContentSearchFilters, }; BookmarkLibrary.Instance.Bookmarks.Add(newBmk); BookmarkLibrary.Save(); Bookmarks.AddNewItem(duplicateBmk); Bookmarks.CommitNew(); SelectedBookmark = duplicateBmk; } } }
private void AddBookmark() { var editBmk = new BookmarkViewModel(new Bookmark()); var dlg = new BookmarkDetailWindow { DataContext = editBmk, Owner = ownerWnd }; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { editBmk.UpdateSectionIndex(); editBmk.SetExtendedProperties(); var newBmk = new Bookmark(editBmk.SearchFor, editBmk.ReplaceWith, editBmk.FilePattern) { Description = editBmk.Description, IgnoreFilePattern = editBmk.IgnoreFilePattern, TypeOfFileSearch = editBmk.TypeOfFileSearch, TypeOfSearch = editBmk.TypeOfSearch, CaseSensitive = editBmk.CaseSensitive, WholeWord = editBmk.WholeWord, Multiline = editBmk.Multiline, Singleline = editBmk.Singleline, BooleanOperators = editBmk.BooleanOperators, IncludeSubfolders = editBmk.IncludeSubfolders, MaxSubfolderDepth = editBmk.MaxSubfolderDepth, IncludeHiddenFiles = editBmk.IncludeHidden, IncludeBinaryFiles = editBmk.IncludeBinary, UseGitignore = editBmk.UseGitignore, SkipRemoteCloudStorageFiles = editBmk.SkipRemoteCloudStorageFiles, IncludeArchive = editBmk.IncludeArchive, FollowSymlinks = editBmk.FollowSymlinks, CodePage = editBmk.CodePage, ApplyFileSourceFilters = editBmk.ApplyFileSourceFilters, ApplyFilePropertyFilters = editBmk.ApplyFilePropertyFilters, ApplyContentSearchFilters = editBmk.ApplyContentSearchFilters, }; string[] paths = editBmk.PathReferences.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); newBmk.FolderReferences.AddRange(paths); BookmarkLibrary.Instance.Bookmarks.Add(newBmk); BookmarkLibrary.Save(); Bookmarks.AddNewItem(editBmk); Bookmarks.CommitNew(); SelectedBookmark = editBmk; } }