Esempio n. 1
0
 private void mnuEditReplace_Click(object sender, EventArgs e)
 {
     if (txtTextArea.TextLength > 0)
     {
         int           location = txtTextArea.SelectionStart;
         string        text     = txtTextArea.SelectedText;
         ReplaceDialog dlg      = new ReplaceDialog(text);
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             currentSearchOpts   = (RichTextBoxFinds)0;
             currentSearchString = dlg.ReplaceString;
             if (dlg.CaseSensitive)
             {
                 currentSearchOpts |= RichTextBoxFinds.MatchCase;
             }
             currentSearchOpts |= (dlg.WholeWord) ? RichTextBoxFinds.WholeWord : RichTextBoxFinds.None;
             do
             {
                 location = txtTextArea.Find(currentSearchString, currentSearchOpts);
                 if (location > 0)
                 {
                     txtTextArea.SelectionStart  = location;
                     txtTextArea.SelectionLength = currentSearchString.Length;
                     txtTextArea.SelectedText    = dlg.ReplacementString;
                 }
             } while (location > 0 && dlg.ReplaceAll);
         }
     }
     else
     {
         OutputTextBox.Text = SharedStrings.NO_SEARCH_TEXT;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 替换 对话框
        /// </summary>
        ///
        public void ShowReplaceDlg()
        {
            ReplaceDialog ReplaceDlg = new ReplaceDialog();

            ReplaceDlg.StartPosition = FormStartPosition.CenterParent;
            ReplaceDlg.richTextBox1  = this.richTextBox1;
            ReplaceDlg.textBox1.Text = this.richTextBox1.SelectedText;
            ReplaceDlg.ShowDialog();
        }
Esempio n. 3
0
        public override void Execute()
        {
            FindDialog.CloseIfOpen();
            FindInFilesDialog.CloseIfOpen();
            ReplaceDialog replaceDialog = ReplaceDialog.GetReplaceDialog(this.FindReplaceModel, this.TextEditor, this.MessageDisplayService);

            if (!this.TextEditor.IsSelectionEmpty)
            {
                string text = this.TextEditor.GetText(this.TextEditor.SelectionStart, this.TextEditor.SelectionLength);
                if (!string.IsNullOrEmpty(text) && text.IndexOf('\n') == -1)
                {
                    replaceDialog.FindText = text;
                }
            }
            replaceDialog.Show();
        }
Esempio n. 4
0
        public override void Execute()
        {
            ReplaceDialog.CloseIfOpen();
            FindInFilesDialog.CloseIfOpen();
            FindDialog findDialog = FindDialog.GetFindDialog(this.FindReplaceModel, this.TextEditor, this.MessageDisplayService);

            if (string.IsNullOrEmpty(findDialog.FindText))
            {
                findDialog.SearchReverse = false;
                findDialog.Show();
            }
            else
            {
                if (!findDialog.FindNext())
                {
                    return;
                }
                this.TextEditor.Focus();
            }
        }
Esempio n. 5
0
    void MenuEditReplaceOnClick(object obj, EventArgs ea)
    {
        if (OwnedForms.Length > 0)
        {
            return;
        }

        txtbox.HideSelection = false;

        ReplaceDialog dlg = new ReplaceDialog();

        dlg.Owner       = this;
        dlg.FindText    = strFind;
        dlg.ReplaceText = strReplace;
        dlg.MatchCase   = bMatchCase;
        dlg.FindDown    = bFindDown;
        dlg.FindNext   += new EventHandler(FindDialogOnFindNext);
        dlg.Replace    += new EventHandler(ReplaceDialogOnReplace);
        dlg.ReplaceAll += new EventHandler(ReplaceDialogOnReplaceAll);
        dlg.CloseDlg   += new EventHandler(FindReplaceDialogOnCloseDlg);
        dlg.Show();
    }
Esempio n. 6
0
        private void Replace_Button_Click(object sender, RoutedEventArgs e)
        {
            if (!backgroundWorker.IsBusy)
            {
                string selectedSpotify = ((FullTrack)found_list.SelectedItem).Id;
                int    selectedIndex   = found_list.SelectedIndex;

                var        listlocal_ = (List <LocalTrack>)local_list.ItemsSource;
                LocalTrack local_     = listlocal_.Find(x => x.SpotifyUri == selectedSpotify);
                if (local_ != null)
                {
                    var           list   = searchOps.GetSpotifyTrack(local_, 5);
                    ReplaceDialog dialog = new ReplaceDialog(list);
                    if (dialog.ShowDialog() == true && dialog.returnTrack != null)
                    {
                        var old = (List <FullTrack>)found_list.ItemsSource;
                        found_list.ItemsSource = null;
                        old[selectedIndex]     = dialog.returnTrack;
                        found_list.ItemsSource = old;
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Handles the Click event of the Edit Replace menu item
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">.NET supplied event parameters</param>
        private void mnuEditReplace_Click(object sender, EventArgs e)
        {
            if (codeText.TextLength > 0)
            {
                int location = codeText.SelectionStart;
                string text = codeText.SelectedText;
                ReplaceDialog dlg = new ReplaceDialog(text);

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    currentSearchOpts = (RichTextBoxFinds)0;
                    currentSearchString = dlg.ReplaceString;

                    if (dlg.CaseSensitive)
                    {
                        currentSearchOpts |= RichTextBoxFinds.MatchCase;
                    }

                    currentSearchOpts |= (dlg.WholeWord) ? RichTextBoxFinds.WholeWord : RichTextBoxFinds.None;

                    do
                    {
                        location = codeText.Find(currentSearchString, currentSearchOpts);

                        if (location > 0)
                        {
                            codeText.SelectionStart = location;
                            codeText.SelectionLength = currentSearchString.Length;
                            codeText.SelectedText = dlg.ReplacementString;
                        }
                    }
                    while (location > 0 && dlg.ReplaceAll);
                }
            }
            else
            {
                StatusTextBox.Text = SharedStrings.NO_SEARCH_TEXT;
            }
        }
Esempio n. 8
0
 private void Replace(ReplaceDialog replaceDialog)
 {
     if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
     {
         ReplaceSourceView(replaceDialog);
     }
     else
     {
         ReplaceListView(replaceDialog);
     }
 }
Esempio n. 9
0
        private void ReplaceListView(ReplaceDialog replaceDialog)
        {
            SaveSubtitleListviewIndices();
            int firstIndex = FirstSelectedIndex;
            bool isFirst = true;
            string selectedText = textBoxListViewText.SelectedText;
            if (selectedText.Length == 0 && _findHelper != null)
                selectedText = _findHelper.FindText;

            if (replaceDialog == null)
            {
                replaceDialog = new ReplaceDialog();
                replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
                if (_findHelper == null)
                {
                    _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
                    _findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
                    _findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
                }
                int index = 0;

                if (SubtitleListview1.SelectedItems.Count > 0)
                    index = SubtitleListview1.SelectedItems[0].Index;

                _findHelper.SelectedIndex = index;
                _findHelper.SelectedPosition = index;
                _replaceStartLineIndex = index;
            }
            else
            {
                isFirst = false;
                if (_findHelper != null)
                    selectedText = _findHelper.FindText;
            }
            replaceDialog.Initialize(selectedText, _findHelper);
            if (replaceDialog.ShowDialog(this) == DialogResult.OK)
            {
                if (_findHelper == null)
                {
                    _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
                }
                else
                {
                    int line = _findHelper.SelectedIndex;
                    int pos = _findHelper.SelectedPosition;
                    bool success = _findHelper.Success;
                    _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
                    _findHelper.SelectedIndex = line;
                    _findHelper.SelectedPosition = pos;
                    _findHelper.Success = success;
                }
                ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1));
                int replaceCount = 0;
                bool searchStringFound = true;
                while (searchStringFound)
                {
                    searchStringFound = false;
                    if (isFirst)
                    {
                        MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText));
                        isFirst = false;
                        _makeHistoryPaused = true;
                    }

                    if (replaceDialog.ReplaceAll)
                    {
                        if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                        {
                            textBoxListViewText.Visible = false;
                            SetTextForFindAndReplace(true);
                            _findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
                            searchStringFound = true;
                            replaceCount++;
                        }
                        else
                        {
                            textBoxListViewText.Visible = true;
                            _subtitleListViewIndex = -1;
                            if (firstIndex >= 0 && firstIndex < SubtitleListview1.Items.Count)
                            {
                                SubtitleListview1.Items[firstIndex].Selected = true;
                                SubtitleListview1.Items[firstIndex].Focused = true;
                                SubtitleListview1.Focus();
                                textBoxListViewText.Text = _subtitle.Paragraphs[firstIndex].Text;
                                if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible)
                                {
                                    var orginial = Utilities.GetOriginalParagraph(_findHelper.SelectedIndex, _subtitle.Paragraphs[_findHelper.SelectedIndex], _subtitleAlternate.Paragraphs);
                                    if (orginial != null)
                                        textBoxListViewTextAlternate.Text = orginial.Text;
                                }
                            }
                            else
                            {
                                SubtitleListview1.SelectIndexAndEnsureVisible(0, true);
                            }
                            ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText));

                            if (_replaceStartLineIndex >= 1) // Prompt for start over
                            {
                                _replaceStartLineIndex = 0;
                                string msgText = _language.ReplaceContinueNotFound;
                                if (replaceCount > 0)
                                    msgText = string.Format(_language.ReplaceXContinue, replaceCount);
                                if (MessageBox.Show(msgText, _language.ReplaceContinueTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    _findHelper.StartLineIndex = 0;
                                    _findHelper.SelectedIndex = 0;
                                    _findHelper.SelectedPosition = 0;
                                    SetTextForFindAndReplace(false);

                                    if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                                    {
                                        SetTextForFindAndReplace(true);
                                        _findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
                                        searchStringFound = true;
                                        replaceCount++;
                                    }
                                }
                            }
                        }
                    }
                    else if (replaceDialog.FindOnly)
                    {
                        if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                        {
                            SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true);
                            textBoxListViewText.Focus();
                            textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
                            textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
                            _findHelper.SelectedPosition += _findHelper.FindTextLength;
                            ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText));
                            Replace(replaceDialog);
                            if (replaceDialog != null && !replaceDialog.IsDisposed)
                            {
                                replaceDialog.Dispose();
                                replaceDialog = null;
                            }
                            return;
                        }
                        if (_replaceStartLineIndex >= 1) // Prompt for start over
                        {
                            _replaceStartLineIndex = 0;
                            if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                SubtitleListview1.SelectIndexAndEnsureVisible(0);
                                _findHelper.StartLineIndex = 0;
                                _findHelper.SelectedIndex = 0;
                                _findHelper.SelectedPosition = 0;
                                if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                                {
                                    SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
                                    textBoxListViewText.Focus();
                                    textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
                                    textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
                                    _findHelper.SelectedPosition += _findHelper.FindTextLength;
                                    ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText));
                                    Replace(replaceDialog);
                                    if (replaceDialog != null)
                                    {
                                        replaceDialog.Dispose();
                                        replaceDialog = null;
                                    }
                                    return;
                                }
                            }
                            else
                            {
                                if (replaceDialog != null && !replaceDialog.IsDisposed)
                                {
                                    replaceDialog.Dispose();
                                    replaceDialog = null;
                                }
                                return;
                            }
                        }
                        ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText));
                    }
                    else if (!replaceDialog.FindOnly) // replace once only
                    {
                        string msg = string.Empty;
                        if (_findHelper.FindType == FindType.RegEx && _findHelper.Success)
                        {
                            if (_findHelper.FindType == FindType.RegEx)
                            {
                                ReplaceViaRegularExpression();
                            }
                            else
                            {
                                textBoxListViewText.SelectedText = _findHelper.ReplaceText;
                            }
                            msg = _language.OneReplacementMade + " ";
                        }
                        else if (textBoxListViewText.SelectionLength == _findHelper.FindTextLength)
                        {
                            textBoxListViewText.SelectedText = _findHelper.ReplaceText;
                            msg = _language.OneReplacementMade + " ";
                        }

                        if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                        {
                            SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
                            if (_findHelper.MatchInOriginal)
                            {
                                textBoxListViewTextAlternate.Focus();
                                textBoxListViewTextAlternate.SelectionStart = _findHelper.SelectedPosition;
                                textBoxListViewTextAlternate.SelectionLength = _findHelper.FindTextLength;
                            }
                            else
                            {
                                textBoxListViewText.Focus();
                                textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
                                textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
                            }
                            _findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
                            ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
                        }
                        else
                        {
                            ShowStatus(msg + string.Format(_language.XNotFound, _findHelper.FindText));

                            // Prompt for start over
                            if (_replaceStartLineIndex >= 1)
                            {
                                _replaceStartLineIndex = 0;
                                if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    SubtitleListview1.SelectIndexAndEnsureVisible(0);
                                    _findHelper.StartLineIndex = 0;
                                    _findHelper.SelectedIndex = 0;
                                    _findHelper.SelectedPosition = 0;

                                    if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
                                    {
                                        SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true);
                                        textBoxListViewText.Focus();
                                        textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
                                        textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
                                        _findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
                                        ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
                                    }
                                }
                                else
                                {
                                    if (replaceDialog != null && !replaceDialog.IsDisposed)
                                    {
                                        replaceDialog.Dispose();
                                        replaceDialog = null;
                                    }
                                    return;
                                }
                            }
                        }
                        Replace(replaceDialog);
                        if (replaceDialog != null && !replaceDialog.IsDisposed)
                        {
                            replaceDialog.Dispose();
                            replaceDialog = null;
                        }
                        return;
                    }
                }

                ShowSource();
                if (replaceCount == 0)
                    ShowStatus(_language.FoundNothingToReplace);
                else
                    ShowStatus(string.Format(_language.ReplaceCountX, replaceCount));
            }
            RestoreSubtitleListviewIndices();
            if (_makeHistoryPaused)
                RestartHistory();
            replaceDialog.Dispose();
        }
