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;
                }
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 public void TestBookmarks()
 {
     BookmarkLibrary.Instance.Bookmarks.Clear();
     BookmarkLibrary.Instance.Bookmarks.Add(new Bookmark("test1", "test2", "test3", "test4"));
     BookmarkLibrary.Save();
     BookmarkLibrary.Load();
     Assert.Equal(BookmarkLibrary.Instance.Bookmarks.Count, 1);
     Assert.Equal(BookmarkLibrary.Instance.Bookmarks[0].Description, "test4");
 }
예제 #4
0
 public void TestBookmarks()
 {
     BookmarkLibrary.Instance.Bookmarks.Clear();
     BookmarkLibrary.Instance.Bookmarks.Add(new Bookmark("test1", "test2", "test3")
     {
         Description = "test4"
     });
     BookmarkLibrary.Save();
     BookmarkLibrary.Load();
     Assert.Single(BookmarkLibrary.Instance.Bookmarks);
     Assert.Equal("test4", BookmarkLibrary.Instance.Bookmarks[0].Description);
 }
예제 #5
0
        private void Delete()
        {
            if (SelectedBookmark != null)
            {
                ClearStar(SelectedBookmark.SearchFor, SelectedBookmark.ReplaceWith, SelectedBookmark.FilePattern);

                var bmk = new Bookmark(SelectedBookmark.SearchFor, SelectedBookmark.ReplaceWith, SelectedBookmark.FilePattern);
                BookmarkLibrary.Instance.Bookmarks.Remove(bmk);
                BookmarkLibrary.Save();

                Bookmarks.Remove(SelectedBookmark);
            }
        }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            BookmarkDetails editForm = new BookmarkDetails(CreateOrEdit.Create);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                Bookmark bookmark = editForm.Bookmark;
                if (!BookmarkLibrary.Instance.Bookmarks.Contains(bookmark))
                {
                    BookmarkLibrary.Instance.Bookmarks.Add(bookmark);
                    BookmarkLibrary.Save();
                    refreshGrid();
                }
            }
        }
예제 #8
0
파일: MainForm.cs 프로젝트: wqssyq/dnGrep
        private void btnBookmark_Click(object sender, EventArgs e)
        {
            BookmarkDetails bookmarkEditForm = new BookmarkDetails(CreateOrEdit.Create);
            Bookmark        newBookmark      = new Bookmark(tbSearchFor.Text, tbReplaceWith.Text, tbFilePattern.Text, "");

            bookmarkEditForm.Bookmark = newBookmark;
            if (bookmarkEditForm.ShowDialog() == DialogResult.OK)
            {
                if (!BookmarkLibrary.Instance.Bookmarks.Contains(newBookmark))
                {
                    BookmarkLibrary.Instance.Bookmarks.Add(newBookmark);
                    BookmarkLibrary.Save();
                }
            }
        }
예제 #9
0
        private void Delete()
        {
            if (SelectedBookmark != null)
            {
                ClearStar(SelectedBookmark.ToBookmark());

                var bmk = BookmarkLibrary.Instance.Find(SelectedBookmark.ToBookmark());
                if (bmk != null)
                {
                    BookmarkLibrary.Instance.Bookmarks.Remove(bmk);
                    BookmarkLibrary.Save();

                    Bookmarks.Remove(SelectedBookmark);
                }
            }
        }
예제 #10
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridBookmarks.SelectedRows.Count != 1)
            {
                return;
            }
            DataRowView bookmarkRow = (DataRowView)gridBookmarks.SelectedRows[0].DataBoundItem;
            Bookmark    oldBookmark = new Bookmark(bookmarkRow["SearchPattern"].ToString(), bookmarkRow["ReplacePattern"].ToString(),
                                                   bookmarkRow["FileNames"].ToString(), bookmarkRow["Description"].ToString());
            Bookmark newBookmark = new Bookmark(bookmarkRow["SearchPattern"].ToString(), bookmarkRow["ReplacePattern"].ToString(),
                                                bookmarkRow["FileNames"].ToString(), bookmarkRow["Description"].ToString());
            BookmarkDetails editForm = new BookmarkDetails(CreateOrEdit.Edit);

            editForm.Bookmark = newBookmark;
            if (editForm.ShowDialog() == DialogResult.OK)
            {
                BookmarkLibrary.Instance.Bookmarks.Remove(oldBookmark);
                BookmarkLibrary.Instance.Bookmarks.Add(newBookmark);
                BookmarkLibrary.Save();
                refreshGrid();
            }
        }
예제 #11
0
 private void BookmarksForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     BookmarkLibrary.Save();
 }