Пример #1
0
        private void processKbdCtrlShortcuts(object sender, KeyEventArgs e)
        {
            TextBoxBase t = (TextBoxBase)sender;

            if (e.KeyData == (Keys.C | Keys.Control))
            {
                t.Copy();
                e.Handled = true;
            }
            else if (e.KeyData == (Keys.X | Keys.Control))
            {
                t.Cut();
                e.Handled = true;
            }
            else if (e.KeyData == (Keys.V | Keys.Control))
            {
                t.Paste();
                e.Handled = true;
            }
            else if (e.KeyData == (Keys.A | Keys.Control))
            {
                t.SelectAll();
                e.Handled = true;
            }
            else if (e.KeyData == (Keys.Z | Keys.Control))
            {
                t.Undo();
                e.Handled = true;
            }
        }
Пример #2
0
        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            TextBoxBase tbx = sender as TextBoxBase;

            if (tbx != null && e.KeyCode == Keys.Enter)
            {
                tbx.SelectAll();
                switch (tbx.Name)
                {
                case "tbxTitle":
                    mskStock.Focus();
                    break;

                case "mskStock":
                    tbxProducer.Focus();
                    break;

                case "tbxProducer":
                    tbxDirector.Focus();
                    break;

                case "tbxDirector":
                    tbxStarring.Focus();
                    break;

                case "tbxStarring":
                    mskProductionYear.Focus();
                    break;

                case "mskProductionYear":
                    rdoAction.Focus();
                    break;
                }
            }
        }
Пример #3
0
        // Perform the command associated with MenuIndex on the specified TextBoxBase.
        private void DoTextBoxCommand(TextBoxBase textbox, MenuIndex menuIndex)
        {
            switch (menuIndex)
            {
            case MenuIndex.Undo:            textbox.Undo();                         break;

            case MenuIndex.Redo:
                if (textbox is RichTextBox)
                {
                    RichTextBox rt = (RichTextBox)textbox;
                    rt.Redo();
                }
                break;

            case MenuIndex.Cut:                     textbox.Cut();                          break;

            case MenuIndex.Copy:            textbox.Copy();                         break;

            case MenuIndex.Paste:           textbox.Paste();                        break;

            case MenuIndex.Delete:          textbox.SelectedText = "";      break;

            case MenuIndex.SelectAll:       textbox.SelectAll();            break;

            case MenuIndex.Properties:                                                              break;
            }
        }
Пример #4
0
        public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            // If we don't have a control, return
            if (sender is TextBoxBase)
            {
                TextBoxBase control = (TextBoxBase)sender;
                if ((bool)e.NewValue)
                {
                    // Focus this control
                    control.Focus();

                    // Select all text
                    control.SelectAll();
                }
            }
            if (sender is PasswordBox)
            {
                PasswordBox password = (PasswordBox)sender;
                if ((bool)e.NewValue)
                {
                    // Focus this control
                    password.Focus();

                    // Select all text
                    password.SelectAll();
                }
            }
        }
Пример #5
0
 private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveControl is TextBoxBase)
     {
         TextBoxBase tb = (TextBoxBase)ActiveControl;
         tb.SelectAll();
     }
 }
Пример #6
0
 private void tbtemplate_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control == true && e.KeyCode == Keys.A)
     {
         TextBoxBase textBox = (TextBoxBase)sender;
         textBox.SelectAll();
     }
 }
Пример #7
0
 public static void Focus(DependencyObject baseObject, TextBoxBase element)
 {
     FocusManager.SetFocusedElement(baseObject, element);
     Delay(baseObject, 16, () =>
     {
         element.SelectAll();
         Keyboard.Focus(element);
     });
 }
Пример #8
0
        private static void OnSelectAll(object sender, RoutedEventArgs e)
        {
            TextBoxBase box = sender as TextBoxBase;

            if (box != null)
            {
                box.SelectAll();
            }
        }