Esempio n. 10
0
        private void SourceListReplaceAll(ReplaceDialog replaceDialog, FindReplaceDialogHelper findHelper)
        {
            int replaceCount = 0;
            bool searchStringFound = true;
            int start = textBoxSource.SelectionStart;
            bool isFirst = true;
            string text = textBoxSource.Text;
            while (searchStringFound)
            {
                searchStringFound = false;
                if (isFirst)
                {
                    MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText));
                    isFirst = false;
                    _makeHistoryPaused = true;
                    if (start >= 0)
                        start--;
                }
                else
                {
                    start--;
                }

                if (_findHelper.FindNext(text, start))
                {
                    text = text.Remove(findHelper.SelectedIndex, findHelper.FindTextLength).Insert(findHelper.SelectedIndex, findHelper.ReplaceText);
                    start = findHelper.SelectedIndex + findHelper.FindTextLength;
                    replaceCount++;
                    searchStringFound = true;
                }
            }
            textBoxSource.Text = text;
            ReloadFromSourceView();
            if (replaceCount == 0)
                ShowStatus(_language.FoundNothingToReplace);
            else
                ShowStatus(string.Format(_language.ReplaceCountX, replaceCount));

            if (_makeHistoryPaused)
                RestartHistory();
            replaceDialog.Dispose();
        }
