WP8简单的计算器
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> <!--TitlePanel 包含应用程序的名称和页标题-->
<StackPanel Grid.Row="" Margin="12,17,0,28">
<TextBlock Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="页面名称" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel> <!--ContentPanel - 在此处放置其他内容-->
<Grid x:Name="ContentPanel" Grid.Row="" Margin="12,0,12,0"> </Grid>
<Grid x:Name="MyGrid" HorizontalAlignment="Left" Height="" Margin="7,0,0,0" Grid.Row="" VerticalAlignment="Top" Width="">
<TextBlock x:Name="InputInformation" HorizontalAlignment="Left" Height="" TextWrapping="Wrap" VerticalAlignment="Top" Width="" FlowDirection="LeftToRight" TextAlignment="Right"/>
<TextBlock x:Name="OperationResult" HorizontalAlignment="Left" Height="" Margin="0,73,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="" FlowDirection="LeftToRight" TextAlignment="Right"/>
<Button x:Name="B0" Content="" HorizontalAlignment="Left" Height="" Margin="19,487,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="Result" Content="=" HorizontalAlignment="Left" Height="" Margin="119,487,0,0" VerticalAlignment="Top" Width="" Click="ResultJG"/>
<Button x:Name="Del" Content="Del" HorizontalAlignment="Left" Height="" Margin="221,487,0,0" VerticalAlignment="Top" Width="" Click="Delclick"/>
<Button x:Name="Divide" Content="/" HorizontalAlignment="Left" Height="" Margin="321,487,0,0" VerticalAlignment="Top" Width="" RenderTransformOrigin="0.5,0.5" Click="YunSuan"/>
<Button x:Name="B1" Content="" HorizontalAlignment="Left" Height="" Margin="19,393,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B2" Content="" HorizontalAlignment="Left" Height="" Margin="119,393,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B3" Content="" HorizontalAlignment="Left" Height="" Margin="221,393,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="Multiply" Content="*" HorizontalAlignment="Left" Height="" Margin="321,393,0,0" VerticalAlignment="Top" Width="" RenderTransformOrigin="0.5,0.5" Click="YunSuan"/>
<Button x:Name="B4" Content="" HorizontalAlignment="Left" Height="" Margin="19,299,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B5" Content="" HorizontalAlignment="Left" Height="" Margin="119,299,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B6" Content="" HorizontalAlignment="Left" Height="" Margin="221,299,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="Minus" Content="-" HorizontalAlignment="Left" Height="" Margin="321,299,0,0" VerticalAlignment="Top" Width="" RenderTransformOrigin="0.5,0.5" Click="YunSuan"/>
<Button x:Name="B7" Content="" HorizontalAlignment="Left" Height="" Margin="19,205,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B8" Content="" HorizontalAlignment="Left" Height="" Margin="119,205,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="B9" Content="" HorizontalAlignment="Left" Height="" Margin="221,205,0,0" VerticalAlignment="Top" Width="" Click="Btn_ButClick"/>
<Button x:Name="Plus" Content="+" HorizontalAlignment="Left" Height="" Margin="321,205,0,0" VerticalAlignment="Top" Width="" RenderTransformOrigin="0.5,0.5" Click="YunSuan"/>
</Grid>
</Grid>
namespace PhoneApp1
{
public partial class Calculator : PhoneApplicationPage
{
public string Operation = "";//记录一下之前一次按下的运算符
public double Num = ;//结果
public Calculator()
{
InitializeComponent();
} private void Btn_ButClick(object sender, RoutedEventArgs e)
{
if (Operation == "=")
{
OperationResult.Text = "";
InputInformation.Text = "";
Num = ;
}
string s = (sender as Button).Content.ToString();
OperationResult.Text = OperationResult.Text + s;
InputInformation.Text = InputInformation.Text + s;
} private void YunSuan(object sender, RoutedEventArgs e)
{
string fh= (sender as Button).Content.ToString();
OperationNum(fh);
InputInformation.Text = InputInformation.Text + fh;
OperationResult.Text = "" ;
} private void OperationNum(string fh)
{
if (OperationResult.Text != "")
{ if (Operation == "+")
{
Num = Num +double.Parse( OperationResult.Text.ToString());
Operation = fh;
}
else if (Operation == "-")
{
Num = Num - double.Parse(OperationResult.Text.ToString());
Operation = fh;
}
else if (Operation == "*")
{
Num = Num * double.Parse(OperationResult.Text.ToString());
Operation = fh;
}
else if (Operation == "/")
{
if (double.Parse(OperationResult.Text.ToString()) != )
Num = Num / double.Parse(OperationResult.Text.ToString());
else
Num = ;
Operation = fh;
}
else//(Operation=="" || Operation="=")
{
Num = double.Parse(OperationResult.Text.ToString());
Operation = fh;
}
}
} private void ResultJG(object sender, RoutedEventArgs e)
{
OperationNum("=");
OperationResult.Text = Num.ToString();
} private void Delclick(object sender, RoutedEventArgs e)
{
OperationResult.Text ="";
InputInformation.Text = "";
Num = ;
}
}
}
WP8简单的计算器的更多相关文章
- js制作简单的计算器
学着做了一个简单的计算器!记录记录!哈哈 <!DOCTYPE html> <html> <head> <title>简单的计算器</title&g ...
- 留念 C语言第一课简单的计算器制作
留念 C语言第一课简单的计算器制作 学C语言这么久了. /* 留念 C语言第一课简单的计算器制作 */ #include<stdio.h> #include<stdlib.h ...
- jsp学习---使用jsp和JavaBean实现超简单网页计算器
一.需求 如题,用jsp实现一个超简单的网页计算器. 二.实现 1.效果图 1)初始界面: 2)随便输入两个数进行相乘: 3)当除数为零时提示报错: 2.代码 Calculator.java pack ...
- JS实现一个简单的计算器
使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除.效果如上: 第一步: 创建构建运算函数count(). 第二步: 获取两个输入框中的值和获取选择 ...
- javascript 简单的计算器
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...
- 教学项目之-通过Python实现简单的计算器
教学项目之-通过Python实现简单的计算器 计算器开发需求 实现加减乘除及拓号优先级解析 用户输入 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/ ...
- HDU1237 简单的计算器 【堆】+【逆波兰式】
简单的计算器 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- 使用qt制作一个简单的计算器
前言:今天使用qt制作了一个很简单的计算器,觉得挺有意思的,所以在这里跟大家分享一下. 这里先跟大家说说使用到的函数: 一.槽连接函数 connect(信号发送者,发送的信号,信号接收者,信号接收者的 ...
- 从0到1:使用Caliburn.Micro(WPF和MVVM)开发简单的计算器
从0到1:使用Caliburn.Micro(WPF和MVVM)开发简单的计算器 之前时间一直在使用Caliburn.Micro这种应用了MVVM模式的WPF框架做开发,是时候总结一下了. Calibu ...
随机推荐
- Linux环境安装python3
linux 安装Python3 1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Pyt ...
- scrapy中Selector的使用
scrapy的Selector选择器其实也可以用来解析,今天主要总结下css和xpath的用法,其实我个人最喜欢用css 以慕课网嵩天老师教程中的一个网页为例,python123.io/ws/demo ...
- 暴力 【p4098】[HEOI2013]ALO
Description Welcome to ALO ( Arithmetic and Logistic Online).这是一个 VR MMORPG, 如名字所见,到处充满了数学的谜题 现在你拥有 ...
- Linux命令之last
last [-num | -n num] [-f file] [-t YYYYMMDDHHMMSS] [-R] [-adioxFw] [username..] [tty..] last作用是显示近期用 ...
- 28、Django实战第28天:个人信息展示
从今天开始,我来完成个人中心部分,前端页面如下 1.浏览这些页面可以发现,它们和base.html是有区别的,因此,它们需要新建一个模板usercenter-base.html 2.把usercent ...
- Linq 透明标识符 let
IEnumerable<Person> list = new List<Person> { , Id = }, , Id = }, , Id = }, , Id = }, , ...
- 【找规律】URAL - 2065 - Different Sums
就让0出现得尽可能多嘛……大概感受一下就是这样…… 0 0 ... 0 0 0 0 4 -4 3 -3 2 -2 1 -1 #include<cstdio> using namespace ...
- 美团在Redis上踩过的一些坑-3.redis内存占用飙升(转载)
一.现象: redis-cluster某个分片内存飙升,明显比其他分片高很多,而且持续增长.并且主从的内存使用量并不一致. 二.分析可能原因: 1. redis-cluster的bu ...
- 移除tabBar 重影
-(void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; for (UIView *child in self.tabBar.sub ...
- Delphi Thread
Thread给几点说明:1.MyThread的实例作为TForm1的成员变量2.不要使用Form1这个全局变量,线程中可要使用它的Handle,你可以在Form中创建MyThread的实例时把Hand ...