M.Sc. – I.T.
Semester II
Mobile Computing
Sr. No. Title Page No
1 Simple Addition,Multiplication,etc operations in Windows
Mobile
2 Calculate Factorial,Revers,IsPalindrome of a given Number in
Windows Mobile.
3
Design Currency Converter in Windows Mobile.
4
a) Design Unit Converter in Windows Mobile.
b)Design Temperature Converter in Windows Mobile.
5
Design Standard Calculator in Windows Mobile.
6
Design Graphics(display circle,square,rectangle,etc)
Application in Windows Mobile.
7
Design Link Navigation Application in Windows Mobile.
8
. quiz program in windows.
9
Emi & BMI
10 Design Image Dropdown List in Windows Mobile.
Practical No.1
Aim: Simple Addition,Multiplication,etc operations in Windows
Mobile.
Add the following Labels ,Textbox and Buttons as shown below
Change the name properties of each of this as shown below
After changing the name properties
Double click on ADD button
private void add_Click(object sender, EventArgs e)
{
lbl_sign.Text = "+";
lbl_temp.Text = txt_no.Text;
txt_no.Text = "";
}
Double click on SUB button
private void sub_Click(object sender, EventArgs e)
{
lbl_sign.Text = "-";
lbl_temp.Text = txt_no.Text;
txt_no.Text = "";
}
Double click on DIV button
private void div_Click(object sender, EventArgs e)
{
lbl_sign.Text = "/";
lbl_temp.Text = txt_no.Text;
txt_no.Text = "";
}
Double click on MUL button
private void mul_Click(object sender, EventArgs e)
{
lbl_sign.Text = "*";
lbl_temp.Text = txt_no.Text;
txt_no.Text = "";
}
Double click on CLEAR button
private void clear_Click(object sender, EventArgs e)
{
txt_no.Text = "";
lbl_temp.Text = "";
lbl_sign.Text = "";
}
Double click on = button
private void equal_Click(object sender, EventArgs e)
{
if (lbl_sign.Text == "+")
{
a = Convert.ToDouble(lbl_temp.Text);
b = Convert.ToDouble(txt_no.Text);
ans = a + b;
lbl_temp.Text = Convert.ToString(ans);
txt_no.Text = lbl_temp.Text;
lbl_temp.Text = null;
}
else if (lbl_sign.Text == "-")
{
a = Convert.ToDouble(lbl_temp.Text);
b = Convert.ToDouble(txt_no.Text);
ans = a - b;
lbl_temp.Text = Convert.ToString(ans);
txt_no.Text = lbl_temp.Text;
lbl_temp.Text = null;
}
else if (lbl_sign.Text == "/")
{
a = Convert.ToDouble(lbl_temp.Text);
b = Convert.ToDouble(txt_no.Text);
ans = a / b;
lbl_temp.Text = Convert.ToString(ans);
txt_no.Text = lbl_temp.Text;
lbl_temp.Text = null;
}
else if (lbl_sign.Text == "*")
{
a = Convert.ToDouble(lbl_temp.Text);
b = Convert.ToDouble(txt_no.Text);
ans = a * b;
lbl_temp.Text = Convert.ToString(ans);
txt_no.Text = lbl_temp.Text;
lbl_temp.Text = null;
}
else { }
}
Click on start debugging button
Click on Deploy button
Enter number in textbox and click ADD Enter second number in textbox
Click = button For second calculation click on another operation
Practical No.2
Aim: Calculate Factorial,Revers,IsPalindrome of a given Number in
Windows Mobile.
Add the following labels, buttons and textbox as shown below
Rename their name and text properties as shown below
Name property of above controls
Double click on FACTORIAL button
private void btn_fact_Click(object sender, EventArgs e)
{
int a, i, fact = 1;
a = Convert.ToInt32(txt_no.Text);
for (i = a; i >= 1; i--)
{
fact = fact * i;
}
lbl_fact.Text = Convert.ToString(fact);
}
Double click on REVERSE button
private void btn_rev_Click(object sender, EventArgs e)
{
int a, temp, d, rev = 0;
a = Convert.ToInt32(txt_no.Text);
temp = a;
while (temp > 0)
{
d = temp % 10;
temp /= 10;
rev = rev * 10 + d;
}
lbl_rev.Text = Convert.ToString(rev);
}
Double click on Palindrome button
private void btn_palindrome_Click(object sender, EventArgs e)
{
int a, temp, d, rev = 0;
a = Convert.ToInt32(txt_no.Text);
temp = a;
while (temp > 0)
{
d = temp % 10;
temp /= 10;
rev = rev * 10 + d;
}
if (rev == a)
{
lbl_palin.Text = "Palindrome";
}
else
{
lbl_palin.Text = "NO";
}
}
Click on start debugging button
Click on Deploy button
Practical No.3
Aim:.Design Currency Converter in Windows Mobile.
Code for Button 1 : Convert
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim c, d
If (ComboBox1.Text = "Dollar") Then
c = Convert.ToInt32(TextBox1.Text)
d = c * 63
TextBox2.Text = d.ToString()
EndIf
If (ComboBox1.Text = "Pound") Then
c = Convert.ToInt32(TextBox1.Text)
d = c * 101
TextBox2.Text = d.ToString()
EndIf
If (ComboBox1.Text = "Yen") Then
c = Convert.ToInt32(TextBox1.Text)
d = c * 0.6
TextBox2.Text = d.ToString()
EndIf
EndSub
Button 2 : Reset
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
ComboBox1.Text = "Select"
EndSub
Practical No.4
Aim: a) Design Unit Converter in Windows Mobile.
Combo box 1 : convert from (SelectedIndexChanged event of combobox)
privatevoid comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
double a = Convert.ToDouble(textBox1.Text);
double b;
if (comboBox1.Text == "mm"&& comboBox2.Text == "mm")
{
label1.Text = "Milimeter";
b = a;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "cm")
{
label1.Text = "Milimeter";
b = a * 0.1;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "m")
{
label1.Text = "Milimeter";
b = a * 0.001;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "inch")
{
label1.Text = "Milimeter";
b = a * 0.0393701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "Foot")
{
label1.Text = "Milimeter";
b = a * 0.00328084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "mm")
{
label1.Text = "Centimeter";
b = a * 10;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "cm")
{
label1.Text = "Centimeter";
b = a;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "m")
{
label1.Text = "Centimeter";
b = a * 0.01;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "inch")
{
label1.Text = "Centimeter";
b = a * 0.393701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "foot")
{
label1.Text = "Centimeter";
b = a * 0.0328084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "mm")
{
label1.Text = "Meter";
b = a * 1000;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "cm")
{
label1.Text = "Meter";
b = a * 100;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "m")
{
label1.Text = "Meter";
b = a;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "inch")
{
label1.Text = "Meter";
b = a * 39.3701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "foot")
{
label1.Text = "Meter";
b = a * 3.28084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "mm")
{
label1.Text = "Inch";
b = a * 25.4;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "cm")
{
label1.Text = "Inch";
b = a * 2.54;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "m")
{
label1.Text = "Inch";
b = a * 0.0254;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "inch")
{
label1.Text = "Inch";
b = a;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "foot")
{
label1.Text = "Inch";
b = a * 0.0833333;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "mm")
{
label1.Text = "Foot";
b = a * 304.8;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "cm")
{
label1.Text = "Foot";
b = a * 30.48;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Foot"&& comboBox2.Text == "m")
{
label1.Text = "Foot";
b = a * 0.3048;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "inch")
{
label1.Text = "Foot";
b = a * 12;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "foot")
{
label1.Text = "Foot";
b = a;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "mm")
{
label1.Text = "Kilometer";
b = a * 1000000;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "cm")
{
label1.Text = "Kilometer";
b = a * 100000;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "m")
{
label1.Text = "Kilometer";
b = a * 1000;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "inch")
{
label1.Text = "Kilometer";
b = a * 39370.1;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "foot")
{
label1.Text = "Kilometer";
b = a * 3280.84;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "Km")
{
label1.Text = "Milimeter";
b = a * 0.000001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "Km")
{
label1.Text = "Centimeter";
b = a * 0.00001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "Km")
{
label1.Text = "Meter";
b = a * 0.001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "Km")
{
label1.Text = "Inch";
b = a * 0.00254;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "Km")
{
label1.Text = "Foot";
b = a * 0.0003048;
label2.Text = "Km";
textBox2.Text = b.ToString();
}
}
Combo box 2 : convert to ( SelectedIndexChanged event of combobox 2)
privatevoid comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Focus();
double a = Convert.ToDouble(textBox1.Text);
double b;
if (comboBox1.Text == "mm"&& comboBox2.Text == "mm")
{
label1.Text = "Milimeter";
b = a;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "cm")
{
label1.Text = "Milimeter";
b = a * 0.1;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "m")
{
label1.Text = "Milimeter";
b = a * 0.001;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "inch")
{
label1.Text = "Milimeter";
b = a * 0.0393701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "Foot")
{
label1.Text = "Milimeter";
b = a * 0.00328084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "mm")
{
label1.Text = "Centimeter";
b = a * 10;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "cm")
{
label1.Text = "Centimeter";
b = a;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "m")
{
label1.Text = "Centimeter";
b = a * 0.01;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "inch")
{
label1.Text = "Centimeter";
b = a * 0.393701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "foot")
{
label1.Text = "Centimeter";
b = a * 0.0328084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "mm")
{
label1.Text = "Meter";
b = a * 1000;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "cm")
{
label1.Text = "Meter";
b = a * 100;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "m")
{
label1.Text = "Meter";
b = a;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "inch")
{
label1.Text = "Meter";
b = a * 39.3701;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "foot")
{
label1.Text = "Meter";
b = a * 3.28084;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "mm")
{
label1.Text = "Inch";
b = a * 25.4;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "cm")
{
label1.Text = "Inch";
b = a * 2.54;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "m")
{
label1.Text = "Inch";
b = a * 0.0254;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "inch")
{
label1.Text = "Inch";
b = a;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "foot")
{
label1.Text = "Inch";
b = a * 0.0833333;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "mm")
{
label1.Text = "Foot";
b = a * 304.8;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "cm")
{
label1.Text = "Foot";
b = a * 30.48;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Foot"&& comboBox2.Text == "m")
{
label1.Text = "Foot";
b = a * 0.3048;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "inch")
{
label1.Text = "Foot";
b = a * 12;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "foot")
{
label1.Text = "Foot";
b = a;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "mm")
{
label1.Text = "Kilometer";
b = a * 1000000;
label2.Text = "Milimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "cm")
{
label1.Text = "Kilometer";
b = a * 100000;
label2.Text = "Centimeter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "m")
{
label1.Text = "Kilometer";
b = a * 1000;
label2.Text = "Meter";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "inch")
{
label1.Text = "Kilometer";
b = a * 39370.1;
label2.Text = "Inch";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "Km"&& comboBox2.Text == "foot")
{
label1.Text = "Kilometer";
b = a * 3280.84;
label2.Text = "Foot";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "mm"&& comboBox2.Text == "Km")
{
label1.Text = "Milimeter";
b = a * 0.000001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "cm"&& comboBox2.Text == "Km")
{
label1.Text = "Centimeter";
b = a * 0.00001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "m"&& comboBox2.Text == "Km")
{
label1.Text = "Meter";
b = a * 0.001;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "inch"&& comboBox2.Text == "Km")
{
label1.Text = "Inch";
b = a * 0.00254;
label2.Text = "Kilometer";
textBox2.Text = b.ToString();
}
elseif (comboBox1.Text == "foot"&& comboBox2.Text == "Km")
{
label1.Text = "Foot";
b = a * 0.0003048;
label2.Text = "Km";
textBox2.Text = b.ToString();
}}
b)Design Temperature Converter in Windows Mobile.
To convert given temperature in Celsius
To convert given temperature in Fahrenheit
Temperature converter
privatevoid button1_Click(object sender, EventArgs e)
{
int a = int.Parse(textBox1.Text);
if (radioButton1.Checked == true)
{
int c = a * 9 / 5 + 32;
textBox2.Text = c.ToString()+" F";
}
if (radioButton2.Checked == true)
{
int c = (a - 32) * 5 / 9;
textBox2.Text = c.ToString()+" C";
}
}
Practical No.5
Aim: Design Standard Calculator in Windows Mobile.
1)To create new project
File>>New Project
2)Select Programming language
3)Edit Project name
4)Select Device application
5)Drag Controls as per need
Add Text boxes
Note-Add three text boxes and name it as txt_fn(For first number),txt_sn(For second number) and
txt_opr(For operator).Keep txt_fn and txt_opr text boxes disabled(or Enbled = False) so user cant edit
it.
Add Button & edit Properties
6)Double Click on button & add code
Code for button 1 Click:
privatevoid btn_1_Click(object sender, EventArgs e)
{
txt_sn.Text = txt_sn.Text + "1";
}
Code for button 2 Click:
privatevoid button1_Click(object sender, EventArgs e)
{
txt_sn.Text = txt_sn.Text + "2";
}
Note - Repeat Steps for 0 to 9 buttons click.
Add button Click:
privatevoid btn_add_Click(object sender, EventArgs e)
{
try
{
txt_fn.Text = txt_sn.Text;
txt_sn.Text = null;
txt_opr.Text = "+";
}
catch (Exception er)
{ //cler all text boxes if error occured
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
Substraction button Click:
privatevoid btn_sub_Click(object sender, EventArgs e)
{
try
{
txt_fn.Text = txt_sn.Text;
txt_sn.Text = null;
txt_opr.Text = "-";
}
catch (Exception er)
{ //cler all text boxes if error occured
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
Multiplication button Click:
privatevoid btn_mul_Click(object sender, EventArgs e)
{
try
{
txt_fn.Text = txt_sn.Text;
txt_sn.Text = null;
txt_opr.Text = "*";
}
catch (Exception er)
{ //cler all text boxes if error occured
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
Division button Click:
privatevoid btn_div_Click(object sender, EventArgs e)
{
try
{
txt_fn.Text = txt_sn.Text;
txt_sn.Text = null;
txt_opr.Text = "/";
}
catch (Exception er)
{ //cler all text boxes if error occured
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
Answer Button Click:
privatevoid btn_ans_Click(object sender, EventArgs e)
{
try
{
double a, b, ans;
if (txt_opr.Text.Equals("+"))
{
a = Convert.ToDouble(txt_fn.Text);
b = Convert.ToDouble(txt_sn.Text);
ans = a + b;
txt_sn.Text = ans.ToString();
txt_opr.Text = null;
txt_fn.Text = null;
}
elseif (txt_opr.Text.Equals("-"))
{
a = Convert.ToDouble(txt_fn.Text);
b = Convert.ToDouble(txt_sn.Text);
ans = a - b;
txt_sn.Text = ans.ToString();
txt_opr.Text = null;
txt_fn.Text = null;
}
elseif (txt_opr.Text.Equals("/"))
{
a = Convert.ToDouble(txt_fn.Text);
b = Convert.ToDouble(txt_sn.Text);
ans = a / b;
txt_sn.Text = ans.ToString();
txt_opr.Text = null;
txt_fn.Text = null;
}
elseif (txt_opr.Text.Equals("*"))
{
a = Convert.ToDouble(txt_fn.Text);
b = Convert.ToDouble(txt_sn.Text);
ans = a * b;
txt_sn.Text = ans.ToString();
txt_opr.Text = null;
txt_fn.Text = null;
}
else
{
}
}
catch (Exception er)
{
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
Clear Button Click:
privatevoid btn_clr_Click(object sender, EventArgs e)
{
//Cler all text fields
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
Negative (-M) button click:
privatevoid btn_negative_Click(object sender, EventArgs e)
{
//To make number negative
try
{
if (txt_sn.Text != null)
{
//if no. exists in text box add negative
//sign before no.
txt_sn.Text = "-" + txt_sn.Text;
}
else
{ //if no. doesnt exist simply add - sign in
//text box
txt_sn.Text = "-";
}
}
catch (Exception er)
{
txt_fn.Text = null;
txt_sn.Text = null;
txt_opr.Text = null;
}
}
7)Start Debugging:
8)Deploy Project:
9)Perform operations
Addition
Note-Entering negative values using “-M” key:
Practical No.6
Aim: Design Graphics(display circle,square,rectangle,etc) Application in
Windows Mobile
Insert one tab control and add tabs from tabPages Property from property window
Change the text property of tab pages and add button in that tabpage also change the name and text
property of button to the desired names
For eg in tab 1 the text of the tabpage is changed to “TEXT” and name of the button is changed to
“btn_text”
Right click on form1 and click view code
Add the following function in class Form1
private void DrawString()
{
System.Drawing.Graphics tabgraphics = tabPage1.CreateGraphics();
string drawString = "Sample Text";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16,
FontStyle.Bold);
System.Drawing.SolidBrush drawBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Black);
float x = 60.0f;
float y = 50.0f;
tabgraphics.DrawString(drawString, drawFont, drawBrush, x, y);
drawFont.Dispose();
drawBrush.Dispose();
tabgraphics.Dispose();
}
Double click on TEXT button of tabPage 1
private void btn_text_Click(object sender, EventArgs e)
{
DrawString();
}
For tabpage 2
Add the following function
private void DrawIt()
{
Pen p = new Pen(Color.Black);
System.Drawing.Graphics tabgraphics1 = tabPage2.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(50, 50,
150, 150);
tabgraphics1.DrawEllipse(p, rectangle);
tabgraphics1.DrawRectangle(p, rectangle);
}
Double click on Draw button
private void btn_ellipse_rectangle_Click(object sender, EventArgs e)
{
DrawIt();
}
For tab page 3
Change the name property
Add the following function in code
Note : commented curve functions are not available in vs2008 if higher version is available then try
it.
private void curves()
{
System.Drawing.Graphics tabgraphics2 = tabPage3.CreateGraphics();
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
// Draw head with an ellipse.
tabgraphics2.DrawEllipse(myPen, 0, 0, 200, 200);
// Draw winking eye with an arc.
// tabGraphics2.DrawArc(myPen, 40, 40, 40, 40, 180, -180);
// Draw open eye with an ellipse.
tabgraphics2.DrawEllipse(myPen, 120, 40, 40, 40);
tabgraphics2.DrawEllipse(myPen, 40, 40, 40, 40);
// Draw nose with a Bezier spline.
//tabGraphics2.DrawBezier(myPen, 100, 60, 120, 100, 90, 120, 80, 100);
// Draw mouth with a canonical spline.
Point[] apt = new Point[4];
apt[0] = new Point(60, 140);
apt[1] = new Point(140, 150);
apt[2] = new Point(100, 180);
apt[3] = new Point(60, 140);
// tabGraphics2.DrawCurve(myPen, apt, 0, 3, 0.9f);
tabgraphics2.DrawPolygon(myPen, apt);
}
Double click on Draw curve and polygon button
private void curve_polygon_Click(object sender, EventArgs e)
{
curves();
}
For tab page 4
Add the following function in code for lines
private void lines()
{
Pen p = new Pen(Color.BlueViolet);
System.Drawing.Graphics tabgraphics3 = tabpage4.CreateGraphics();
for (int i = 100; i > 10;i-=5 )
{
tabgraphics3.DrawLine(p, 50,100, i,i);
}
Point[] apt1 = new Point[4];
apt1[0] = new Point(60, 140);
apt1[1] = new Point(140, 150);
apt1[2] = new Point(100, 180);
apt1[3] = new Point(60, 140);
tabgraphics3.DrawLines(p, apt1);
}
Double click on Draw Line button
private void btn_line_Click(object sender, EventArgs e)
{
lines();
}
For tab page 5
Add the following function in code
private void fill_shapes()
{
///////////filled ellipse//////////////////
System.Drawing.SolidBrush brush1 = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics tabGraphics =
tabPage5.CreateGraphics();
tabGraphics.FillEllipse(brush1, new
System.Drawing.Rectangle(50, 50, 75, 30));
brush1.Dispose();
///////////filled rectangle//////////////////
System.Drawing.SolidBrush brush2 = new
System.Drawing.SolidBrush(System.Drawing.Color.Blue);
System.Drawing.Graphics tabGraphics1 =
tabPage5.CreateGraphics();
tabGraphics1.FillRectangle(brush2, new
System.Drawing.Rectangle(150, 150, 100, 150));
brush2.Dispose();
tabGraphics1.Dispose();
////////////////////polygon////////////////////
Point[] apt1 = new Point[4];
apt1[0] = new Point(60, 140);
apt1[1] = new Point(140, 150);
apt1[2] = new Point(100, 180);
apt1[3] = new Point(60, 140);
System.Drawing.SolidBrush brush3 = new
System.Drawing.SolidBrush(System.Drawing.Color.Gold);
System.Drawing.Graphics tabGraphics2 =
tabPage5.CreateGraphics();
tabGraphics2.FillPolygon(brush3,apt1);
brush1.Dispose();
tabGraphics.Dispose();
}
Double click on fill button
private void btn_fill_Click(object sender, EventArgs e)
{
fill_shapes();
}
Click on start debugging button
Click on Deploy button
Practical No.7
Aim:Design Link Navigation Application in Android/Windows Mobile.
1)To create new project
File>>New Project
2)Select Programming language
3)Edit Project name
4)Select Device application
5)Add Controls(tabcontrol,text box and button)
6)Double click on search button and write following code
privatevoid search_Click(object sender, EventArgs e)
{
WebBrowser wb = newWebBrowser();
if (tabControl1.SelectedIndex == 0)
{
tabPage1.Controls.Add(wb);
wb.Dock = DockStyle.Fill;
System.Uri adr = newUri("http://" + txt_adr.Text + "/");
wb.Navigate(adr);
try
{
tabPage1.Text = wb.Url.Host.ToString();
}
catch (Exception er)
{
tabPage1.Text = "Error";
System.Uri adr1 =
newUri(@"file://\Windows\default.htm");
wb.Navigate(adr1);
}
}
elseif (tabControl1.SelectedIndex == 1)
{
tabPage2.Controls.Add(wb);
wb.Dock = DockStyle.Fill;
System.Uri adr = newUri("http://" + txt_adr.Text+"/");
wb.Navigate(adr);
try
{
tabPage2.Text = wb.Url.Host.ToString();
}
catch (Exception er)
{
tabPage2.Text = "Error";
System.Uri adr1 =
newUri(@"file://\Windows\default.htm");
wb.Navigate(adr1);
}
}
else
{
}
}
7)Codefor navigatingbrowser to url on pressing enter key
privatevoid enter_key_press(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
WebBrowser wb = newWebBrowser();
if (tabControl1.SelectedIndex == 0)
{
tabPage1.Controls.Add(wb);
wb.Dock = DockStyle.Fill;
System.Uri adr = newUri("http://" + txt_adr.Text +
"/");
wb.Navigate(adr);
try
{
tabPage1.Text = wb.Url.Host.ToString();
}
catch (Exception er)
{
tabPage1.Text = "Error";
System.Uri adr1 =
newUri(@"file://\Windows\default.htm");
wb.Navigate(adr1);
}
}
elseif (tabControl1.SelectedIndex == 1)
{
tabPage2.Controls.Add(wb);
wb.Dock = DockStyle.Fill;
System.Uri adr = newUri("http://" + txt_adr.Text +
"/");
wb.Navigate(adr);
try
{
tabPage2.Text = wb.Url.Host.ToString();
}
catch (Exception er)
{
tabPage2.Text = "Error";
System.Uri adr1 =
newUri(@"file://\Windows\default.htm");
wb.Navigate(adr1);
}
}
else
{
}
}
}
8)Output Window
Note-Here since we don’t have internet connectivity ,it will navigate to default page.
Practical No.8
Aim:Quiz program in windows mobile
Step1 : create new project :
Step2: Edit Project Name:
On click of submit button
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true && radioButton3.Checked ==
true && radioButton5.Checked == true)
{
MessageBox.Show("Your Score is: 3");
}
if (radioButton1.Checked == true && radioButton3.Checked ==
true && radioButton5.Checked == false)
{
MessageBox.Show("Your Score is: 2");
}
if (radioButton1.Checked == true && radioButton3.Checked ==
false && radioButton5.Checked == false)
{
MessageBox.Show("Your Score is: 1");
}
if (radioButton1.Checked == false && radioButton3.Checked ==
false && radioButton5.Checked == false)
{
MessageBox.Show("Your Score is: 0");
}
if (radioButton1.Checked == true && radioButton3.Checked ==
false && radioButton5.Checked == true)
{
MessageBox.Show("Your Score is: 2");
}
if (radioButton1.Checked == false && radioButton3.Checked ==
true && radioButton5.Checked == true)
{
MessageBox.Show("Your Score is: 2");
}
if (radioButton1.Checked == false && radioButton3.Checked ==
false && radioButton5.Checked == true)
{
MessageBox.Show("Your Score is: 1");
}
}
Practical No.9
Aim: EMI & BMI Application in window Mobile.
1)To create new project
File>>New Project
2)Select Programming language
3)Edit project name
4)Select Device application
5)Design application as shown below
(Note-Add both text boxes and calculate button on panal)
6)Double click on Calculate button and write code
privatevoid btn_clt_Click(object sender, EventArgs e)
{
panel1.Visible = false;
lbl_rslt.Visible = true;
lnlbl_try.Visible = true;
double a, b, ans;
a = Convert.ToDouble(txt_wt.Text);
b = Convert.ToDouble(txt_ht.Text);
b = b / 100;
b = b * b;
ans = a / b;
if (ans >= 0 && ans <= 18)
{
lbl_rslt.Text = "Slim !!!";
}
elseif (ans >18 && ans <= 25)
{
lbl_rslt.Text = "Fit !!!";
}
else
{
lbl_rslt.Text = "Fat !!!";
}
}
7)Double click on “try again…” link button and type code
privatevoid linkLabel1_Click(object sender, EventArgs e)
{
panel1.Visible = true;
lbl_rslt.Visible = false;
lnlbl_try.Visible = false;
txt_ht.Text = null;
txt_wt.Text = null;
}
8)Output Window
To Calculate EMI :
Design the form as following
To calculate emi :double click on button1 and add the following code
privatevoid button1_Click(object sender, EventArgs e)
{
double p, r, sI,n;
if(comboBox1.Text=="6 months")
{
n = 6;
p = double.Parse(textBox1.Text);
r = 9.25;
sI = p * n * r / 100;
textBox2.Text = sI.ToString();
}
elseif (comboBox1.Text == "1 year")
{
n = 12;
p = double.Parse(textBox1.Text);
r = 9.25;
sI = p * n * r / 100;
textBox2.Text = sI.ToString();
}
elseif (comboBox1.Text == "2 year")
{
n = 24;
p = double.Parse(textBox1.Text);
r = 9.25;
sI = p * n * r / 100;
textBox2.Text = sI.ToString();
}
elseif (comboBox1.Text == "3 year")
{
n = 36;
p = double.Parse(textBox1.Text);
r = 9.25;
sI = p * n * r / 100;
textBox2.Text = sI.ToString();
}
}
Practical No.10
Aim:Design Image Dropdown List in Windows Mobile.
1) Create new project
2) Edit Project name
3) Select Device application
4) Insert one combobox , panel and one web browser tool in panel as shown below
5) Add one event in the combobox events as shown
6) And type the following code in the event created
private void imgchanged(object sender, EventArgs e)
{
System.Uri imgpath = new Uri(@"file://\My Documents\My Pictures\" +
cmb_image.SelectedItem.ToString() + ".jpg");
wb.Navigate(imgpath);
}
7) And deploy the project