Example #1
0
        public void ShowFindAndReplace()
        {
            using (var fdf = new FindDialogForm())
            {
                if (fdf.ShowDialog(_messageEditor) != DialogResult.OK)
                {
                    return;
                }
                var sf = SearchFlags.None;

                if (fdf.MatchCase)
                {
                    sf |= SearchFlags.MatchCase;
                }

                if (fdf.MatchWholeWord)
                {
                    sf |= SearchFlags.WholeWord;
                }

                if (fdf.MatchWordStart)
                {
                    sf |= SearchFlags.WordStart;
                }

                if (fdf.UseRegex)
                {
                    sf |= SearchFlags.RegExp;
                }

                var start = fdf.SelectionOnly
                                        ? _messageEditor.Selection.Start
                                        : 0;
                var end = fdf.SelectionOnly
                                        ? _messageEditor.Selection.End
                                        : _messageEditor.Model.TextLength;

                if (fdf.Reverse)
                {
                    var b = start;
                    start = end;
                    end   = b;
                }

                var res = _messageEditor.Model
                          .FindText(start, end, fdf.TextToFind, sf);

                if (!res.IsSuccess)
                {
                    MessageBox.Show(
                        SR.MessageEditor.FindNothing,
                        ApplicationInfo.ApplicationName,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    _messageEditor.Selection.Start = res.FindStart;
                    _messageEditor.Selection.End   = res.FindEnd;
                }
            }
        }
Example #2
0
        public void ShowFindAndReplace()
        {
            using (var fdf = new FindDialogForm())
            {
                if (fdf.ShowDialog(_messageEditor) != DialogResult.OK)
                    return;
                var sf = SearchFlags.None;

                if (fdf.MatchCase)
                    sf |= SearchFlags.MatchCase;

                if (fdf.MatchWholeWord)
                    sf |= SearchFlags.WholeWord;

                if (fdf.MatchWordStart)
                    sf |= SearchFlags.WordStart;

                if (fdf.UseRegex)
                    sf |= SearchFlags.RegExp;

                var start = fdf.SelectionOnly
                    ? _messageEditor.Selection.Start
                    : 0;
                var end = fdf.SelectionOnly
                    ? _messageEditor.Selection.End
                    : _messageEditor.Model.TextLength;

                if (fdf.Reverse)
                {
                    var b = start;
                    start = end;
                    end = b;
                }

                var res = _messageEditor.Model
                    .FindText(start, end, fdf.TextToFind, sf);

                if (!res.IsSuccess)
                {
                    MessageBox.Show(
                        SR.MessageEditor.FindNothing,
                        ApplicationInfo.ApplicationName,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    _messageEditor.Selection.Start = res.FindStart;
                    _messageEditor.Selection.End = res.FindEnd;
                }
            }
        }