Beispiel #1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            Form1 form = (Form1)FindForm();

            if (form == null)
            {
                base.OnKeyDown(e);
                return;
            }

            if (e.Control && e.KeyCode == Keys.X)
            {
                if (!ReadOnly)
                {
                    TextManager.CutControl(this);
                }
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
            else if (e.Control && e.KeyCode == Keys.C)
            {
                TextManager.CopyControl(this);
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
            else if (e.Control && e.KeyCode == Keys.V)
            {
                if (!ReadOnly)
                {
                    TextManager.PasteControl(this);
                }
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
            //else if (e.Control && e.KeyCode == Keys.L)
            //{
            //    TextManager.SelectCurrentLine(form);
            //    e.Handled = true;
            //    e.SuppressKeyPress = true;
            //}
            else if (e.Control && e.KeyCode == Keys.A)
            {
                TextManager.SelectAllControl(this);
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
            else if ((e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) && !e.Shift && !e.Alt && !e.Control)
            {
                String initialText = Text;

                switch (ReturnActionType)
                {
                case ReturnAction.StartSearch:
                    e.Handled          = true;
                    e.SuppressKeyPress = true;

                    SearchManager.SearchNext(form);

                    Text = initialText;
                    Select(TextLength, 0);
                    ScrollToCaret();

                    Focus();
                    break;

                case ReturnAction.StartReplace:
                    e.Handled          = true;
                    e.SuppressKeyPress = true;

                    ReplaceManager.ReplaceNext(form);

                    Text = initialText;
                    Select(TextLength, 0);
                    ScrollToCaret();

                    Focus();
                    break;

                default:
                    //AppendText("¶");
                    base.OnKeyDown(e);
                    break;
                }
            }
            else
            {
                base.OnKeyDown(e);
            }
        }
Beispiel #2
0
        private void replaceToolStripButton2_Click(object sender, EventArgs e)
        {
            Form1 form = (Form1)ParentForm;

            ReplaceManager.ReplaceNext(form);
        }