Thursday, December 8, 2011

Kanaku – The Simple Calculator for Windows Phone 7

For sometime now, I’ve been intrigued on developing apps for Mobile devices and platforms. Sure enough, most of the devices right now, run either Android or iOS. Windows Phone 7 platform is slowly gaining momentum, with big break coming from Nokia’s Deal with Microsoft to produce Win 7 phones from now on.

The following is a simple calculator with text boxes and buttons that runs on Win 7 Phone Platform. Designed exclusively for those running v7.1 and above and supports Metro UI.

Source Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace calculator
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            int x = Convert.ToInt32(tb1.Text);
            int y = Convert.ToInt32(tb2.Text);
            int z = x + y;
            tb3.Text = Convert.ToString(z);
        }
       
        private void button2_Click(object sender, RoutedEventArgs e)
        {
             int x = Convert.ToInt32(tb1.Text);
            int y = Convert.ToInt32(tb2.Text);
            int z = x - y;
            tb3.Text = Convert.ToString(z);
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
             int x = Convert.ToInt32(tb1.Text);
            int y = Convert.ToInt32(tb2.Text);
            int z = x * y;
            tb3.Text = Convert.ToString(z);
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            int x = Convert.ToInt32(tb1.Text);
            int y = Convert.ToInt32(tb2.Text);
            int z = x / y;
            tb3.Text = Convert.ToString(z);
        }
    }

}

Download

The project is hosted at codeplex.com and can be found at http://kanaku.codeplex.com.

No comments: