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;
using System.IO;
namespace 老陈Wpf
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public static int Count = 0;
public static int right = 0;
int m = 0; private void button1_Click(object sender, RoutedEventArgs e)
{
StreamWriter n1 = File.AppendText("C:\\n1.txt");
n1.WriteLine(textBox1.Text);
n1.Close();
StreamWriter n2 = File.AppendText("C:\\n2.txt");
n2.WriteLine(textBox2.Text);
n2.Close();
StreamWriter n3 = File.AppendText("C:\\n3.txt");
n3.WriteLine(textBox3.Text);
n3.Close();
MessageBox.Show("录题成功");
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
} private void button2_Click(object sender, RoutedEventArgs e)
{
//出题
string[] n1 = new string[100];
n1 = File.ReadAllLines("C:\\n1.txt");
textBox1.Text = n1[m];
string[] n2 = new string[100];
n2 = File.ReadAllLines("C:\\n2.txt");
textBox2.Text = n2[m];
string[] n3 = new string[100];
n3 = File.ReadAllLines("C:\\n3.txt");
textBox3.Text = n3[m];
m++;
}
//结束
private void button3_Click(object sender, RoutedEventArgs e)
{
textBox5.Text = MainWindow.Count.ToString();//题目总数
textBox6.Text = MainWindow.right.ToString();
textBox7.Text = ((MainWindow.right / (double)(MainWindow.Count)) * 100).ToString() + "%";//正确率
} private void textBox4_KeyDown(object sender, KeyEventArgs e)
{
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox3.Text);
Char c = Convert.ToChar(textBox2.Text);
Class1 con = new Class1();
con.chu(a, b, c);
if (e.Key == Key.Enter)
{ if (con.answer == int.Parse(textBox4.Text))
{
MessageBox.Show("回答正确!下一题请按开始按钮!");
right++;
Count++;
} else
{ MessageBox.Show("回答错误!下一题请按开始按钮!");
Count++; }
textBox4.Clear();
}
} private void button1_Click_1(object sender, RoutedEventArgs e)
{
StreamWriter n1 = File.AppendText("C:\\n1.txt");
n1.WriteLine(textBox1.Text);
n1.Close();
StreamWriter n2 = File.AppendText("C:\\n2.txt");
n2.WriteLine(textBox2.Text);
n2.Close();
StreamWriter n3 = File.AppendText("C:\\n3.txt");
n3.WriteLine(textBox3.Text);
n3.Close();
MessageBox.Show("录题成功");
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}

 封装

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 老陈Wpf
{
class Class1
{
public int sum;
public int answer
{
get
{
return sum;
}
} public int chu(int n1, int n2, char fuhao)
{
if (fuhao == '+')
{
return sum = n1 + n2;
}
else if (fuhao == '-')
{
return sum = n1 - n2;
}
else if (fuhao == '*')
{
return sum = n1 * n2;
}
return sum; }
}
}

  运行的界面如下:

