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. 解决phpcms图片太大撑破表格图片自适应图片按比例缩小

    img,a img{ border:0; margin:0; padding:0; max-width:590px; width:expression(this.width590?590px:this ...

  2. winform之回车执行某个按钮 以及Esc执行某个按钮

    在winform中,我们在登陆的时候,需要点击回车键,就执行登陆,点击Esc键就执行取消,那么最方便的方法就是利用AcceptButton和CancelButton这两个属性(它属于窗体属性). 如图 ...

  3. 原生jdbc执行存储过程

    //定时任务,结转 . //表名 fys_sch_lvyou2 ,存储过程名:fys_sch_lvyou2_carrayover //无参调用:{call insertLine} //有参调用:{ca ...

  4. 微软TTS尝试系列之开篇杂谈(仅思路)

    第一次写博客,不知道如何下手,思路也乱,就先聊聊怎么进的园子吧,但愿不会浪费大家太多的宝贵时间>_<. 与博客园结缘应该是大三刚开始的时候.当时学校教务处想开发一个教务安排系统,为了省钱就 ...

  5. jpg图片在IE6、IE7和IE8下不显示解决办法

    坑人的IE浏览器,花了我一个小时才找到原因. 原因:IE内核不能渲染CMYK模式的jpg图片,需要转换为RGB模式. 在photoshop里点击菜单栏—图像—RGB模式就行了 引用:http://lg ...

  6. Android---WebView显示Html乱码问题

    webView.loadData(result,"text/html","UTF-8"); 反正是用上面的方法无法解决乱码的问题. 使用下面的方法就能完美解决了 ...

  7. poj 1459 Power Network

    题目连接 http://poj.org/problem?id=1459 Power Network Description A power network consists of nodes (pow ...

  8. NFC应用实例

    package com.example.mynfcdemon; import android.app.Activity;import android.nfc.NfcAdapter;import and ...

  9. 常用gradle命令

    1.build.gradle ext { profile = "dev" tag='web' if (project.hasProperty('pro')) { temp = pr ...

  10. .NET基础:修饰符

    访问修饰符 软道语录定义: 访问修饰符就是类,属性和方法的电影分级制度 . public:访问不受限制. protected:访问仅限于包含类或从包含类派生的类型.只有包含该成员的类以及继承的类可以存 ...