-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculatorPage.xaml.cs
164 lines (125 loc) · 3.65 KB
/
CalculatorPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
namespace UIControls;
public partial class CalculatorPage : ContentPage
{
double FirstNumber = 0;
double SecoundNumber = 0;
string SelectedOperation = "";
public CalculatorPage()
{
InitializeComponent();
Btn0_Clicked(sender,e);
}
private void Btn0_Clicked(object sender, EventArgs e)
{
if (LblMoniter.Text == "0")
return;
LblMoniter.Text = LblMoniter.Text + "0";
}
private void Btn1_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "1";
}
private void Btn2_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "2";
}
private void Btn3_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "3";
}
private void Btn4_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "4";
}
private void Btn5_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "5";
}
private void Btn6_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "6";
}
private void Btn7_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "7";
}
private void Btn8_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "8";
}
private void Btn9_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = LblMoniter.Text + "9";
}
private void BtnClear_Clicked(object sender, EventArgs e)
{
LblMoniter.Text = "";
LblHistory.Text = "";
LblResult.Text = "";
FirstNumber = 0;
SecoundNumber = 0;
SelectedOperation = "";
}
private void BtnPoint_Clicked(object sender, EventArgs e)
{
if (LblMoniter.Text == "")
{
LblMoniter.Text = "0.";
return;
}
if (LblMoniter.Text.Contains("."))
{
return;
}
LblMoniter.Text = LblMoniter.Text + ".";
//foreach (var charecter in LblMoniter.Text)
//{
// if (charecter == '.')
// {
// }
//}
}
private void BtnOperation_Clicked(object sender, EventArgs e)
{
//object aaa = new ContentPage();
if (LblMoniter.Text == "")
return;
var OperationButton = sender as Button;
SelectedOperation = OperationButton.Text;
if (OperationButton.Text == "*")
{
}
else if (OperationButton.Text == "/")
{
}
else if (OperationButton.Text == "+")
{
if (FirstNumber == 0)
{
var isNumber = double.TryParse(LblMoniter.Text, out FirstNumber);
LblHistory.Text = LblHistory.Text + " " + LblMoniter.Text + " " + SelectedOperation;
LblMoniter.Text = "";
}
else
{
double.TryParse(LblMoniter.Text, out SecoundNumber);
LblHistory.Text = LblHistory.Text + " " + LblMoniter.Text + " " + SelectedOperation;
LblResult.Text = (FirstNumber + SecoundNumber).ToString();
FirstNumber = (FirstNumber + SecoundNumber);
SecoundNumber = 0;
LblMoniter.Text = "";
}
}
else if (OperationButton.Text == "-")
{
}
}
private void BtnEquel_Clicked(object sender, EventArgs e)
{
//TO DO ADD MATH LOGIC
LblMoniter.Text = "";
LblHistory.Text = LblResult.Text;
SecoundNumber = 0;
//LblMoniter.Text = "";
}
}