老陈 WPF的更多相关文章

  1. (l老陈-小石头)典型用户、用户故事、用例图

    一.典型用户 老陈 小石头 二.用户故事 老陈:作为一个家长,我希望能利用软件在电脑上储存一些数学题目,以便在繁忙的工作中也能帮助到孩子提高数学. 小石头:作为一个小学二年级的小学生,我希望能利用软件 ...

  2. 老陈---谈Delphi中SSL协议的应用[转]

    摘要:本文主要介绍如何在Delphi中使用SSL协议.一共分为七个部分:(1)SSL协议是什么?(2)Delphi中如何使用SSL协议?(3)SSL客户端编程实例.(4)SSL服务端编程实例.(5)S ...

  3. 老陈 ASP.NET封装

    第一个页面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...

  4. WPF 策略模式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  5. [WPF]为旧版本的应用添加触控支持

    之前做WPF开发时曾经遇到这样一个需求:为一个基于 .NET Framework 3.5开发的老旧WPF程序添加触控支持,以便于大屏触控展示. 接手之后发现这是一个大坑. 项目最初的时候完全没考虑过软 ...

  6. 無間道III 終極無間

    凭良心说,它绝对算是诚意之作,而非急功近利或者说抢市.因为导演尤其是编剧都用了心,为了和第一二集融合而在细节处理上做足了文章,麦兆辉也实在够天才. 关于时间问题,本片不是完全杂乱无章,只不过是前后两段 ...

  7. 匿名对象 构造方法 重载 构造代码块 this 关键字

    一.匿名对象 1.匿名对象 :没有名字对象 2.匿名对象的使用注意点: 1.我们一般不会用匿名对象给属性赋值,无法获取属性值. 2.匿名对象永远都不可能事一个对象. 3.匿名对象的好处 : 书写简单. ...

  8. 关于 Poco::TCPServer框架 (windows 下使用的是 select模型) 学习笔记.

    说明 为何要写这篇文章 ,之前看过阿二的梦想船的<Poco::TCPServer框架解析> http://www.cppblog.com/richbirdandy/archive/2010 ...

  9. 一个基于POP3协议进行邮箱账号验证的类

    最近老陈要针对企业邮箱做一些开发,以对接企业OA神马的,但企业邮箱唯独没有开放账号密码验证功能,很恼火!不得已,翻出早些年的Asp代码改编成了C#类,实现了一个C#下的通过POP3协议进行邮箱账号验证 ...

随机推荐

  1. 微软ASP.NET MVC 学习地址

    微软ASP.NET MVC4.0学习地址:http://www.asp.net/mvc

  2. Vue.js学习 Item4 -- 数据双向绑定

    Vue.js 的模板是基于 DOM 实现的.这意味着所有的 Vue.js 模板都是可解析的有效的 HTML,且通过一些特殊的特性做了增强.Vue 模板因而从根本上不同于基于字符串的模板,请记住这点. ...

  3. iostat命令简单说说

    tps: 每秒钟发送到的I/O请求数. Blk_read /s: 每秒读取的block数 Blk_wrtn/s: 每秒写入的block数 Blk_read: 读入的block总数 Blk_wrtn: ...

  4. PHP-PCRE正则表达式函数

    PCRE正则表达式函数 PCRE字符类 \\b        词边界 \\d        匹配任意数字 \\s        匹配任意空白,如TAB制表符或空格 \\t        匹配一个TAB ...

  5. Python pass 语句使用示例

    Python pass 语句的使用方法示例.Python pass是空语句,pass语句什么也不做,一般作为占位符或者创建占位程序,是为了保持程序结构的完整性,pass语句不会执行任何操作,比如: P ...

  6. Decorator模式

    Decorator模式能够像标准的继承一样为类添加新的功能. 不同于标准继承机制的是,如果对象进行了实例化,Decorator模式能够在运行时动态地为对象添加新的功能. <?php abstra ...

  7. 电商、商城类APP常用标签"hot"--第三方开源--LabelView

    LabelView是在github上一个开源的标签库.其项目主页是:https://github.com/linger1216//labelview LabelView为一个TextView,Imag ...

  8. MapReduce数据流

    图4.5细节化的Hadoop MapReduce数据流 图4.5展示了流线水中的更多机制.虽然只有2个节点,但相同的流水线可以复制到跨越大量节点的系统上.下去的几个段落会详细讲述MapReduce程序 ...

  9. Servlet之HttpServletResponse和HttpServletRequest

    HttpServletResponse 1.告诉服务器应用使用UTF-8解析文本的两种方式,告诉客户端要使用什么编码 response.setHeader("content-type&quo ...

  10. Python 有哪些优点?为何要学Python?

      1. 支持OOP编程 从根本上讲Python仍是一种面向对象的语言,支持多态.继承等高级概念,在Python里使用OOP十分容易 没有C++.Java那样复杂,但不必做Python下OOp高手,够 ...