@@ -14,6 +14,8 @@ public class MainActivity : Activity
14
14
{
15
15
private bool IsCalculateOver = false ;
16
16
private string ExpressString = "" ;
17
+ private EditText txtInner = null ;
18
+ private EditText txtSurface = null ;
17
19
protected override void OnCreate ( Bundle bundle )
18
20
{
19
21
base . OnCreate ( bundle ) ;
@@ -39,7 +41,7 @@ protected override void OnCreate(Bundle bundle)
39
41
btnOne . Click += delegate { Click ( "1" ) ; } ;
40
42
Button btnTwo = FindViewById < Button > ( Resource . Id . btnTwo ) ;
41
43
btnTwo . Click += delegate { Click ( "2" ) ; } ;
42
- Button btnThree = FindViewById < Button > ( Resource . Id . btnThree ) ;
44
+ Button btnThree = FindViewById < Button > ( Resource . Id . btnThree ) ;
43
45
btnThree . Click += delegate { Click ( "3" ) ; } ;
44
46
Button btnRightBracket = FindViewById < Button > ( Resource . Id . btnRightBracket ) ;
45
47
btnRightBracket . Click += delegate { Click ( "(" ) ; } ;
@@ -63,10 +65,11 @@ protected override void OnCreate(Bundle bundle)
63
65
btnEqual . Click += delegate { Equal ( ) ; } ;
64
66
Button btnClear = FindViewById < Button > ( Resource . Id . btnClear ) ;
65
67
btnClear . Click += delegate { Clear ( ) ; } ;
68
+ txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
69
+ txtSurface = FindViewById < EditText > ( Resource . Id . txtSurface ) ;
66
70
}
67
71
private void Click ( string Tag )
68
72
{
69
- EditText txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
70
73
if ( ! ExpressString . Equals ( "" ) && IsCalculateOver )
71
74
{
72
75
IsCalculateOver = false ;
@@ -76,23 +79,20 @@ private void Click(string Tag)
76
79
}
77
80
private void Back ( )
78
81
{
79
- EditText txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
80
82
if ( ! txtInner . Text . Equals ( "" ) )
81
83
{
82
- txtInner . Text = txtInner . Text . Substring ( 0 , txtInner . Text . Length - 1 ) ;
84
+ txtInner . Text = txtInner . Text . PadRight ( 1 ) ;
83
85
}
84
86
}
85
87
private void Equal ( )
86
88
{
87
- EditText txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
88
- EditText txtSurface = FindViewById < EditText > ( Resource . Id . txtSurface ) ;
89
89
if ( ! txtInner . Text . Equals ( "" ) )
90
90
{
91
91
try
92
- {
92
+ {
93
93
StringCalculate Parse = new StringCalculate ( ) ;
94
- string Result = Parse . runExpress ( txtInner . Text ) ;
95
- double Number = Convert . ToDouble ( Result ) ;
94
+ var Result = Parse . runExpress ( txtInner . Text ) ;
95
+ var Number = Convert . ToDecimal ( Result ) ;
96
96
txtSurface . Text = Number . ToString ( ) ;
97
97
IsCalculateOver = ! IsCalculateOver ;
98
98
ExpressString = Result ;
@@ -106,15 +106,13 @@ private void Equal()
106
106
}
107
107
private void SameAsPrevious ( string Sign )
108
108
{
109
- EditText txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
110
- if ( txtInner . Text . Length > 1 && txtInner . Text . Substring ( txtInner . Text . Length - 2 , 1 ) . Equals ( Sign ) )
109
+ if ( txtInner . Text . Length > 1 && txtInner . Text . PadRight ( 1 ) . Equals ( Sign ) )
111
110
{
112
- txtInner . Text = txtInner . Text . Substring ( 0 , txtInner . Text . Length - 1 ) ;
111
+ txtInner . Text = txtInner . Text . PadLeft ( txtInner . Text . Length - 1 ) ;
113
112
}
114
113
}
115
114
private void Clear ( )
116
115
{
117
- EditText txtInner = FindViewById < EditText > ( Resource . Id . txtInner ) ;
118
116
txtInner . Text = "" ;
119
117
}
120
118
}
0 commit comments