Ejemplo n.º 1
0
        private void ReplaceBar_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)
                {
                    OnFindAndReplaceButtonClicked?.Invoke(sender,
                                                          new FindAndReplaceEventArgs(GetSearchContext(), ReplaceBar.Text, FindAndReplaceMode.Replace, SearchDirection.Previous));
                }
                else
                {
                    ReplaceButton_OnClick(sender, e);
                }
            }
            else if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible)
                {
                    FindBar.Focus(FocusState.Programmatic);
                }
            }
        }
Ejemplo n.º 2
0
        private void SearchBackwardButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (sender is MenuFlyout)
            {
                return;
            }

            OnFindAndReplaceButtonClicked?.Invoke(sender, new FindAndReplaceEventArgs(FindBar.Text, null, MatchCaseToggle.IsChecked, MatchWholeWordToggle.IsChecked, UseRegexToggle.IsChecked, FindAndReplaceMode.FindOnly, SearchDirection.Previous));
        }
Ejemplo n.º 3
0
        private void SearchBackwardButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (sender is MenuFlyout)
            {
                return;
            }

            OnFindAndReplaceButtonClicked?.Invoke(sender, new FindAndReplaceEventArgs(GetSearchContext(), null, FindAndReplaceMode.FindOnly, SearchDirection.Previous));
        }
        private void SearchButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (sender is MenuFlyout)
            {
                return;
            }

            OnFindAndReplaceButtonClicked?.Invoke(sender, new FindAndReplaceEventArgs(SearchBar.Text, null, MatchCaseToggle.IsChecked, MatchWholeWordToggle.IsChecked, FindAndReplaceMode.FindOnly));
        }
Ejemplo n.º 5
0
 private void ReplaceAllButton_OnClick(object sender, RoutedEventArgs e)
 {
     OnFindAndReplaceButtonClicked?.Invoke(sender, new FindAndReplaceEventArgs(FindBar.Text, ReplaceBar.Text, MatchCaseToggle.IsChecked, MatchWholeWordToggle.IsChecked, UseRegexToggle.IsChecked, FindAndReplaceMode.ReplaceAll));
 }
Ejemplo n.º 6
0
        protected override void OnKeyDown(KeyRoutedEventArgs e)
        {
            var ctrl  = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
            var alt   = Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu);
            var shift = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);

            if (ctrl.HasFlag(CoreVirtualKeyStates.Down) && !alt.HasFlag(CoreVirtualKeyStates.Down))
            {
                // Disable RichEditBox default shortcuts (Bold, Underline, Italic)
                // https://docs.microsoft.com/en-us/windows/desktop/controls/about-rich-edit-controls
                if (e.Key == VirtualKey.B || e.Key == VirtualKey.I || e.Key == VirtualKey.U ||
                    e.Key == VirtualKey.Number1 || e.Key == VirtualKey.Number2 ||
                    e.Key == VirtualKey.Number3 || e.Key == VirtualKey.Number4 ||
                    e.Key == VirtualKey.Number5 || e.Key == VirtualKey.Number6 || e.Key == VirtualKey.Number7 ||
                    e.Key == VirtualKey.Number8 || e.Key == VirtualKey.Number9 ||
                    e.Key == VirtualKey.L || e.Key == VirtualKey.R)
                {
                    return;
                }

                if (e.Key == VirtualKey.Tab)
                {
                    return; // ignoring tab key here since it is reserved for tab switch
                }

                if (e.Key == VirtualKey.W)
                {
                    if (!shift.HasFlag(CoreVirtualKeyStates.Down))
                    {
                        OnSetClosingKeyDown?.Invoke(this, e);
                    }
                    return;
                }

                if (e.Key == VirtualKey.F)
                {
                    if (shift.HasFlag(CoreVirtualKeyStates.Down))
                    {
                        OnFindAndReplaceButtonClicked?.Invoke(this, e);
                    }
                    else
                    {
                        OnFindButtonClicked?.Invoke(this, e);
                    }
                    return;
                }

                if (e.Key == VirtualKey.H)
                {
                    OnFindAndReplaceButtonClicked?.Invoke(this, e);
                    return;
                }

                if (e.Key == VirtualKey.Z)
                {
                    if (shift.HasFlag(CoreVirtualKeyStates.Down))
                    {
                        Document.Redo();
                    }
                    else
                    {
                        Document.Undo();
                    }
                    return;
                }

                if (e.Key == (VirtualKey)187 || e.Key == VirtualKey.Add) // +
                {
                    SetDefaultTabStop(FontFamily, FontSize + 2);
                    FontSize += 2;
                    return;
                }

                if (e.Key == (VirtualKey)189 || e.Key == VirtualKey.Subtract) // -
                {
                    if (FontSize > 4)
                    {
                        SetDefaultTabStop(FontFamily, FontSize - 2);
                        FontSize -= 2;
                    }
                    return;
                }

                if (e.Key == VirtualKey.Number0) // 0
                {
                    SetDefaultTabStop(FontFamily, EditorSettingsService.EditorFontSize);
                    FontSize = EditorSettingsService.EditorFontSize;
                    return;
                }
            }

            base.OnKeyDown(e);
        }
Ejemplo n.º 7
0
 private void ReplaceAllButton_OnClick(object sender, RoutedEventArgs e)
 {
     OnFindAndReplaceButtonClicked?.Invoke(sender, new FindAndReplaceEventArgs(GetSearchContext(), ReplaceBar.Text, FindAndReplaceMode.ReplaceAll));
 }