1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using System.IO;
  15. namespace 老陈Wpf
  16. {
  17. /// <summary>
  18. /// MainWindow.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. public MainWindow()
  23. {
  24. InitializeComponent();
  25. }
  26. public static int Count = 0;
  27. public static int right = 0;
  28. int m = 0;
  29.  
  30. private void button1_Click(object sender, RoutedEventArgs e)
  31. {
  32. StreamWriter n1 = File.AppendText("C:\\n1.txt");
  33. n1.WriteLine(textBox1.Text);
  34. n1.Close();
  35. StreamWriter n2 = File.AppendText("C:\\n2.txt");
  36. n2.WriteLine(textBox2.Text);
  37. n2.Close();
  38. StreamWriter n3 = File.AppendText("C:\\n3.txt");
  39. n3.WriteLine(textBox3.Text);
  40. n3.Close();
  41. MessageBox.Show("录题成功");
  42. textBox1.Text = "";
  43. textBox2.Text = "";
  44. textBox3.Text = "";
  45. }
  46.  
  47. private void button2_Click(object sender, RoutedEventArgs e)
  48. {
  49. //出题
  50. string[] n1 = new string[100];
  51. n1 = File.ReadAllLines("C:\\n1.txt");
  52. textBox1.Text = n1[m];
  53. string[] n2 = new string[100];
  54. n2 = File.ReadAllLines("C:\\n2.txt");
  55. textBox2.Text = n2[m];
  56. string[] n3 = new string[100];
  57. n3 = File.ReadAllLines("C:\\n3.txt");
  58. textBox3.Text = n3[m];
  59. m++;
  60. }
  61. //结束
  62. private void button3_Click(object sender, RoutedEventArgs e)
  63. {
  64. textBox5.Text = MainWindow.Count.ToString();//题目总数
  65. textBox6.Text = MainWindow.right.ToString();
  66. textBox7.Text = ((MainWindow.right / (double)(MainWindow.Count)) * 100).ToString() + "%";//正确率
  67. }
  68.  
  69. private void textBox4_KeyDown(object sender, KeyEventArgs e)
  70. {
  71. int a = int.Parse(textBox1.Text);
  72. int b = int.Parse(textBox3.Text);
  73. Char c = Convert.ToChar(textBox2.Text);
  74. Class1 con = new Class1();
  75. con.chu(a, b, c);
  76. if (e.Key == Key.Enter)
  77. {
  78.  
  79. if (con.answer == int.Parse(textBox4.Text))
  80. {
  81. MessageBox.Show("回答正确!下一题请按开始按钮!");
  82. right++;
  83. Count++;
  84. }
  85.  
  86. else
  87. {
  88.  
  89. MessageBox.Show("回答错误!下一题请按开始按钮!");
  90. Count++;
  91.  
  92. }
  93. textBox4.Clear();
  94. }
  95. }
  96.  
  97. private void button1_Click_1(object sender, RoutedEventArgs e)
  98. {
  99. StreamWriter n1 = File.AppendText("C:\\n1.txt");
  100. n1.WriteLine(textBox1.Text);
  101. n1.Close();
  102. StreamWriter n2 = File.AppendText("C:\\n2.txt");
  103. n2.WriteLine(textBox2.Text);
  104. n2.Close();
  105. StreamWriter n3 = File.AppendText("C:\\n3.txt");
  106. n3.WriteLine(textBox3.Text);
  107. n3.Close();
  108. MessageBox.Show("录题成功");
  109. textBox1.Text = "";
  110. textBox2.Text = "";
  111. textBox3.Text = "";
  112. }
  113. }
  114. }

 封装

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace 老陈Wpf
  7. {
  8. class Class1
  9. {
  10. public int sum;
  11. public int answer
  12. {
  13. get
  14. {
  15. return sum;
  16. }
  17. }
  18.  
  19. public int chu(int n1, int n2, char fuhao)
  20. {
  21. if (fuhao == '+')
  22. {
  23. return sum = n1 + n2;
  24. }
  25. else if (fuhao == '-')
  26. {
  27. return sum = n1 - n2;
  28. }
  29. else if (fuhao == '*')
  30. {
  31. return sum = n1 * n2;
  32. }
  33. return sum;
  34.  
  35. }
  36. }
  37. }

  运行的界面如下:

老陈 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. chrome调试学习

    参考:http://ued.taobao.com/blog/2012/06/debug-with-chrome-dev-tool/ http://guoshuang.com/frontend/chro ...

  2. 安装CMS遇到php5.3的问题

    DedeCMS Error: (PHP 5.3 and above) Please set 'request_order' ini value to include C,G and P (recomm ...

  3. 《第一行代码--Android》阅读笔记之数据持久化

    1.升级数据库 为了避免手工清空数据(或卸载重装APP),重写SQLiteOpenHelper里面的onUpgrade()方法   引用自http://blog.csdn.net/longvslove ...

  4. 【转】准确理解CSS clear:left/right的含义及实际用途

    零.说点什么 好久没更新了.并不是在折腾什么大作,而是广度学习与实践中,加上婚礼等诸多大事,所以产出较少. 今天这篇也只是小作,博客是自己很好的学习工具,只要我学习不止,博客也会不断更新的. 我们平时 ...

  5. [leetcode]_Best Time to Buy and Sell Stock I && II

    一个系列三道题,我都不会做,google之答案.过了两道,第三道看不懂,放置,稍后继续. 一.Best Time to Buy and Sell Stock I 题目:一个数组表示一支股票的价格变换. ...

  6. Hive中典型的表内数据除重写法

    insert overwrite table store select t.p_key,t.sort_word from ( select p_key, sort_word , row_number( ...

  7. 多层级Spinner列表选项实时更新树形层级(选择城市)

    package com.example.spinnerdemo; import android.os.Bundle; import android.app.Activity; import andro ...

  8. Firebird 修改表名

    UPDATE RDB$RELATIONS SET  RDB$RELATION_NAME='NEWNAME' where RDB$RELATION_NAME='OLDNAME'; UPDATE RDB$ ...

  9. Kafka入门学习(一)

    ====常用开源分布式消息系统 *集群:多台机器组成的系统叫集群. *ActiveMQ还是支持JMS的一种消息中间件. *阿里巴巴metaq,rocketmq都有kafka的影子. *kafka的动态 ...

  10. SQL Server中查询用户的对象权限和角色的方法

    --SQL Server中查询用户的对象权限和角色的方法 -- 查询用户的object权限 exec sp_helprotect NULL, 'sa' -- 查询用户拥有的role exec sp_h ...