Esempio n. 1
0
        //--------------------------------------------------------------------
        // 翻訳処理
        public void form_search()
        {
            if (translatorThread != null)
            {
                //  検索中を示す背景色とタイトルを戻す
                this.BackColor = System.Drawing.SystemColors.Control;
#if !EDICT
                this.Text = "KJ_dictform";
#else
                this.Text = "KJ_Edict";
#endif

                translatorThread.Abort();
                // filterを戻す
                KJ_dict.SetFilter(this.filter);
            }

            // 現在のfilterをbackup
            this.filter = KJ_dict.GetFilter();

            // 処理用のスレッドを作成
            translatorThread = new Thread(new ThreadStart(this.form_search_thread));
            translatorThread.Start();

            // filterを戻す
            KJ_dict.SetFilter(this.filter);
        }
Esempio n. 2
0
        //--------------------------------------------------------------------
        // その他正規表現検索
        static public SearchResult RegexSearch(SearchType type, string searchword)
        {
            SearchResult result;


            char[] any1 = new char[] { '.', '*', '?', '+', '[', '{' };
            char[] any2 = new char[] { '.', '*', '?', '+', ']', '}' };

            int leftPos  = searchword.IndexOfAny(any1);
            int rightPos = searchword.LastIndexOfAny(any2);
            int strLen   = searchword.Length;

            // あいう[か-く]まみ
            // 0 1 2 34 56 78 9
            //  leftPos:3    rightPos:7  strLen:9
            //    head : あいう
            //    tail : まみ
            //  if(leftPos+1==rightPos){
            //      return null;
            //  }

            string head = searchword.Substring(0, leftPos);
            string tail = searchword.Remove(0, rightPos + 1);

            KJ_dict.filterRegexword = searchword;

            // filterのデリゲート生成
            FilterDelegate dictFilter = new FilterDelegate(KJ_dict.RegexFilter);

            KJ_dict.SetFilter(dictFilter);

            // 長い方を優先に、前方一致または後方一致をかけ、
            // その結果からfilterを使い絞込みを行う。
            if (head.Length >= tail.Length)
            {
                result = KJ_dict.DictSearch(SearchType.forward, head);
            }
            else
            {
                result = KJ_dict.DictSearch(SearchType.backward, tail);
            }


            return(result);
        }
Esempio n. 3
0
        // コンストラクタ
        public KJ_form()
        {
            msg = new KJ_Message();


            // 設定情報
            Setting = new KJ_form_Setting();

            // もし存在するならば設定をファイルから読み込む

            if (System.IO.File.Exists(Setting.SettingFileName) == true)
            {
                // 設定ファイルあり

                //XmlSerializerオブジェクトの作成
                XmlSerializer serializer2 =
                    new XmlSerializer(typeof(KJ_form_Setting));
                //ファイルを開く
                FileStream fs2 = new FileStream(Setting.SettingFileName,
                                                FileMode.Open,
                                                FileAccess.Read);
                //XMLファイルから読み込み、逆シリアル化する
                Setting = (KJ_form_Setting)serializer2.Deserialize(fs2);

                // もし設定ファイルにカルチャ情報があれば,KJ_Messageに設定する
                //  (ふるい設定ファイルにはカルチャ情報はない)
                if (Setting.CultureName != null)
                {
                    KJ_Message.SetCultureName(Setting.CultureName);
                }
                else
                {
                    // 無いならOSのデフォルトを設定
                    Setting.CultureName = KJ_Message.GetCultureName();
                }

                //閉じる
                fs2.Close();
            }
            else
            {
                // 設定ファイルがない時のdefault
                Setting.withPronunciation = false;
                Setting.PronunciationType = 1;
                Setting.TargetLang        = 1;
                Setting.CultureName       = KJ_Message.GetCultureName();
                Setting.debugInfo         = false;
                Setting.except9999        = false;
                Setting.except8888        = true;
                Setting.ClipboardView     = false;
#if  !EDICT
                Setting.CompactForm = false;
#else
                Setting.CompactForm = true;
#endif
            }


            // フォントを設定する
            FontSetting();


            // FormのInitialize
            InitializeComponent();


            //コンパクトモード切替
            if (this.Setting.CompactForm)
            {
                this.ChangeCompactForm();
            }
            else
            {
                // Fromサイズを覚えていたらSettingから戻す
                if (Setting.FormSize.Width != 0)
                {
                    this.ClientSize = Setting.FormSize;
                }
            }

            // フィルタのデリゲート生成
            this.filter = new FilterDelegate(this.defaultFilter);

            // 韓国語環境テストが簡単にできるように関数化
            this.cultureName = KJ_Message.GetCultureName();
            //  "ja-JP"  or ...

            //  Open dictionary
      #if  EDICT
            //     KJ_dict.DictOpen("edict.yml");
            if (this.Setting.TargetLang == 1)
            {
                KJ_dict.DictOpen("edict.yml");
            }
            if (this.Setting.TargetLang == 2)
            {
                KJ_dict.DictOpen("edict.yml", "edict.yml.en");
            }
            if (this.Setting.TargetLang == 3)
            {
                KJ_dict.DictOpen("edict.yml", "edict.yml.jp");
            }
      #else
            if (this.Setting.TargetLang == 1)
            {
                KJ_dict.DictOpen("KJ_dict.yml");
            }
            if (this.Setting.TargetLang == 2)
            {
                KJ_dict.DictOpen("KJ_dict.yml", "KJ_dict.yml.kr");
            }
            if (this.Setting.TargetLang == 3)
            {
                KJ_dict.DictOpen("KJ_dict.yml", "KJ_dict.yml.jp");
            }
      #endif

            KJ_dict.SetFilter(this.filter);


            // for Clipboard
            NextHandle = SetClipboardViewer(this.Handle);
        } // end of KJ_form