private void Edit() { if (SelectedBookmark != null) { // edit a copy var editBmk = new BookmarkViewModel(SelectedBookmark); editBmk.SetEditMode(SelectedBookmark.ToBookmark()); var dlg = new BookmarkDetailWindow { DataContext = editBmk, Owner = ownerWnd }; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { editBmk.SetExtendedProperties(); if (SelectedBookmark != editBmk) { ClearStar(SelectedBookmark.ToBookmark()); } var bmk = BookmarkLibrary.Instance.Find(SelectedBookmark.ToBookmark()); if (bmk != null) { BookmarkLibrary.Instance.Bookmarks.Remove(bmk); Bookmarks.Remove(SelectedBookmark); } 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, IncludeArchive = editBmk.IncludeArchive, FollowSymlinks = editBmk.FollowSymlinks, CodePage = editBmk.CodePage, }; 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; } } }
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) { 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, IncludeSubfolders = editBmk.IncludeSubfolders, IncludeHiddenFiles = editBmk.IncludeHidden, IncludeBinaryFiles = editBmk.IncludeBinary, }; BookmarkLibrary.Instance.Bookmarks.Add(newBmk); BookmarkLibrary.Save(); Bookmarks.AddNewItem(editBmk); SelectedBookmark = editBmk; } }
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; } } }