微信小程序> 简体字转换繁体字的winfrom小程序

简体字转换繁体字的winfrom小程序

浏览量:618 时间: 来源:暗诡刺

 

这是一个可以把输入的简体字转换成繁体字的小东西。

 

输入完后按“回车”也行,点击“转换”也行。就会自己出来下面的这个窗体:

这个窗体不能动,只能看,关闭按键就是两个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();        }        Dictionary<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, EventArgs 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 += array[i];                i++;            }        }    }}

注意:第二个窗体为了一个小小的效果,用了一个timer微信小程序

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