示例#1
0
        public bool Equals(BookmarkViewModel otherVM)
        {
            if (otherVM is null)
            {
                return(false);
            }

            return
                (TypeOfFileSearch == otherVM.TypeOfFileSearch &&
                 FilePattern == otherVM.FilePattern &&
                 IgnoreFilePattern == otherVM.IgnoreFilePattern &&
                 TypeOfSearch == otherVM.TypeOfSearch &&
                 SearchFor == otherVM.SearchFor &&
                 ReplaceWith == otherVM.ReplaceWith &&
                 CaseSensitive == otherVM.CaseSensitive &&
                 WholeWord == otherVM.WholeWord &&
                 Multiline == otherVM.Multiline &&
                 Singleline == otherVM.Singleline &&
                 BooleanOperators == otherVM.BooleanOperators &&
                 IncludeSubfolders == otherVM.IncludeSubfolders &&
                 IncludeHidden == otherVM.IncludeHidden &&
                 IncludeBinary == otherVM.IncludeBinary &&
                 FollowSymlinks == otherVM.FollowSymlinks &&
                 MaxSubfolderDepth == otherVM.MaxSubfolderDepth &&
                 UseGitignore == otherVM.UseGitignore &&
                 SkipRemoteCloudStorageFiles == otherVM.SkipRemoteCloudStorageFiles &&
                 IncludeArchive == otherVM.IncludeArchive &&
                 CodePage == otherVM.CodePage &&
                 ApplyFileSourceFilters == otherVM.ApplyFileSourceFilters &&
                 ApplyFilePropertyFilters == otherVM.ApplyFilePropertyFilters &&
                 ApplyContentSearchFilters == otherVM.ApplyContentSearchFilters);
        }
        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;
                }
            }
        }
示例#3
0
        public BookmarkViewModel(BookmarkViewModel toCopy)
        {
            HasExtendedProperties = true;
            IsEverythingAvailable = EverythingSearch.IsAvailable;

            Description = toCopy.Description;
            FilePattern = toCopy.FilePattern;
            SearchFor   = toCopy.SearchFor;
            ReplaceWith = toCopy.ReplaceWith;

            TypeOfSearch      = toCopy.TypeOfSearch;
            TypeOfFileSearch  = toCopy.TypeOfFileSearch;
            IgnoreFilePattern = toCopy.IgnoreFilePattern;

            IncludeBinary     = toCopy.IncludeBinary;
            IncludeHidden     = toCopy.IncludeHidden;
            IncludeSubfolders = toCopy.IncludeSubfolders;

            CaseSensitive          = toCopy.CaseSensitive;
            IsCaseSensitiveEnabled = toCopy.IsCaseSensitiveEnabled;

            WholeWord          = toCopy.WholeWord;
            IsWholeWordEnabled = toCopy.IsWholeWordEnabled;

            Multiline          = toCopy.Multiline;
            IsMultilineEnabled = toCopy.IsMultilineEnabled;

            Singleline          = toCopy.Singleline;
            IsSinglelineEnabled = toCopy.IsSinglelineEnabled;
        }
示例#4
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;
            }
        }
示例#5
0
        public bool Equals(BookmarkViewModel otherVM)
        {
            if (otherVM is null)
            {
                return(false);
            }

            return
                (TypeOfFileSearch == otherVM.TypeOfFileSearch &&
                 FilePattern == otherVM.FilePattern &&
                 IgnoreFilePattern == otherVM.IgnoreFilePattern &&
                 TypeOfSearch == otherVM.TypeOfSearch &&
                 SearchFor == otherVM.SearchFor &&
                 ReplaceWith == otherVM.ReplaceWith &&
                 CaseSensitive == otherVM.CaseSensitive &&
                 WholeWord == otherVM.WholeWord &&
                 Multiline == otherVM.Multiline &&
                 Singleline == otherVM.Singleline &&
                 BooleanOperators == otherVM.BooleanOperators &&
                 IncludeSubfolders == otherVM.IncludeSubfolders &&
                 IncludeHidden == otherVM.IncludeHidden &&
                 IncludeBinary == otherVM.IncludeBinary &&
                 MaxSubfolderDepth == otherVM.MaxSubfolderDepth &&
                 UseGitignore == otherVM.UseGitignore &&
                 IncludeArchive == otherVM.IncludeArchive &&
                 CodePage == otherVM.CodePage);
        }
