Rev 2357 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2357 | Rev 2364 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | /// <summary> |
29 | /// <summary> |
30 | /// Logica di interazione per MainWindow.xaml |
30 | /// Logica di interazione per MainWindow.xaml |
31 | /// </summary> |
31 | /// </summary> |
32 | public partial class Keypad : Window,INotifyPropertyChanged |
32 | public partial class Keypad : Window,INotifyPropertyChanged |
33 | { |
33 | { |
34 | #region Public Properties |
- | |
Line 35... | Line 34... | ||
35 | 34 | ||
- | 35 | private string _result; |
|
- | 36 | int length = 0; |
|
- | 37 | double min = 0, max = 0; |
|
- | 38 | #region Public Properties |
|
- | 39 | public double MIN |
|
- | 40 | { |
|
- | 41 | get { return min; } |
|
- | 42 | set { min = value; } |
|
- | 43 | } |
|
- | 44 | public double MAX |
|
- | 45 | { |
|
- | 46 | get { return max; } |
|
- | 47 | set { max = value; } |
|
- | 48 | } |
|
- | 49 | public int LENGTH |
|
- | 50 | { |
|
- | 51 | get { return length; } |
|
- | 52 | set { length = value; } |
|
36 | private string _result; |
53 | } |
37 | public string Result |
54 | public string Result |
38 | { |
55 | { |
39 | get { return _result; } |
56 | get { return _result; } |
40 | set { _result = value; this.OnPropertyChanged("Result"); } |
57 | set { _result = value; this.OnPropertyChanged("Result"); } |
- | 58 | } |
|
- | 59 | public void disableDecimal() |
|
- | 60 | { |
|
41 | } |
61 | gDecimal.Visibility = Visibility.Hidden; |
42 | 62 | } |
|
Line 43... | Line 63... | ||
43 | #endregion |
63 | #endregion |
44 | 64 | ||
45 | public Keypad(Window owner) |
65 | public Keypad(Window owner) |
Line 57... | Line 77... | ||
57 | case "ESC": |
77 | case "ESC": |
58 | this.DialogResult = false; |
78 | this.DialogResult = false; |
59 | break; |
79 | break; |
Line 60... | Line 80... | ||
60 | 80 | ||
- | 81 | case "RETURN": |
|
- | 82 | double result1; |
|
- | 83 | if (Double.TryParse(Result, out result1)) |
|
61 | case "RETURN": |
84 | if (result1 <= max && result1 >= min && Result.Length <= length) |
62 | this.DialogResult = true; |
85 | this.DialogResult = true; |
Line 63... | Line 86... | ||
63 | break; |
86 | break; |
64 | 87 | ||
65 | case "BACK": |
88 | case "BACK": |
66 | if (Result.Length > 0) |
89 | if (Result.Length > 0) |
Line 67... | Line 90... | ||
67 | Result = Result.Remove(Result.Length - 1); |
90 | Result = Result.Remove(Result.Length - 1); |
- | 91 | break; |
|
- | 92 | ||
- | 93 | default: |
|
- | 94 | string tmp = Result + button.Content.ToString(); |
|
- | 95 | double result; |
|
- | 96 | // if (Double.TryParse(tmp,System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"),out result)) |
|
68 | break; |
97 | if (Double.TryParse(tmp,out result)) |
- | 98 | { |
|
69 | 99 | if (result <= max && tmp.Length <= length) |
|
70 | default: |
100 | Result += button.Content.ToString(); |
71 | Result += button.Content.ToString(); |
101 | } |
Line 72... | Line 102... | ||
72 | break; |
102 | break; |