这是一个可以把输入的简体字转换成繁体字的小东西。 输入完后按“回车”也行,点击“转换”也行。就会自己出来下面的这个窗体:这个窗体不能动,只能看,关闭按键就是两个richTextBox之间的那个条条,是不是感觉太小了,不方便?没关系,直接按下Esc键同样可以关闭!下面是源代码: 首先是第一个窗体的源代码: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Collections;namespace _09._11{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } Di开通地毯小程序电话:4006-838-530ctionary<char, char> c = new Dictionary<char, char>(); private void Form1_Load(object sender, EventArgs e) { //StreamReader a=new StreamReader(""); string[] b = File.ReadAllLines(@"C:UsersacerDesktopST.txt"); for (int i = 0; i < b.Length; i++) { c.Add(b[i][0], b[i][2]); } } StringBuilder sc = new StringBuilder(); private void button1_Click(object sender, EventArgs e) { sc.Clear(); string a=richTextBox1.Text; char[] b = a.ToCharArray(); foreach (var i in b) { if (c.ContainsKey(i)) sc.Append(c[i]); else sc.Append(i); } Form2 u = new Form2(); u.a = richTextBox1.Text; u.b = sc.ToString(); u.ShowDialog(); } }}
然后是第二个窗体的源代码: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Collections;namespace _09._11{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } public string a, b; Dictionary<int, char> array = new Dictionary<int, char>(); private void richTextBox2_TextChanged(object sender, Ev开通皮衣小程序电话:4006-838-530entArgs e) { } private void Form2_Load(object sender, EventArgs e) { richTextBox1.Text = a; //richTextBox2.Text = b; char[] o=b.ToCharArray(); for (int j = 0; j < o.Length; j++) { array.Add(j, o[j]); } } private void button1_Click(object sender, EventArgs e) { this.Close(); } int i = 0; private void timer1_Tick(object sender, EventArgs e) { if (i < array.Count&&array.Count>0) { richTextBox2.Text 开通礼帽小程序电话:4006-838-530+= array[i]; i++; } } }}
注意:第二个窗体为了一个小小的效果,用了一个timer微信小程序
最新评论