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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 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 this.Value = (0).ToString();
19 this.ReadOnly = false;
20 InputType = NumericInputTypes.Default;
21 }
22 //public override string Text
23 //{
24 // get { return base.Text; }
25 // set { base.Text = value; }
26 //}
27
28 private NumericInputTypes _InputType;
29 public NumericInputTypes InputType
30 {
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 case NumericInputTypes.Binary:
44 ValidKeys.Add(Keys.D0);
45 ValidKeys.Add(Keys.NumPad0);
46 ValidKeys.Add(Keys.D1);
47 ValidKeys.Add(Keys.NumPad1);
48 break;
49 case NumericInputTypes.Octal:
50 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 break;
53 case NumericInputTypes.Hex:
54 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 case NumericInputTypes.Decimal:
64 ValidKeys.Add(Keys.Decimal);
65 ValidKeys.Add(Keys.OemPeriod);
66 ValidKeys.Add(Keys.OemMinus);
67 ValidKeys.Add(Keys.Subtract);
68 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 public enum NumericInputTypes
76 {
77 Decimal,
78 Binary,
79 Octal,
80 Hex,
81 Default = Decimal,
82 }
83 }

  ViewVC Help
Powered by ViewVC 1.1.22