Пример #9
0
        public void SelectAll()
        {
            TextBoxBase textBox = FindFocusedTextBox();

            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
Пример #10
0
 public static bool ParseInputH(TextBoxBase control, out ulong value)
 {
     if (!ulong.TryParse(control.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out value))
     {
         control.Focus();
         control.SelectAll();
         return(false);
     }
     return(true);
 }
Пример #11
0
 public static bool ParseInputD(TextBoxBase control, out ulong value)
 {
     if (!ulong.TryParse(control.Text, out value))
     {
         control.Focus();
         control.SelectAll();
         return(false);
     }
     return(true);
 }
Пример #12
0
 public void SelectAll()
 {
     if (isFc)
     {
         fc.SelectAll();
     }
     else
     {
         tb.SelectAll();
     }
 }
Пример #13
0
        private static void TrySet(TextBoxBase textBox, bool value)
        {
            if (value)
            {
                textBox.GotKeyboardFocus += async(s, a) =>
                {
                    await Task.Delay(20).ConfigureAwait(true); // Quite ugly but required to make it work

                    textBox.SelectAll();
                };
            }
        }
Пример #14
0
        private void DoCredentialsFocussed(object sender, RoutedEventArgs e)
        {
            TextBoxBase tb = sender as TextBoxBase;

            if (tb == null)
            {
                PasswordBox pwb = sender as PasswordBox;
                pwb.SelectAll();
            }
            else
            {
                tb.SelectAll();
            }
        }
Пример #15
0
        /// <summary>
        /// Handles the key down event for the text controls.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param>
        private void TextKeyDown(object sender, KeyEventArgs e)
        {
            TextBoxBase textBox = sender as TextBoxBase;

            if (textBox == null)
            {
                return;
            }

            if (e.Control && e.KeyCode == Keys.A)
            {
                textBox.SelectAll();
            }
        }
Пример #16
0
 protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
 {
     // if event is called from ComboBox itself and not from any of underlying controls
     // and if textBox is defined in control template
     if (e.OriginalSource == e.Source && textBox != null)
     {
         textBox.Focus();
         textBox.SelectAll();
         e.Handled = true;
     }
     else
     {
         base.OnPreviewGotKeyboardFocus(e);
     }
 }
Пример #17
0
        private void ValidatingTextBox(TextBoxBase control, CancelEventArgs e)
        {
            if (!control.Enabled)
            {
                return;
            }

            if (control.Text.Length != 0)
            {
                return;
            }

            e.Cancel = true;
            control.SelectAll();
            errorProvider1.SetError(control, "Text box cannot be empty");
        }
        private static void SelectAllText(this TextBoxBase textBoxBase)
        {
            if (textBoxBase is System.Windows.Controls.TextBox textBox)
            {
                if (textBox.SelectedText == textBox.Text)
                {
                    return;
                }

                textBox.SelectAll();
                return;
            }

            if (!textBoxBase.IsSelectionActive)
            {
                textBoxBase.SelectAll();
            }
        }
Пример #19
0
        /// <summary>
        /// Traite l'évènement GotFocus de l'élément associé.
        /// </summary>
        /// <param name="sender">La source de l'évènement.</param>
        /// <param name="e">Les <see cref="System.Windows.RoutedEventArgs"/> contenant les données de l'évènement.</param>
        void AssociatedObject_GotFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            TextBoxBase textBox = (TextBoxBase)AssociatedObject;

            // Sélectionne tout le textbox lorsqu'il a le focus
            Dispatcher.BeginInvoke
            (
                DispatcherPriority.ContextIdle,
                new Action
                (
                    () =>
            {
                textBox.SelectAll();
                textBox.ReleaseMouseCapture();
            }
                )
            );
        }
Пример #20
0
 private void FixMicrosoft(object sender, KeyPressEventArgs e)
 {
     // stop annoying beep due to parent not having an AcceptButton
     if ((e.KeyChar == (char)Keys.Enter) || (e.KeyChar == (char)Keys.Escape))
     {
         e.Handled = true;
     }
     // enable Ctrl+A to SelectAll in TextBox and RichTextBox
     if ((ModifierKeys == Keys.Control) && (e.KeyChar == (char)1))
     {
         TextBoxBase control = (sender as TextBoxBase);
         if (control != null)
         {
             control.SelectAll();
             e.Handled = true;
         }
     }
 }
Пример #21
0
        private static void FocusTextBox(TextBoxBase textBox)
        {
            DeferredAction.Create(context =>
            {
                if (textBox == null || Application.Current == null || Application.Current.MainWindow == null)
                {
                    return;
                }

                textBox.Focus();
                textBox.SelectAll();
                FocusManager.SetFocusedElement(Application.Current.MainWindow, textBox);
                Keyboard.Focus(textBox);

                if (textBox.IsVisible == false || textBox.IsKeyboardFocused)
                {
                    context?.Dispose();
                }
                else
                {
                    context?.Defer(TimeSpan.FromSeconds(0.25));
                }
            }).Defer(TimeSpan.FromSeconds(0.25));
        }
