ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/Win32/libWin32/Win32/UI/NumericBoxBase.cs
(Generate patch)

Comparing trunk/Win32/libWin32/Win32/UI/NumericBoxBase.cs (file contents):
Revision 220 by william, Sat Jun 2 11:55:57 2012 UTC vs.
Revision 223 by william, Sat Jun 2 13:20:13 2012 UTC

# Line 6 | Line 6 | using System.Data;
6   using System.Linq;
7   using System.Text;
8   using System.Windows.Forms;
9 + using System.Collections;
10  
11   namespace System.Windows.Forms
12   {
# Line 40 | Line 41 | namespace System.Windows.Forms
41  
42          private void btnCopy_Click(object sender, EventArgs e) { Clipboard.SetData(DataFormats.Text, this.Text); }
43          private void btnPaste_Click(object sender, EventArgs e) { if (this.ReadOnly) return; this.Text = (string)Clipboard.GetData(DataFormats.Text); }
44 +
45 +
46 +        protected void CreateStandardKeys(List<Keys> ValidKeys)
47 +        {
48 +            // these are mostly editing/navigation keys
49 +            ValidKeys.Add(Keys.Delete);
50 +            ValidKeys.Add(Keys.Back);
51 +            ValidKeys.Add(Keys.Up);
52 +            ValidKeys.Add(Keys.Down);
53 +            ValidKeys.Add(Keys.Left);
54 +            ValidKeys.Add(Keys.Right);
55 +            ValidKeys.Add(Keys.Home);
56 +            ValidKeys.Add(Keys.End);
57 +        }
58 +        protected virtual void CreateValidKeys(List<Keys> ValidKeys)
59 +        {
60 +            //ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
61 +           // ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
62 +        }
63 +        protected List<Keys> GetValidKeys()
64 +        {
65 +            List<Keys> ValidKeys = new List<Keys>();
66 +            CreateStandardKeys(ValidKeys);
67 +            CreateValidKeys(ValidKeys);
68 +            return ValidKeys;
69 +        }
70 +        private void txtValueBox_KeyDown(object sender, KeyEventArgs e)
71 +        {
72 +            List<Keys> ValidKeys = this.GetValidKeys();
73 +            if (ValidKeys.Contains(e.KeyCode))
74 +            {
75 +                if (txtValueBox.Text.Contains(".") && (e.KeyCode == Keys.Decimal || e.KeyCode == Keys.OemPeriod))
76 +                {
77 +                    e.SuppressKeyPress = true;
78 +                }
79 +                return;
80 +            }
81 +            if(!e.Control && !e.Alt)
82 +            {
83 +                e.SuppressKeyPress = true;
84 +            }
85 +        }
86      }
87  
88      #region NumericBox Extensions

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines