From 78455c91b09616e2ff6713adbd6d44463a80608b Mon Sep 17 00:00:00 2001 From: Jes Date: Thu, 14 Jan 2010 19:01:07 +0100 Subject: Mise à jour de l'éditeur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-editor/CustomControl.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 script-editor/CustomControl.cs (limited to 'script-editor/CustomControl.cs') diff --git a/script-editor/CustomControl.cs b/script-editor/CustomControl.cs new file mode 100644 index 0000000..829565c --- /dev/null +++ b/script-editor/CustomControl.cs @@ -0,0 +1,35 @@ +using System.Windows.Forms; + +namespace CustomControl +{ + public class MyPanel : Panel + { + protected override void OnPaintBackground(PaintEventArgs pevent) { } + } + + public class MyRichTextBox : RichTextBox + { + private bool allowedKeypress; + + protected override void OnKeyPress(KeyPressEventArgs e) + { + e.Handled = true; + if (!allowedKeypress) + System.Media.SystemSounds.Beep.Play(); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + allowedKeypress = e.Control && (e.KeyCode == Keys.A || e.KeyCode == Keys.C || e.KeyCode == Keys.Insert || e.KeyCode == Keys.Y || e.KeyCode == Keys.Z); + + if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete || (e.Control && (e.KeyCode == Keys.V || e.KeyCode == Keys.X)) || (e.Shift && (e.KeyCode == Keys.Insert || e.KeyCode == Keys.Delete))) + { + if (e.KeyCode == Keys.Delete || (e.Shift && (e.KeyCode == Keys.Insert || e.KeyCode == Keys.Delete))) + System.Media.SystemSounds.Beep.Play(); + e.Handled = true; + } + else + base.OnKeyDown(e); + } + } +} -- cgit v1.2.3