コード例 #1
0
        private void FindBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            var shiftDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);

            if (e.Key == VirtualKey.Enter && !string.IsNullOrEmpty(FindBar.Text))
            {
                _enterPressed = true;
                if (shiftDown)
                {
                    SearchBackwardButton_OnClick(sender, e);
                }
                else
                {
                    SearchForwardButton_OnClick(sender, e);
                }
            }
            else if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible)
                {
                    ReplaceBar.Focus(FocusState.Programmatic);
                }
            }
        }
コード例 #2
0
        public void Focus(string searchString, FindAndReplaceMode mode)
        {
            if (_shouldUpdateSearchString && !string.IsNullOrEmpty(searchString)) FindBar.Text = searchString;

            if (mode == FindAndReplaceMode.FindOnly)
                FindBar.Focus(FocusState.Programmatic);
            else
                ReplaceBar.Focus(FocusState.Programmatic);

            FindBar_OnTextChanged(null, null);
        }
コード例 #3
0
 public void Focus(FindAndReplaceMode mode)
 {
     if (mode == FindAndReplaceMode.FindOnly)
     {
         FindBar.Focus(FocusState.Programmatic);
     }
     else
     {
         ReplaceBar.Focus(FocusState.Programmatic);
     }
 }
コード例 #4
0
        private void FindBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter && !string.IsNullOrEmpty(FindBar.Text))
            {
                _enterPressed = true;
                SearchForwardButton_OnClick(sender, e);
            }

            if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible) ReplaceBar.Focus(FocusState.Programmatic);
            }
        }
コード例 #5
0
 public void Focus(FindAndReplaceMode mode)
 {
     if (mode == FindAndReplaceMode.FindOnly)
     {
         FindBar.Focus(FocusState.Programmatic);
     }
     else
     {
         if (!string.IsNullOrEmpty(FindBar.Text))
         {
             FindBar.SelectionStart = FindBar.Text.Length;
         }
         if (!string.IsNullOrEmpty(ReplaceBar.Text))
         {
             ReplaceBar.SelectionStart = ReplaceBar.Text.Length;
         }
         ReplaceBar.Focus(FocusState.Programmatic);
     }
 }