Пример #22
0
 //Handles GotFocus for several text boxes
 private static void Text_Focus(TextBoxBase textBox)
 {
     textBox.SelectAll();
 }
Пример #23
0
 public static void TextAutoSelectText(TextBoxBase sender)
 {
     sender.SelectAll();
 }
Пример #24
0
 public static void SetSelect(this TextBoxBase textBox)
 {
     textBox.Focus();
     textBox.SelectAll();
 }
 public static void FocusAndSelectAll(this TextBoxBase s)
 {
     s.Enabled = true;
     s.Focus();
     s.SelectAll();
 }
Пример #26
0
 // Token: 0x060002FC RID: 764 RVA: 0x0000337E File Offset: 0x0000157E
 static void smethod_17(TextBoxBase textBoxBase_0)
 {
     textBoxBase_0.SelectAll();
 }
Пример #27
0
        public static void ProcessTextContextMenu(TextBoxBase textbox, object sender)
        {
            var tsmi = sender as ToolStripMenuItem;

            if (tsmi == null)
            {
                return;
            }

            var cmd = tsmi.Tag as string;

            var text = string.Empty;

            try
            {
                if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_ALL.ToString())
                {
                    if (textbox.Text != "")
                    {
                        Clipboard.SetText(textbox.Text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY.ToString())
                {
                    if (textbox.SelectedText != "")
                    {
                        Clipboard.SetText(textbox.SelectedText);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_CUT.ToString())
                {
                    if (textbox.SelectedText != "")
                    {
                        textbox.Cut();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_PASTE.ToString())
                {
                    if (Clipboard.ContainsText())
                    {
                        //TODO no RTF
                        textbox.Paste();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECT_ALL.ToString())
                {
                    textbox.Focus();
                    textbox.SelectAll();
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_CLEAR.ToString())
                {
                    textbox.Clear();
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_DELETE.ToString())
                {
                    if (textbox.SelectionLength > 0)
                    {
                        var oldStart = textbox.SelectionStart;
                        textbox.Text           = textbox.Text.Remove(textbox.SelectionStart, textbox.SelectionLength);
                        textbox.SelectionStart = oldStart;
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SAVE.ToString())
                {
                    var sfd = new SaveFileDialog();
                    sfd.Filter = ResxManager.GetResourceString(FormStringKeys.STR_TEXT_SAVE_FILTER);
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllText(sfd.FileName, textbox.Text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_WORDWRAP.ToString())
                {
                    textbox.WordWrap = !tsmi.Checked;
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SEND_TO_SOURCE.ToString())
                {
                    //TODO STR_MENUITEM_SEND_TO_SOURCE
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_UNDO.ToString())
                {
                    if (textbox.CanUndo)
                    {
                        textbox.Undo();
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_AS_REGEX.ToString())
                {
                    text = textbox.SelectedText;
                    if (text != string.Empty)
                    {
                        IRegexAnalyst ra = new RegexAnalyst();
                        text = ra.ToSimpleRegexString(text);
                        Clipboard.SetText(text);
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_TO_REGEX_FORMAT.ToString())
                {
                    text = textbox.SelectedText;

                    if (text == string.Empty)
                    {
                        text = textbox.Text;
                    }

                    if (text != string.Empty)
                    {
                        IRegexAnalyst ra = new RegexAnalyst();
                        text = ra.ToSimpleRegexString(text);

                        if (textbox.SelectedText.Length > 0)
                        {
                            if (text != textbox.SelectedText)
                            {
                                //TODO it can be undo,but affect the clipboard
                                Clipboard.SetText(text);
                                textbox.Paste();
                                Clipboard.Clear();
                            }
                        }
                        else
                        {
                            if (text != textbox.Text)
                            {
                                //TODO it can be undo,but affect the clipboard
                                Clipboard.SetText(text);
                                textbox.SelectAll();
                                textbox.Paste();
                                Clipboard.Clear();
                            }
                        }
                    }
                }
                else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECTION_ONLY.ToString())
                {
                    tsmi.Checked = !tsmi.Checked;
                    //textbox.HideSelection = !tsmi.Checked;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
 public void SelectAll()
 {
     textBox.SelectAll();
 }
Пример #29
0
 public static void FocusAndSelectAll(this TextBoxBase control)
 {
     control.Focus();
     control.SelectAll();
 }
Пример #30
0
 public static void activeEdit(TextBoxBase edit)
 {
     edit.Focus();
     edit.SelectAll();
 }