form1.cs

来自「敏感词过滤系统」· CS 代码 · 共 71 行

CS
71
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ChineseWordUnit
{
    public partial class Form1 : Form
    {
        string InitFileName = "E:\\temp\\敏感词\\敏感词\\WordFilter.txt";

        public Form1()
        {
            ChineseParse.InitFromFile(InitFileName);
            InitializeComponent();
        }

        private void btnFileOpen_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            if (opdFile.ShowDialog() == DialogResult.OK)
            {
                InitFileName = opdFile.FileName;
                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    //using (StreamReader sr = new StreamReader(opdFile.OpenFile()))
                    //{
                        //String line;
                        // Read and display lines from the file until the end of 
                        // the file is reached.
                        //while ((line = sr.ReadLine()) != null)
                        //{
                        //    sb.Append(line);
                        //    sb.Append("\n");
                        //    //Console.WriteLine(line);
                        //}
                      rtxOld.Text =  File.ReadAllText(InitFileName, Encoding.Default);
                        //rtxOld.Text = sb.ToString();
                    //}
                }
                catch (Exception ee)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The file could not be read:");
                    Console.WriteLine(ee.Message);
                }
            }


        }

        private void btnFilter_Click(object sender, EventArgs e)
        {
            //string[] newString = ChineseParse.ParseChinese(rtxOld.Text);
            //for (int i = 0; i < newString.Length; i++ )
            //{
            //    rtxNew.Text += newString[i] + "/";
            //    //rtxNew.Text += newString[i];
                
            //}
            rtxNew.Text = ChineseParse.ParseChinese(rtxOld.Text);
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?