/[RomCheater]/trunk/Win32/libWin32/Win32/UI/MultiNumericBox.cs
ViewVC logotype

Annotation of /trunk/Win32/libWin32/Win32/UI/MultiNumericBox.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 906 - (hide annotations) (download)
Wed Sep 17 13:07:57 2014 UTC (7 years, 4 months ago) by william
File size: 3035 byte(s)
+ fix input keys for some numeric input controls

1 william 223 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Drawing;
5     using System.Data;
6     using System.Linq;
7     using System.Text;
8     using System.Windows.Forms;
9    
10     namespace System.Windows.Forms
11     {
12     public partial class MultiNumericBox : NumericBoxBase
13     {
14     public MultiNumericBox()
15     : base()
16     {
17     InitializeComponent();
18 william 225 this.Value = (0).ToString();
19 william 223 this.ReadOnly = false;
20 william 225 InputType = NumericInputTypes.Default;
21 william 223 }
22 william 225 //public override string Text
23     //{
24     // get { return base.Text; }
25     // set { base.Text = value; }
26     //}
27 william 223
28 william 225 private NumericInputTypes _InputType;
29     public NumericInputTypes InputType
30 william 223 {
31     get { return _InputType; }
32     set
33     {
34     _InputType = value;
35     }
36     }
37    
38     protected override void CreateValidKeys(List<Keys> ValidKeys)
39     {
40     base.CreateStandardKeys(ValidKeys);
41     switch (InputType)
42     {
43 william 225 case NumericInputTypes.Binary:
44 william 223 ValidKeys.Add(Keys.D0);
45     ValidKeys.Add(Keys.NumPad0);
46     ValidKeys.Add(Keys.D1);
47     ValidKeys.Add(Keys.NumPad1);
48     break;
49 william 225 case NumericInputTypes.Octal:
50 william 224 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D7));
51     ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad7));
52 william 223 break;
53 william 225 case NumericInputTypes.Hex:
54 william 223 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
55     ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
56     ValidKeys.Add(Keys.A);
57     ValidKeys.Add(Keys.B);
58     ValidKeys.Add(Keys.C);
59     ValidKeys.Add(Keys.D);
60     ValidKeys.Add(Keys.E);
61     ValidKeys.Add(Keys.F);
62     break;
63 william 225 case NumericInputTypes.Decimal:
64 william 223 ValidKeys.Add(Keys.Decimal);
65     ValidKeys.Add(Keys.OemPeriod);
66 william 904 ValidKeys.Add(Keys.OemMinus);
67 william 906 ValidKeys.Add(Keys.Subtract);
68 william 223 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
69     ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
70     break;
71     }
72     }
73     }
74    
75 william 225 public enum NumericInputTypes
76 william 223 {
77     Decimal,
78     Binary,
79     Octal,
80     Hex,
81     Default = Decimal,
82     }
83     }

  ViewVC Help
Powered by ViewVC 1.1.22