Exemple #1
0
        public void ReplaceAll(bool AskBefore = true)
        {
            IEditor CE = GetCurrentEditor();

            if (CE == null)
            {
                return;
            }

            if (!AskBefore || 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;
                // loop through all editors, until we are back at the starting editor
                do
                {
                    Regex r      = GetRegEx(true); // force left to right, otherwise indices are screwed up
                    int   offset = 0;
                    CE.BeginChange();
                    foreach (Match m in r.Matches(CE.Text))
                    {
                        CE.Replace(offset + m.Index, m.Length, ReplacementText);
                        offset += ReplacementText.Length - m.Length;
                    }
                    CE.EndChange();
                    CE = GetNextEditor();
                } while (CurrentEditor != InitialEditor);
            }
        }
Exemple #2
0
        public void ReplaceAll(bool AskBefore = true)
        {
            IEditor CE = GetCurrentEditor();

            if (CE == null)
            {
                return;
            }

            var msgBox = ServiceLocator.Current.GetInstance <IMessageBoxService>();

            if (!AskBefore || msgBox.Show(string.Format(Util.Local.Strings.STR_FINDREPLACE_ASK_REALLY_REPLACEEVERYTHING, TextToFind, ReplacementText),
                                          Util.Local.Strings.STR_FINDREPLACE_ReplaceAll_Caption,
                                          MsgBoxButtons.YesNoCancel, MsgBoxImage.Alert) == MsgBoxResult.Yes)
            {
                object InitialEditor = CurrentEditor;
                // loop through all editors, until we are back at the starting editor
                do
                {
                    Regex r      = GetRegEx(true); // force left to right, otherwise indices are screwed up
                    int   offset = 0;
                    CE.BeginChange();
                    foreach (Match m in r.Matches(CE.Text))
                    {
                        CE.Replace(offset + m.Index, m.Length, ReplacementText);
                        offset += ReplacementText.Length - m.Length;
                    }
                    CE.EndChange();

                    // XXX TODO CE = GetNextEditor();
                } while (CurrentEditor != InitialEditor);
            }
        }
        public void ReplaceAll()
        {
            IEditor CE = GetCurrentEditor();

            if (CE == null)
            {
                return;
            }

            object InitialEditor = CurrentEditor;

            // loop through all editors, until we are back at the starting editor
            do
            {
                Regex r      = GetRegEx(true); // force left to right, otherwise indices are screwed up
                int   offset = 0;
                CE.BeginChange();
                foreach (Match m in r.Matches(CE.Text))
                {
                    CE.Replace(offset + m.Index, m.Length, ReplacementText);
                    offset += ReplacementText.Length - m.Length;
                }
                CE.EndChange();
                CE = GetNextEditor();
            } while (CurrentEditor != InitialEditor);
        }
Exemple #4
0
        public void ReplaceAllText()
        {
            Regex regex  = GetRegEx(TextToFind, true);
            int   offset = 0;

            editor.BeginChange();
            // TODO  if selectionlength > 0 replace only in selection
            foreach (Match match in regex.Matches(editor.Text))
            {
                editor.DocumentReplace(offset + match.Index, match.Length, TextToReplace);
                offset += TextToReplace.Length - match.Length;
            }
            editor.EndChange();
        }