Esempio n. 11
0
        private void ReplaceSourceView(ReplaceDialog replaceDialog)
        {
            bool isFirst = true;
            string selectedText = textBoxSource.SelectedText;
            if (selectedText.Length == 0 && _findHelper != null)
                selectedText = _findHelper.FindText;

            if (replaceDialog == null)
            {
                replaceDialog = new ReplaceDialog();
                replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
                if (_findHelper == null)
                {
                    _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
                    _findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
                    _findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
                }
            }
            else
                isFirst = false;

            replaceDialog.Initialize(selectedText, _findHelper);
            if (replaceDialog.ShowDialog(this) == DialogResult.OK)
            {
                _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
                ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1));
                if (replaceDialog.ReplaceAll)
                {
                    SourceListReplaceAll(replaceDialog, _findHelper);
                    return;
                }
                int replaceCount = 0;
                bool searchStringFound = true;
                if (searchStringFound)
                {
                    searchStringFound = false;
                    int start = textBoxSource.SelectionStart;
                    if (isFirst)
                    {
                        MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText));
                        isFirst = false;
                        _makeHistoryPaused = true;
                        if (start >= 0)
                            start--;
                    }
                    else
                    {
                        if (textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly)
                            start--;
                    }

                    if (_findHelper.FindNext(textBoxSource.Text, start))
                    {
                        textBoxSource.SelectionStart = _findHelper.SelectedIndex;
                        textBoxSource.SelectionLength = _findHelper.FindTextLength;
                        if (!replaceDialog.FindOnly)
                            textBoxSource.SelectedText = _findHelper.ReplaceText;
                        textBoxSource.ScrollToCaret();

                        replaceCount++;
                        searchStringFound = true;

                        if (!replaceDialog.FindOnly)
                        {
                            if (_findHelper.FindNext(textBoxSource.Text, start))
                            {
                                textBoxSource.SelectionStart = _findHelper.SelectedIndex;
                                textBoxSource.SelectionLength = _findHelper.FindTextLength;
                                textBoxSource.ScrollToCaret();
                            }
                            Replace(replaceDialog);
                            return;
                        }
                    }
                    if (replaceDialog.FindOnly)
                    {
                        if (searchStringFound)
                            ShowStatus(string.Format(_language.MatchFoundX, _findHelper.FindText));
                        else
                            ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText));

                        Replace(replaceDialog);
                        return;
                    }
                }
                ReloadFromSourceView();
                if (replaceCount == 0)
                    ShowStatus(_language.FoundNothingToReplace);
                else
                    ShowStatus(string.Format(_language.ReplaceCountX, replaceCount));
            }
            if (_makeHistoryPaused)
                RestartHistory();
            replaceDialog.Dispose();
        }
