/[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 225 - (show annotations) (download)
Sat Jun 2 14:29:00 2012 UTC (9 years, 4 months ago) by william
File size: 3016 byte(s)
+ commit wip for data type conversion: need to fix format exceptions

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 case NumericInputTypes.IEEE754HexFloat:
55 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
56 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
57 ValidKeys.Add(Keys.A);
58 ValidKeys.Add(Keys.B);
59 ValidKeys.Add(Keys.C);
60 ValidKeys.Add(Keys.D);
61 ValidKeys.Add(Keys.E);
62 ValidKeys.Add(Keys.F);
63 break;
64 case NumericInputTypes.Decimal:
65 ValidKeys.Add(Keys.Decimal);
66 ValidKeys.Add(Keys.OemPeriod);
67 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.D0 && x <= Keys.D9));
68 ValidKeys.AddRange(Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => x >= Keys.NumPad0 && x <= Keys.NumPad9));
69 break;
70 }
71 }
72 }
73
74 public enum NumericInputTypes
75 {
76 Decimal,
77 Binary,
78 Octal,
79 Hex,
80 IEEE754HexFloat,
81 Default = Decimal,
82 }
83 }

  ViewVC Help
Powered by ViewVC 1.1.22