From 5353f8c6d75eef84f77f8b3cf2d4379b2d11a261 Mon Sep 17 00:00:00 2001 From: Florian Rager Date: Wed, 13 May 2020 14:17:58 +0200 Subject: [PATCH 1/2] update gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bdc3535..e66f2a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.vs + # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) [Bb]in/ [Oo]bj/ @@ -59,7 +61,7 @@ _ReSharper* *.ncrunch* .*crunch*.local.xml -# Installshield output folder +# Installshield output folder [Ee]xpress # DocProject is a documentation generator add-in From 572d396b59c1e7e45759f56d590bf89d38150541 Mon Sep 17 00:00:00 2001 From: Florian Rager Date: Tue, 26 May 2020 20:18:53 +0200 Subject: [PATCH 2/2] Add property to control whether the replace all prompt is shown Changed this because the replace all confirmation prompt caused some problems with my project. The prompt would for some reason never appear in front of my window??? Tried everything, nothing worked, so I introduced this property. --- FindReplace/FindReplace.cs | 15 ++++++++++++--- FindReplaceUnitTests/FindReplaceVMTest.cs | 9 ++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/FindReplace/FindReplace.cs b/FindReplace/FindReplace.cs index 2176a0c..94ea81d 100644 --- a/FindReplace/FindReplace.cs +++ b/FindReplace/FindReplace.cs @@ -214,7 +214,16 @@ public Window OwnerWindow public static readonly DependencyProperty OwnerWindowProperty = DependencyProperty.Register("OwnerWindow", typeof(Window), typeof(FindReplaceMgr), new UIPropertyMetadata(null)); - + /// + /// Determines whether to display the confirmation Prompt when pressing replace all + /// + public bool ShowReplaceAllConfirmationPrompt + { + get { return (bool)GetValue(ShowReplaceAllConfirmationPromptProperty); } + set { SetValue(ShowReplaceAllConfirmationPromptProperty, value); } + } + public static readonly DependencyProperty ShowReplaceAllConfirmationPromptProperty = + DependencyProperty.Register("ShowReplaceAllPrompt", typeof(bool), typeof(FindReplaceMgr), new UIPropertyMetadata(true)); #endregion @@ -274,12 +283,12 @@ public Regex GetRegEx(bool ForceLeftToRight = false) return r; } - public void ReplaceAll(bool AskBefore = true) + public void ReplaceAll() { IEditor CE = GetCurrentEditor(); if (CE == null) return; - if (!AskBefore || MessageBox.Show("Do you really want to replace all occurences of '" + TextToFind + "' with '" + ReplacementText + "'?", + if (!ShowReplaceAllConfirmationPrompt || MessageBox.Show("Do you really want to replace all occurences of '" + TextToFind + "' with '" + ReplacementText + "'?", "Replace all", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { object InitialEditor = CurrentEditor; diff --git a/FindReplaceUnitTests/FindReplaceVMTest.cs b/FindReplaceUnitTests/FindReplaceVMTest.cs index dad1b2a..a665f4f 100644 --- a/FindReplaceUnitTests/FindReplaceVMTest.cs +++ b/FindReplaceUnitTests/FindReplaceVMTest.cs @@ -182,13 +182,15 @@ public void ReplaceAllTest() bool AskBefore = false; // test basic replacement - target.ReplaceAll(AskBefore); + target.ShowReplaceAllConfirmationPrompt = AskBefore; + target.ReplaceAll(); Assert.AreEqual(Editors[0].Text, @"Hallo 1 bla bla Hallo2 Hallo 3. xxx test tesssst"); // test wrapping through all open files target.SearchIn = FindReplaceMgr.SearchScope.AllDocuments; target.TextToFind = "bla"; - target.ReplaceAll(AskBefore); + target.ShowReplaceAllConfirmationPrompt = AskBefore; + target.ReplaceAll(); Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst"); Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst"); Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx test tesssst"); @@ -197,7 +199,8 @@ public void ReplaceAllTest() target.UseWildcards = true; target.CaseSensitive = true; target.TextToFind = "tes*st"; - target.ReplaceAll(AskBefore); + target.ShowReplaceAllConfirmationPrompt = AskBefore; + target.ReplaceAll(); Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx"); Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx"); Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx xxx");