Esempio n. 12
0
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReplaceDialog replaceDialog = new ReplaceDialog(this);

            replaceDialog.Show();
        }
Esempio n. 13
0
        private void ReplaceSourceView(ReplaceDialog replaceDialog)
        {
            bool isFirst = true;
            string selectedText = this.textBoxSource.SelectedText;
            if (selectedText.Length == 0 && this._findHelper != null)
            {
                selectedText = this._findHelper.FindText;
            }

            if (replaceDialog == null)
            {
                replaceDialog = new ReplaceDialog();
                replaceDialog.SetIcon(this.toolStripButtonReplace.Image as Bitmap);
                if (this._findHelper == null)
                {
                    this._findHelper = replaceDialog.GetFindDialogHelper(this._subtitleListViewIndex);
                    this._findHelper.WindowPositionLeft = this.Left + (this.Width / 2) - (replaceDialog.Width / 2);
                    this._findHelper.WindowPositionTop = this.Top + (this.Height / 2) - (replaceDialog.Height / 2);
                }
            }
            else
            {
                isFirst = false;
            }

            replaceDialog.Initialize(selectedText, this._findHelper);
            if (replaceDialog.ShowDialog(this) == DialogResult.OK)
            {
                this._findHelper = replaceDialog.GetFindDialogHelper(this._subtitleListViewIndex);
                this.ShowStatus(string.Format(this._language.SearchingForXFromLineY, this._findHelper.FindText, this._subtitleListViewIndex + 1));
                int replaceCount = 0;
                bool searchStringFound = true;
                while (searchStringFound)
                {
                    searchStringFound = false;
                    int start = this.textBoxSource.SelectionStart;
                    if (isFirst)
                    {
                        this.MakeHistoryForUndo(string.Format(this._language.BeforeReplace, this._findHelper.FindText));
                        isFirst = false;
                        this._makeHistoryPaused = true;
                        if (start >= 0)
                        {
                            start--;
                        }
                    }
                    else
                    {
                        if (this.textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly)
                        {
                            start--;
                        }
                    }

                    if (this._findHelper.FindNext(this.textBoxSource, start))
                    {
                        this.textBoxSource.SelectionStart = this._findHelper.SelectedIndex;
                        this.textBoxSource.SelectionLength = this._findHelper.FindTextLength;
                        if (!replaceDialog.FindOnly)
                        {
                            this.textBoxSource.SelectedText = this._findHelper.ReplaceText;
                        }

                        this.textBoxSource.ScrollToCaret();

                        replaceCount++;
                        searchStringFound = true;

                        if (!replaceDialog.ReplaceAll && !replaceDialog.FindOnly)
                        {
                            if (this._findHelper.FindNext(this.textBoxSource, start))
                            {
                                this.textBoxSource.SelectionStart = this._findHelper.SelectedIndex;
                                this.textBoxSource.SelectionLength = this._findHelper.FindTextLength;
                                this.textBoxSource.ScrollToCaret();
                            }

                            this.Replace(replaceDialog);
                            return;
                        }
                    }

                    if (replaceDialog.FindOnly)
                    {
                        if (searchStringFound)
                        {
                            this.ShowStatus(string.Format(this._language.MatchFoundX, this._findHelper.FindText));
                        }
                        else
                        {
                            this.ShowStatus(string.Format(this._language.NoMatchFoundX, this._findHelper.FindText));
                        }

                        this.Replace(replaceDialog);
                        return;
                    }

                    if (!replaceDialog.ReplaceAll)
                    {
                        break; // out of while loop
                    }
                }

                this.ReloadFromSourceView();
                if (replaceCount == 0)
                {
                    this.ShowStatus(this._language.FoundNothingToReplace);
                }
                else
                {
                    this.ShowStatus(string.Format(this._language.ReplaceCountX, replaceCount));
                }
            }

            if (this._makeHistoryPaused)
            {
                this.RestartHistory();
            }

            replaceDialog.Dispose();
        }
