1.下載Hokoy.WordKit.dll檔,並註冊,才能執行本程式:
http://www.hokoy.com/Works/Program/HokoyWordKit.aspx
2.程式碼如下: /*
* 由 SharpDevelop .NET 免費開發工具 建立的 C# .NET 程式.
* 作 者:
* 建立日期:
* 建立時間:
* 功 能: C# 繁簡轉換 COM 元件 之使用
* 修改日期:
*/
using System;
using System.Windows.Forms;
using Hokoy;
namespace DefaultNamespace
{
///
/// Description of MainForm.
///
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox richTextBox2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
///
private void InitializeComponent() {
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 5);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 16);
this.label1.TabIndex = 3;
this.label1.Text = "來源:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(464, 56);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 5;
this.button2.Text = "簡體->繁體";
this.button2.Click += new System.EventHandler(this.Button2Click);
//
// richTextBox2
//
this.richTextBox2.Location = new System.Drawing.Point(8, 176);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(448, 128);
this.richTextBox2.TabIndex = 2;
this.richTextBox2.Text = "";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(8, 24);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(448, 128);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(464, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 1;
this.button1.Text = "繁體->簡體";
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 159);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 16);
this.label2.TabIndex = 4;
this.label2.Text = "轉換結果:";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(552, 318);
this.Controls.Add(this.button2);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.richTextBox2);
this.Controls.Add(this.button1);
this.Controls.Add(this.richTextBox1);
this.Name = "MainForm";
this.Text = "MainForm";
this.ResumeLayout(false);
}
#endregion
//繁體轉簡體
void Button1Click(object sender, System.EventArgs e)
{
WordKitClass source1=new WordKitClass();
Object OK1=new Object();
if (richTextBox1.Text.Length>0)
{
OK1=source1.Big5toGB(richTextBox1.Text);
richTextBox2.Text =OK1.ToString();
}
}
//簡體轉繁體
void Button2Click(object sender, System.EventArgs e)
{
WordKitClass source2=new WordKitClass();
Object OK2=new Object();
if (richTextBox1.Text.Length>0)
{
OK2=source2.GBtoBig5(richTextBox1.Text);
richTextBox2.Text =OK2.ToString();
}
}
}
}
網海無涯,唯學是岸! 發表人 - qoo1234 於 2004/08/15 16:04:11