老陈 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协议进行邮箱账号验证 ...
随机推荐
- chrome调试学习
参考:http://ued.taobao.com/blog/2012/06/debug-with-chrome-dev-tool/ http://guoshuang.com/frontend/chro ...
- 安装CMS遇到php5.3的问题
DedeCMS Error: (PHP 5.3 and above) Please set 'request_order' ini value to include C,G and P (recomm ...
- 《第一行代码--Android》阅读笔记之数据持久化
1.升级数据库 为了避免手工清空数据(或卸载重装APP),重写SQLiteOpenHelper里面的onUpgrade()方法 引用自http://blog.csdn.net/longvslove ...
- 【转】准确理解CSS clear:left/right的含义及实际用途
零.说点什么 好久没更新了.并不是在折腾什么大作,而是广度学习与实践中,加上婚礼等诸多大事,所以产出较少. 今天这篇也只是小作,博客是自己很好的学习工具,只要我学习不止,博客也会不断更新的. 我们平时 ...
- [leetcode]_Best Time to Buy and Sell Stock I && II
一个系列三道题,我都不会做,google之答案.过了两道,第三道看不懂,放置,稍后继续. 一.Best Time to Buy and Sell Stock I 题目:一个数组表示一支股票的价格变换. ...
- Hive中典型的表内数据除重写法
insert overwrite table store select t.p_key,t.sort_word from ( select p_key, sort_word , row_number( ...
- 多层级Spinner列表选项实时更新树形层级(选择城市)
package com.example.spinnerdemo; import android.os.Bundle; import android.app.Activity; import andro ...
- Firebird 修改表名
UPDATE RDB$RELATIONS SET RDB$RELATION_NAME='NEWNAME' where RDB$RELATION_NAME='OLDNAME'; UPDATE RDB$ ...
- Kafka入门学习(一)
====常用开源分布式消息系统 *集群:多台机器组成的系统叫集群. *ActiveMQ还是支持JMS的一种消息中间件. *阿里巴巴metaq,rocketmq都有kafka的影子. *kafka的动态 ...
- SQL Server中查询用户的对象权限和角色的方法
--SQL Server中查询用户的对象权限和角色的方法 -- 查询用户的object权限 exec sp_helprotect NULL, 'sa' -- 查询用户拥有的role exec sp_h ...