/[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 224 - (show annotations) (download)
Sat Jun 2 13:27:18 2012 UTC (9 years, 7 months ago) by william
File size: 3211 byte(s)
+ add validiation for octal: numbers between 0 and 7

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;
19 this.ReadOnly = false;
20 InputType = MultiNumericBox_InputType.Default;
21 }
22
23 new public ValueType Value
24 {
25 get { return this.ToSingle(); }
26 set { base.Value = value; }
27 }
28 public override string Text
29 {
30 get { return base.Text; }
31 set { base.Text = value; }
32 }
33
34 private MultiNumericBox_InputType _InputType;
35 public MultiNumericBox_InputType InputType
36 {
37 get { return _InputType; }
38 set
39 {
40 _InputType = value;
41 }
42 }
43
44 protected override void CreateValidKeys(List<Keys> ValidKeys)
45 {
46 base.CreateStandardKeys(ValidKeys);
47 switch (InputType)
48 {
49 case MultiNumericBox_InputType.Binary:
50 ValidKeys.Add(Keys.D0);
51 ValidKeys.Add(Keys.NumPad0);
52 ValidKeys.Add(Keys.D1);
53 ValidKeys.Add(Keys.NumPad1);
54 break;
55 case MultiNumericBox_InputType.Octal:
56 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D7));
57 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad7));
58 break;
59 case MultiNumericBox_InputType.Hex:
60 case MultiNumericBox_InputType.IEEE754HexFloat:
61 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
62 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
63 ValidKeys.Add(Keys.A);
64 ValidKeys.Add(Keys.B);
65 ValidKeys.Add(Keys.C);
66 ValidKeys.Add(Keys.D);
67 ValidKeys.Add(Keys.E);
68 ValidKeys.Add(Keys.F);
69 break;
70 case MultiNumericBox_InputType.Decimal:
71 ValidKeys.Add(Keys.Decimal);
72 ValidKeys.Add(Keys.OemPeriod);
73 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
74 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
75 break;
76 }
77 }
78 }
79
80 public enum MultiNumericBox_InputType
81 {
82 Decimal,
83 Binary,
84 Octal,
85 Hex,
86 IEEE754HexFloat,
87 Default = Decimal,
88 }
89 }

  ViewVC Help
Powered by ViewVC 1.1.22