老陈 WPF
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的更多相关文章
- (l老陈-小石头)典型用户、用户故事、用例图
一.典型用户 老陈 小石头 二.用户故事 老陈:作为一个家长,我希望能利用软件在电脑上储存一些数学题目,以便在繁忙的工作中也能帮助到孩子提高数学. 小石头:作为一个小学二年级的小学生,我希望能利用软件 ...
- 老陈---谈Delphi中SSL协议的应用[转]
摘要:本文主要介绍如何在Delphi中使用SSL协议.一共分为七个部分:(1)SSL协议是什么?(2)Delphi中如何使用SSL协议?(3)SSL客户端编程实例.(4)SSL服务端编程实例.(5)S ...
- 老陈 ASP.NET封装
第一个页面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...
- WPF 策略模式
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- [WPF]为旧版本的应用添加触控支持
之前做WPF开发时曾经遇到这样一个需求:为一个基于 .NET Framework 3.5开发的老旧WPF程序添加触控支持,以便于大屏触控展示. 接手之后发现这是一个大坑. 项目最初的时候完全没考虑过软 ...
- 無間道III 終極無間
凭良心说,它绝对算是诚意之作,而非急功近利或者说抢市.因为导演尤其是编剧都用了心,为了和第一二集融合而在细节处理上做足了文章,麦兆辉也实在够天才. 关于时间问题,本片不是完全杂乱无章,只不过是前后两段 ...
- 匿名对象 构造方法 重载 构造代码块 this 关键字
一.匿名对象 1.匿名对象 :没有名字对象 2.匿名对象的使用注意点: 1.我们一般不会用匿名对象给属性赋值,无法获取属性值. 2.匿名对象永远都不可能事一个对象. 3.匿名对象的好处 : 书写简单. ...
- 关于 Poco::TCPServer框架 (windows 下使用的是 select模型) 学习笔记.
说明 为何要写这篇文章 ,之前看过阿二的梦想船的<Poco::TCPServer框架解析> http://www.cppblog.com/richbirdandy/archive/2010 ...
- 一个基于POP3协议进行邮箱账号验证的类
最近老陈要针对企业邮箱做一些开发,以对接企业OA神马的,但企业邮箱唯独没有开放账号密码验证功能,很恼火!不得已,翻出早些年的Asp代码改编成了C#类,实现了一个C#下的通过POP3协议进行邮箱账号验证 ...
随机推荐
- JavaScript常用标签和方法总结
什么是javascript? (1) JavaScript是一种基于对象(Object)和事件驱动(Event Driven)并具有安全性能的 脚本语言. (2) JavaScript是由Nets ...
- POJ C程序设计进阶 编程题#1:单词翻转
编程题#1:单词翻转 来源: POJ (Coursera声明:在POJ上完成的习题将不会计入Coursera的最后成绩.) 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 输入一 ...
- source insight用于C语言编程的工具脚本
简单来说,source insight提供的功能功能还不够傻瓜,用起来还不够方便,所以写了此脚本,提高开发效率. 部分source insight提供的功能也包含了进来,主要是因为我不喜欢使用太多的快 ...
- AeroSpike 资料
文档总览:http://www.aerospike.com/docs/ JAVA AeroSpike知识总览:http://www.aerospike.com/docs/client/java/sta ...
- ThinkPHP之中getlist方法实现数据搜索功能
自己在ThinkPHP之中的model之中书写getlist方法,其实所谓的搜索功能无非就是数据库查询之中用到的like %string%,或者其他的 字段名=特定值,这些sql语句拼接在and语句 ...
- Delphi XE5 for android 图片缩放和拖动处理
首先,需要分辨手势的类型. 有两种类型的手势: 一是标准手势(Standard Gestures): 在Windows,android上,标准手势都是用一个手指. 在Mac OS X and iOS上 ...
- 每天进步一点--c#基础巩固,事件、委托
要想技术有所提高,就是把有些问题真正的弄懂弄明白,我从事C#开发两年了,一直对事件委托等概念一知半解,有时候博客园上看看别的大牛的文章,看看懂了就过去了,时间长了又忘了,真正理解还是要自己动手弄些例子 ...
- MVC的Filters(拦截过滤)的Error页面,支持Ajax报错
报错拦截过滤到error页面 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, A ...
- wpf的datepicker处理
如果有2个datepicker,控制时间起和止的话,可以把第二个datepicker加一个属性,DisplayDateStart = "{Binding SelectedDate,Eleme ...
- 调用微信退款接口时出现System.Security.Cryptography.CryptographicException: 出现了内部错误 解决办法
我总结了一下出现证书无法加载的原因有以下三个 1.证书密码不正确,微信证书密码就是商户号 解决办法:请检查证书密码是不是和商户号一致 2.IIS设置错误,未加载用户配置文件 解决办法:找到网站使用的应 ...