using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace MathsOperators
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary> public partial class MainWindow : Window
{ public MainWindow()
{
InitializeComponent();
} private void calculateClick(object sender, RoutedEventArgs e)
{
try
{
if ((bool)addition.IsChecked)
addValues();
else if ((bool)subtraction.IsChecked)
subtractValues();
else if ((bool)multiplication.IsChecked)
multiplyValues();
else if ((bool)division.IsChecked)
divideValues();
else if ((bool)remainder.IsChecked)
remainderValues();
}
catch (Exception caught)
{
expression.Text = "";
result.Text = caught.Message;
}
} private void addValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs + rhs;
expression.Text = lhsOperand.Text + " + " + rhsOperand.Text;
result.Text = outcome.ToString();
} private void subtractValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs - rhs;
expression.Text = lhsOperand.Text + " - " + rhsOperand.Text;
result.Text = outcome.ToString();
} private void multiplyValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs * rhs;
expression.Text = lhsOperand.Text + " * " + rhsOperand.Text;
result.Text = outcome.ToString();
} private void divideValues()
{
float lhs = float.Parse(lhsOperand.Text);
float rhs = float.Parse(rhsOperand.Text);
float outcome;
outcome = lhs / rhs;
expression.Text = lhsOperand.Text + " / " + rhsOperand.Text;
result.Text = outcome.ToString();
} private void remainderValues()
{
float lhs = float.Parse(lhsOperand.Text);
float rhs = float.Parse(rhsOperand.Text);
float outcome;
outcome = lhs % rhs;
expression.Text = lhsOperand.Text + " % " + rhsOperand.Text;
result.Text = outcome.ToString();
} private void quitClick(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

c# radiobutton的更多相关文章

  1. RadioButton与CheckBox

    笔者长期从事于数据库的开发,算了,不提当年了,因为一直用的是小语种(PowerBuilder),还是来说说这两个最常见的控件吧! RadioButton(单选)和CheckBox(多选) 先来看看继承 ...

  2. 【WPF】值是枚举的RadioButton 绑定问题

    源 1.RadioButton 2.IValueConverter 3.枚举 xaml实现 <RadioButton Content="单打热身" GroupName=&qu ...

  3. Android RadioGroup和RadioButton详解

    实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGrou ...

  4. react native RadioButton(单选按钮)

    刚刚写完这个多选按钮,我觉得没有单选的话,总会觉得有一点点不爽,因为在项目中我也没有用到单选,所以我没有好好研究源码,所以我在Github上找了一下,发现有一个挺好的,简单,不花哨. 在Github上 ...

  5. RadioButton(单选按钮)文字在按钮的左边

    <RadioButton style="@style/CustomCheckboxTheme" android:layout_width="fill_parent& ...

  6. RadioGroup、RadioButton、CheckBox、Toast用法

    xml布局文件如下: <RadioGroup android:id="@+id/sex" android:layout_width="wrap_content&qu ...

  7. 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch

    [源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...

  8. 转 Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  9. WPF中RadioButton绑定数据的正确方法

    RadioButton一般用于单选的时候,也就是从一组值中选择一个值. 比如性别有“男”和“女”两种取值,而对于一个员工的实例来说,性别的取值要么是男,要么是女. 这种时候一般就会用到RadioBut ...

  10. Android-组件RadioButton使用技巧

    当初第一次接触Android组件的时候,我感觉微信底部的菜单,是用button这样的组件来做的. 可我想错了.却是用RadioButton来做的.那到底怎么做,接下来我就做一下分享!希望看了之后你也觉 ...

随机推荐

  1. swift4.2 - 距离传感器

    import UIKit class ViewController: UIViewController { deinit { NotificationCenter.default.removeObse ...

  2. Linux系统声卡问题

    问题:Linux系统中有声卡设备,但是听不到声音 一.声卡驱动没有安装 1.通过插拔声卡查出声卡驱动 2.在相应的kernel中编译内核 修改保存.config文件,然后进行编译 make -j ma ...

  3. 谷歌开发的draco格式文件将obj文件压缩成drc文件后将大大减小文件大小(threejs加载有mtl文件的drc文件)

    问题描述:当前threejs是92版本 但是当前版本还没有能够直接加载带贴图文件的drc格式的loader: 解决办法:先加载mtl文件将obj文件分解(按照mtl文件内材质贴图信息进行分解)再将分解 ...

  4. 扩展、委托、Lambda、linq

    1.扩展 扩展是一个很有用的功能.如果你有一个类.不能修改,同时你又想给他加一个方法.这个过程就是扩展.扩展就是扩展方法. 例1: 类People public class People { publ ...

  5. CSS学习总结3:CSS定位

    CSS 定位机制 CSS 有三种基本的定位机制:普通流.浮动和绝对定位. 一.普通流 除非专门指定,否则所有框都在普通流中定位.普通流中元素框的位置由元素在(X)HTML中的位置决定.块级元素从上到下 ...

  6. windows2003两台服务器,局域网之间不能互相访问

    准备在两台服务器之间,映射网络驱动器,但怎么也连不上了. 可以在网络邻居中看到对方的机器,但就是访问不到共享的文件,也无法做网络映射. 搜索了一下,发现在是因为防火墙中,没有把"文件和打印机 ...

  7. 肤色检测一例-使用rgb颜色模型

    代码: /* 输入:rgb图像 输出:与输入图像尺寸相同的灰度图,若rgb图中某像素检测为肤色,则灰度图中对应像素为255,否则为0 */ void SkinRGB( Mat &rgb,Mat ...

  8. Android.Tools.Summary

    Android平台上工具的总结 每个工具的详细使用和深入理解参考每个工具相关的blog. 1. Android SDK中提供的工具 http://developer.android.com/tools ...

  9. Unknown type name 'NSString' 解决方案

    今天看到个问题,编辑工程提示Unknown type name 'NSString',如下图 导致出现异常的原因是是因为工程中添加了ZipArchive(第三方开源解压缩库) 一般情况下出现“Unkn ...

  10. tableView中cell的复用机制

    TableView的重用机制,为了做到显示和数据分离,IOS tableView的实现并且不是为每个数据项创建一个tableCell.而是只创建屏幕可显示最大个数的cell,然后重复使用这些cell, ...