Esempio n. 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public SearchOptionForm(EditorSearchOption option, string selectText)
        {
            InitializeComponent();

            m_option = option;
            if (selectText != "")
            {
                //指定した項目を追加する
                option.SearchKeywordTable.Add(selectText);
            }

            //検索履歴をセットする
            foreach (string keyword in m_option.SearchKeywordTable.List)
            {
                searchKeywordBox.Items.Add(keyword);
            }
            if (searchKeywordBox.Items.Count > 0)
            {
                //一番先頭を選択状態にする
                searchKeywordBox.SelectedIndex = 0;
            }

            //オプション情報の反映
            ignoreCaseCheckBox.Checked = m_option.IgnoreCase;
            wordUnitCheckBox.Checked   = m_option.WordUnit;
            regexCheckBox.Checked      = m_option.Regex;

            m_searchResult = false;
        }
Esempio n. 2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Grep(EditorSearchOption option)
        {
            //エラーチェック
            if (option.SearchKeyword == "")
            {
                util.Msgbox.Error("検索キーワードが指定されていません");
                return;
            }
            if (option.GrepOption.FileExt == "")
            {
                util.Msgbox.Error("検索種類が指定されていません");
                return;
            }
            if (option.GrepOption.Pos == GrepPotision.Folder)
            {
                if (Directory.Exists(option.GrepOption.FolderPath) == false)
                {
                    util.Msgbox.Error("検索フォルダが見つかりません");
                    return;
                }
            }
            else if (option.GrepOption.Pos == GrepPotision.Project)
            {
                if (Directory.Exists(GlobalStatus.Project.DataFullPath) == false)
                {
                    util.Msgbox.Error("プロジェクトフォルダが見つかりません");
                    return;
                }
            }

            m_option = option;
        }
Esempio n. 3
0
 /// <summary>
 /// Grep検索を実行する
 /// </summary>
 /// <param name="option">検索オプション</param>
 public void Grep(EditorSearchOption option)
 {
     m_option = option;
     infoStatusBar.Visible         = true;       //ステータスバーを表示する
     resultEditor.Text             = "";
     searchResultProgressBar.Value = 0;
     searchResultStatusLabel.Text  = "検索中...";
     grepBgWarker.RunWorkerAsync(option);
 }
Esempio n. 4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="option">検索オプション</param>
        /// <param name="selectText">現在選択している文字列</param>
        public GrepOptionForm(EditorSearchOption option, string selectText)
        {
            InitializeComponent();

            m_option = option;
            if (selectText != "")
            {
                //指定した項目を追加する
                option.SearchKeywordTable.Add(selectText);
            }

            //検索履歴をセットする
            foreach (string keyword in m_option.SearchKeywordTable.List)
            {
                searchKeywordBox.Items.Add(keyword);
            }
            if (searchKeywordBox.Items.Count > 0)
            {
                //一番先頭を選択状態にする
                searchKeywordBox.SelectedIndex = 0;
            }

            //オプション情報の反映
            ignoreCaseCheckBox.Checked = m_option.IgnoreCase;
            wordUnitCheckBox.Checked   = m_option.WordUnit;
            regexCheckBox.Checked      = m_option.Regex;

            //ファイル種類をセットする
            foreach (string keyword in m_option.GrepOption.FileExtTable.List)
            {
                fileExtBox.Items.Add(keyword);
            }
            if (fileExtBox.Items.Count > 0)
            {
                //一番先頭を選択状態にする
                fileExtBox.SelectedIndex = 0;
            }
            else
            {
                fileExtBox.Text = "*.ks;*.tjs";
            }

            if (m_option.GrepOption.Pos == GrepPotision.Project)
            {
                grepPosProjectRadioButton.Checked = true;
            }
            else if (m_option.GrepOption.Pos == GrepPotision.Folder)
            {
                grepPosFolderRadioButton.Checked = true;
            }
            grepPosFolderBox.Text         = m_option.GrepOption.FolderPath;
            grepSubFolderCheckBox.Checked = m_option.GrepOption.UseSubFolder;

            m_searchResult = false;
        }
Esempio n. 5
0
        /// <summary>
        /// Grep検索を実行する
        /// </summary>
        private void grepBgWarker_DoWork(object sender, DoWorkEventArgs e)
        {
            EditorSearchOption option = (EditorSearchOption)e.Argument;
            Grep grep = new Grep(option);

            if (grep.Option == null)
            {
                return;                 //オプションが不正なときは強制終了
            }

            //検索ファイルリストを取得する
            string[] fileList = grep.GetSearchFileList();
            if (fileList == null || fileList.Length == 0)
            {
                return;
            }
            string basePath = option.GrepOption.SearchStartPath;

            //ファイルの数だけ検索を行う
            for (int i = 0; i < fileList.Length; i++)
            {
                if (grepBgWarker.CancellationPending)
                {
                    return;                                                        //強制中断
                }
                List <search.Grep.SearchResult> result = grep.Search(fileList[i]); //検索する

                //結果作成し送信する
                int    progress = (int)((double)((double)i / (double)fileList.Length) * 100);
                string text     = "";
                foreach (search.Grep.SearchResult res in result)
                {
                    text += String.Format("{0}({1}):{2}\n"
                                          , util.FileUtil.ConvertRelativaPath(basePath, res.FilePath), res.LineNumber, res.LineText);
                }
                ResultState state = new ResultState(fileList[i], progress, text);
                grepBgWarker.ReportProgress(progress, state);
            }
        }