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

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     case NumericInputTypes.IEEE754HexFloat:
55 william 223 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 william 225 case NumericInputTypes.Decimal:
65 william 223 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 william 225 public enum NumericInputTypes
75 william 223 {
76     Decimal,
77     Binary,
78     Octal,
79     Hex,
80     IEEE754HexFloat,
81     Default = Decimal,
82     }
83     }

  ViewVC Help
Powered by ViewVC 1.1.22