示例#6
0
        public BookmarkViewModel(BookmarkViewModel toCopy)
        {
            IsEverythingAvailable = EverythingSearch.IsAvailable;
            IsGitInstalled        = Utils.IsGitInstalled;

            Description = toCopy.Description;
            FilePattern = toCopy.FilePattern;
            SearchFor   = toCopy.SearchFor;
            ReplaceWith = toCopy.ReplaceWith;

            TypeOfSearch      = toCopy.TypeOfSearch;
            TypeOfFileSearch  = toCopy.TypeOfFileSearch;
            IgnoreFilePattern = toCopy.IgnoreFilePattern;

            IncludeBinary               = toCopy.IncludeBinary;
            IncludeHidden               = toCopy.IncludeHidden;
            IncludeSubfolders           = toCopy.IncludeSubfolders;
            MaxSubfolderDepth           = toCopy.MaxSubfolderDepth;
            UseGitignore                = toCopy.UseGitignore;
            SkipRemoteCloudStorageFiles = toCopy.SkipRemoteCloudStorageFiles;
            IncludeArchive              = toCopy.IncludeArchive;
            FollowSymlinks              = toCopy.FollowSymlinks;
            CodePage       = toCopy.CodePage;
            PathReferences = string.Join(Environment.NewLine, toCopy.PathReferences);

            CaseSensitive          = toCopy.CaseSensitive;
            IsCaseSensitiveEnabled = toCopy.IsCaseSensitiveEnabled;

            WholeWord          = toCopy.WholeWord;
            IsWholeWordEnabled = toCopy.IsWholeWordEnabled;

            Multiline          = toCopy.Multiline;
            IsMultilineEnabled = toCopy.IsMultilineEnabled;

            Singleline          = toCopy.Singleline;
            IsSinglelineEnabled = toCopy.IsSinglelineEnabled;

            BooleanOperators          = toCopy.BooleanOperators;
            IsBooleanOperatorsEnabled = toCopy.IsBooleanOperatorsEnabled;

            ApplyFileSourceFilters    = toCopy.ApplyFileSourceFilters;
            ApplyFilePropertyFilters  = toCopy.ApplyFilePropertyFilters;
            ApplyContentSearchFilters = toCopy.ApplyContentSearchFilters;

            UpdateSectionIndex();
            SetExtendedProperties();

            ApplicationFontFamily = GrepSettings.Instance.Get <string>(GrepSettings.Key.ApplicationFontFamily);
            DialogFontSize        = GrepSettings.Instance.Get <double>(GrepSettings.Key.DialogFontSize);
        }
示例#7
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;
                }
            }
        }
示例#8
0
        public BookmarkViewModel(BookmarkViewModel toCopy)
        {
            HasExtendedProperties = true;
            IsEverythingAvailable = EverythingSearch.IsAvailable;
            IsGitInstalled        = Utils.IsGitInstalled;

            Description = toCopy.Description;
            FilePattern = toCopy.FilePattern;
            SearchFor   = toCopy.SearchFor;
            ReplaceWith = toCopy.ReplaceWith;

            TypeOfSearch      = toCopy.TypeOfSearch;
            TypeOfFileSearch  = toCopy.TypeOfFileSearch;
            IgnoreFilePattern = toCopy.IgnoreFilePattern;

            IncludeBinary     = toCopy.IncludeBinary;
            IncludeHidden     = toCopy.IncludeHidden;
            IncludeSubfolders = toCopy.IncludeSubfolders;
            MaxSubfolderDepth = toCopy.MaxSubfolderDepth;
            UseGitignore      = toCopy.UseGitignore;
            IncludeArchive    = toCopy.IncludeArchive;
            CodePage          = toCopy.CodePage;
            PathReferences    = string.Join(Environment.NewLine, toCopy.PathReferences);

            CaseSensitive          = toCopy.CaseSensitive;
            IsCaseSensitiveEnabled = toCopy.IsCaseSensitiveEnabled;

            WholeWord          = toCopy.WholeWord;
            IsWholeWordEnabled = toCopy.IsWholeWordEnabled;

            Multiline          = toCopy.Multiline;
            IsMultilineEnabled = toCopy.IsMultilineEnabled;

            Singleline          = toCopy.Singleline;
            IsSinglelineEnabled = toCopy.IsSinglelineEnabled;

            BooleanOperators          = toCopy.BooleanOperators;
            IsBooleanOperatorsEnabled = toCopy.IsBooleanOperatorsEnabled;
        }
示例#9
0
 public static bool Equals(BookmarkViewModel b1, BookmarkViewModel b2) => b1 is null ? b2 is null : b1.Equals(b2);