001usingSystem;
002usingSystem.Collections.Generic;
003usingSystem.ComponentModel;
004usingSystem.Data;
005usingSystem.Drawing;
006usingSystem.Linq;
007usingSystem.Text;
008usingSystem.Windows.Forms;
009usingSystem.IO;
010usingSystem.Drawing.Text;
011
012namespace转繁体
013{
014publicpartialclassForm1 : Form
015{
016publicForm1()
017{
018InitializeComponent();
019FontsizeCom.Text = "12";
020}
021doubletime = 1;
022Dictionary<char, char> dict = newDictionary<char, char>();
023privatevoidForm1_Load(objectsender, EventArgs e)
024{
025///////////////////窗体加载各种初始化///////////////////////
026timer1.Interval = 1000;
027labresult.Hide();
028this.MaximizeBox = false;
029
030txtCT.ReadOnly=true;
031
032txtCS.Font = newFont("宋体",12);
033txtCS.ForeColor = Color.Gray;
034txtCS.Text = "请输入需要转换的简体中文";
035//////////////////窗体初始化设置////////////////////////////
036this.FormBorderStyle = FormBorderStyle.FixedDialog;
037Fontstyle.DropDownStyle = ComboBoxStyle.DropDownList;
038
039///////////////////字体选择初始化/////////////////////////
040InstalledFontCollection MyFont = newInstalledFontCollection();
041FontFamily[] MyFontFamilies = MyFont.Families;
042intCount = MyFontFamilies.Length;
043for(inti = 0; i < Count; i++)
044{
045stringFontName = MyFontFamilies[i].Name;
046this.Fontstyle.Items.Add(FontName);
047}
048Fontstyle.Text="宋体";
049
050////////////////////字体大小初始化////////////////////////////
051for(inti = 12; i <= 35; i++)
052{
053FontsizeCom.Items.Add(i);
054}
055
056
057/////////////////////用户提示初始化labresult//////////////////////////
058labresult.ForeColor = Color.RoyalBlue;
059labresult.Font = newFont("宋体",18);
060
061////////////////////////////////////////////////////////
062string[] lines = File.ReadAllLines("ST.txt");
063for(inti = 0; i < lines.Length; i++)
064{
065dict.Add(lines[i][0],lines[i][2]);
066}
067
068}
069
070privatevoidbutton1_Click(objectsender, EventArgs e)
071{
072StringBuilder cover_char = newStringBuilder();
073stringinput = txtCS.Text.Trim();
074if(txtCS.Text.Trim() != ""&&txtCS.Text.Trim()!=("请输入需要转换的简体中文"))
075{
076for(inti = 0; i < input.Length; i++)
077{
078if(dict.ContainsKey(input[i]))
079{
080cover_char.Append(dict[input[i]]);
081}
082else
083{
084cover_char.Append(input[i]);
085}
086}
087
088txtCT.Text = cover_char.ToString();
089}
090else
091{
092MessageBox.Show("请输入……");
093}
094if(txtCT.Text.Trim() != null)
095{
096Clipboard.SetText(this.txtCT.Text);
097labresult.Show();
098labresult.Text = "自动复制成功O(∩_∩)O";
099timer1.Start();
100}
101}
102
103privatevoidtxtCS_MouseClick(objectsender, MouseEventArgs e)
104{
105txtCS.Text = "";
106txtCS.ForeColor = Color.Black;
107txtCS.Font = newFont("微软雅黑", 12);
108txtCT.Font = newFont("微软雅黑", 15);
109}
110
111privatevoidFontstyle_SelectedIndexChanged(objectsender, EventArgs e)
112{
113
114//string fontstyle = Fontstyle.Text.Trim();
115//int fontsize = int.Parse(FontsizeCom.Text.Trim());
116//txtCT.Font = new Font(fontstyle,fontsize);
117}
118
119privatevoidFontsize_SelectedIndexChanged(objectsender, EventArgs e)
120{
121//string fontstyle = Fontstyle.Text.Trim();
122//int fontsize = int.Parse(FontsizeCom.Text.Trim());
123//txtCT.Font = new Font(fontstyle, fontsize);
124}
125
126privatevoidFontstyle_SelectedIndexChanged_1(objectsender, EventArgs e)
127{
128stringfontstyle = Fontstyle.Text.Trim();
129intfontsize = int.Parse(FontsizeCom.Text.Trim());
130txtCT.Font = newFont(fontstyle, fontsize);
131}
132
133privatevoidbutton2_Click(objectsender, EventArgs e)
134{
135
136}
137
138privatevoidtimer1_Tick(objectsender, EventArgs e)
139{
140time++;
141if(time == 2)
142{
143labresult.Hide();
144
145}
146timer1.Stop();
147time = 1;
148}
149
150privatevoidlinkLabel1_LinkClicked(objectsender, LinkLabelLinkClickedEventArgs e)
151{
152AboutBox1 about = newAboutBox1();
153about.Show();
154}
155
156
157
158
159
160
161
162
163
164}
165}