Esempio n. 14
0
 public override void Execute()
 {
     FindDialog.CloseIfOpen();
     ReplaceDialog.CloseIfOpen();
     FindInFilesDialog.GetFindInFilesDialog(this.services).Show();
 }
Esempio n. 15
0
        bool ICommandHandler.HandleCommand(Command command)
        {
            ISearchableDocumentView view;
            bool flag = false;
            bool flag2 = false;
            if (command.CommandGroup.Equals(typeof(GlobalCommands)))
            {
                switch (command.CommandID)
                {
                    case 0x6c:
                        goto Label_02E2;

                    case 0x6d:
                    {
                        ISearchableDocumentView activeDocumentView = this.GetActiveDocumentView() as ISearchableDocumentView;
                        if (activeDocumentView != null)
                        {
                            ReplaceDialog dialog2 = new ReplaceDialog(this._serviceProvider, activeDocumentView, this._lastFindReplaceOptions, activeDocumentView.InitialSearchString, this.FindMruList, this.ReplaceMruList);
                            IUIService service7 = (IUIService) this._serviceProvider.GetService(typeof(IUIService));
                            if (service7 != null)
                            {
                                service7.ShowDialog(dialog2);
                                this._lastFindReplaceOptions = dialog2.FindReplaceOptions;
                            }
                            flag2 = true;
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 110:
                    {
                        ISearchableDocumentView view3 = this.GetActiveDocumentView() as ISearchableDocumentView;
                        if (((view3 != null) && (command.Text != null)) && (command.Text.Length > 0))
                        {
                            this.FindMruList.AddEntry(command.Text);
                            flag2 = true;
                            if (!view3.PerformFind(command.Text, this._lastFindReplaceOptions & (FindReplaceOptions.WholeWord | FindReplaceOptions.MatchCase)))
                            {
                                IUIService service6 = (IUIService) this._serviceProvider.GetService(typeof(IUIService));
                                if (service6 != null)
                                {
                                    service6.ShowMessage("Couldn't find '" + command.Text + "'", string.Empty, MessageBoxButtons.OK);
                                }
                            }
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 8:
                    {
                        IPrintService service = (IPrintService) this._serviceProvider.GetService(typeof(IPrintService));
                        if (service != null)
                        {
                            service.ConfigurePrintSettings();
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 300:
                    case 0x12d:
                    case 0x12e:
                    case 0x12f:
                    case 0x130:
                    case 0x131:
                    case 0x132:
                    case 0x133:
                    case 0x134:
                    case 0x135:
                    case 320:
                    case 0x141:
                        ((ICommandHandler) this.AddInManager).HandleCommand(command);
                        flag = true;
                        goto Label_052C;

                    case 310:
                    case 0x137:
                    case 0x138:
                    case 0x139:
                    case 0x13a:
                    case 0x13b:
                    case 0x13c:
                    case 0x13d:
                    case 0x13e:
                    case 0x13f:
                    case 0x142:
                    case 0x143:
                    case 0x259:
                    case 0x25d:
                    case 0x25f:
                    case 0x260:
                    case 0x261:
                        goto Label_052C;

                    case 0x144:
                    {
                        OptionsDialog dialog3 = new OptionsDialog(this._serviceProvider);
                        ((IUIService) this._serviceProvider.GetService(typeof(IUIService))).ShowDialog(dialog3);
                        flag = true;
                        goto Label_052C;
                    }
                    case 0x145:
                    case 0x146:
                    case 0x147:
                    {
                        IToolboxService service8 = this._serviceProvider.GetService(typeof(IToolboxService)) as IToolboxService;
                        ToolboxSection activeSection = service8.ActiveSection;
                        if (activeSection != null)
                        {
                            activeSection.Customize(command.CommandID - 0x145, this._serviceProvider);
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 180:
                    {
                        ISearchableDocumentView view2 = this.GetActiveDocumentView() as ISearchableDocumentView;
                        if (view2 != null)
                        {
                            if (this.FindMruList.Count == 0)
                            {
                                goto Label_02E2;
                            }
                            view2.PerformFind(this.FindMruList[0], this._lastFindReplaceOptions & (FindReplaceOptions.WholeWord | FindReplaceOptions.MatchCase));
                            flag2 = true;
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 600:
                        this.OnCommandHelpTopics();
                        flag = true;
                        goto Label_052C;

                    case 0x25a:
                    case 0x25e:
                    {
                        ApplicationInfoDialog dialog = new ApplicationInfoDialog(this._serviceProvider, command.CommandID == 0x25e);
                        IUIService service4 = (IUIService) this._serviceProvider.GetService(typeof(IUIService));
                        if (service4 == null)
                        {
                            dialog.ShowDialog();
                        }
                        else
                        {
                            service4.ShowDialog(dialog);
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 0x25b:
                    case 0x25c:
                    {
                        string format = ConfigurationSettings.AppSettings["IDE.AskQuestionUrl"];
                        if ((format == null) || (format.Length == 0))
                        {
                            ((IUIService) this._serviceProvider.GetService(typeof(IUIService))).ShowMessage("Unable to bring up launch the answer page.", "Ask Question");
                        }
                        else
                        {
                            string entry = string.Empty;
                            if (command.CommandID == 0x25c)
                            {
                                entry = command.Text;
                                if (entry != null)
                                {
                                    this.AskQuestionMruList.AddEntry(entry);
                                    format = string.Format(format, entry);
                                    flag2 = true;
                                }
                            }
                            ((IWebBrowsingService) this._serviceProvider.GetService(typeof(IWebBrowsingService))).BrowseUrl(format);
                        }
                        flag = true;
                        goto Label_052C;
                    }
                    case 610:
                    case 0x263:
                    case 0x264:
                    case 0x265:
                    case 0x266:
                    case 0x267:
                    case 0x268:
                    case 0x269:
                    case 0x26a:
                    case 0x26b:
                    {
                        IDictionary webLinks = this.WebLinks;
                        if (webLinks != null)
                        {
                            int num = command.CommandID - 610;
                            string str = "Help" + num;
                            WebLink link = (WebLink) webLinks[str];
                            if (link != null)
                            {
                                this.OnCommandBrowseUrl(link.Url);
                            }
                        }
                        flag = true;
                        goto Label_052C;
                    }
                }
            }
            goto Label_052C;
            Label_02E2:
            view = this.GetActiveDocumentView() as ISearchableDocumentView;
            if (view != null)
            {
                SearchForm form = new SearchForm(this._serviceProvider, view, this._lastFindReplaceOptions, view.InitialSearchString, this.FindMruList);
                IUIService service5 = (IUIService) this._serviceProvider.GetService(typeof(IUIService));
                if (service5 != null)
                {
                    service5.ShowDialog(form);
                    this._lastFindReplaceOptions = form.FindReplaceOptions;
                }
                flag2 = true;
            }
            flag = true;
            Label_052C:
            if (flag2)
            {
                ((ICommandManager) this._serviceProvider.GetService(typeof(ICommandManager))).UpdateCommands(false);
            }
            return flag;
        }
Esempio n. 16
0
 private void Replace()
 {
     ReplaceDialog dialog = new ReplaceDialog(this.htmlControl);
     dialog.ShowDialog();
 }
Esempio n. 17
0
        public void 替换ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //RichTextBox r = new RichTextBox();
            r = GetCurrentRichTextBox();

            ReplaceDialog f = new ReplaceDialog();
            f.rtb = r; //传值(从主窗口传到FindForm)
            f.Owner = this; //悬浮于当前窗体
            f.Show();
        }
Esempio n. 18
0
        private void menuitemEditReplace_Click(object sender, EventArgs e)
        {
            if (Content.Length == 0) return;

            if (_ReplaceDialog == null) {
                _ReplaceDialog = new ReplaceDialog(this);
            }

            _ReplaceDialog.Left = this.Left + 56;
            _ReplaceDialog.Top = this.Top + 113;

            if (!_ReplaceDialog.Visible) {
                _ReplaceDialog.Show(this);
            } else {
                _ReplaceDialog.Show();
            }

            _ReplaceDialog.Triggered();
        }