Beispiel #1
0
        /// <summary>
        /// Opens the Quick Find box.  The word under the cursor is automatically
        /// filled into the Find field.
        /// </summary>
        /// <param name="replace">A boolean value specifying whether we want Replace functionality.</param>
        public void Open(bool replace = false)
        {
            bool wasVisibleBefore = Visible;

            ApplyStyle(StyleManager.Style);

            SuspendLayout();
            TitleLabel.Text = replace ? "Quick Replace" : "Quick Find";

            BringToFront();
            Show();

            // populate the Find term from the current selection
            if (!wasVisibleBefore)
            {
                if (string.IsNullOrEmpty(m_codeBox.SelectedText))
                {
                    // if no selection, use word under cursor
                    int wordStart = m_codeBox.WordStartPosition(m_codeBox.CurrentPosition, false);
                    int wordEnd   = m_codeBox.WordEndPosition(m_codeBox.CurrentPosition, false);
                    if (!wasVisibleBefore)
                    {
                        m_codeBox.TargetStart = wordStart;
                        FindTextBox.Text      = m_codeBox.GetWordFromPosition(m_codeBox.CurrentPosition);
                    }
                }
                else if (!m_codeBox.SelectedText.Contains('\r') && !m_codeBox.SelectedText.Contains('\n'))
                {
                    // if there is a selection, use it as the search term unless it contains newlines
                    m_codeBox.TargetStart = m_codeBox.SelectionStart;
                    FindTextBox.Text      = m_codeBox.SelectedText;
                }
                else
                {
                    FindTextBox.Text = "";
                }
                if (!string.IsNullOrEmpty(FindTextBox.Text))
                {
                    PerformFind();
                }
            }

            FindTextBox.Focus();
            FindTextBox.SelectAll();
            ReplaceTextBox.Visible   = replace;
            ReplaceButton.Visible    = replace;
            ReplaceAllButton.Visible = replace;
            if (replace)
            {
                Height = m_fullHeight;
            }
            else
            {
                Height = m_fullHeight - ReplaceTextBox.Height;
            }

            ResumeLayout();
        }
Beispiel #2
0
 private void FindTextBox_Enter(object sender, EventArgs e)
 {
     // don't Select All unless we came from a different textbox
     if (m_lastTextBox != FindTextBox)
     {
         FindTextBox.SelectAll();
     }
     m_lastTextBox = FindTextBox;
 }
 private void FindTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     FindTextBox.SelectAll();
 }