Example #1
0
        public override bool search(Search.Option option, TreeNodeUtill.GetNode getfunc)
        {
            // Fileつかって探るのとtree使うのはどっちが早いんだろうね
            TreeNode select = treeViewLine.SelectedNode;

            if (select == null)
            {
                if (treeViewLine.Nodes.Count > 0)
                {
                    // これをselectにするとこいつは調べてくれない
                    // まあ今のところは調べる必要は薄いのだが
                    select = treeViewLine.Nodes[0];
                }
                else
                {
                    return(false);
                }
            }
            TreeNode node = searchNext(select, null, option, getfunc);

            if (node == null && option.repeat && select != treeViewLine.Nodes[0])
            {
                node = searchNext(treeViewLine.Nodes[0], select, option, getfunc);
            }
            if (node != null)
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        TreeNode searchFile(TreeNode node, TreeNode stop, Search.Option option, TreeNodeUtill.GetNode getfunc)
        {
            TreeNode next = getfunc(node);

            while (next != null && next != stop)
            {
                string text = next.Text;
                // 細かいオプションはまだ
                if (compare(text, option))
                {
                    return(next);
                }
                next = getfunc(next);
            }
            return(null);
        }
Example #3
0
        TreeNode searchNext(TreeNode node, TreeNode stop, Search.Option option, TreeNodeUtill.GetNode getfunc)
        {
            TreeNode next = getfunc(node);

            while (next != null && next != stop)
            {
                File.Chunk chunk = next.Tag as File.Chunk;
                if (option.origin)
                {
                    chunk = Original.Chunks[chunk.ID.Original] as File.Chunk;
                }

                if (option.line)
                {
                    if (compare(chunk.Message.Modify, option))
                    {
                        treeViewLine.SelectedNode = next;
                        if (option.origin)
                        {
                            textBoxOriginal.Focus();
                        }
                        else
                        {
                            textBoxModify.Focus();
                        }
                        return(next);
                    }
                }
                if (option.id)
                {
                    if (compare(chunk.ID.Original, option))
                    {
                        treeViewLine.SelectedNode = next;
                        treeViewLine.Focus();
                        return(next);
                    }
                }
                next = getfunc(next);
            }
            return(null);
        }
Example #4
0
 public virtual bool search(Search.Option option, TreeNodeUtill.GetNode getfunc)
 {
     return(false);
 }
Example #5
0
        void find(bool forward)
        {
            TreeNodeUtill.GetNode getfunc = TreeNodeUtill.GetPrev;
            if (forward)
            {
                getfunc = TreeNodeUtill.GetNext;
            }
            Search.Option option   = new Search.Option(search_option);
            TabPage       tab      = tabControlFile.SelectedTab;
            int           tabindex = tabControlFile.SelectedIndex;

            switch (option.range)
            {
            //case Search.Option.Range.ByAll:
            //    break;
            //case Search.Option.Range.ByMes:
            //    break;
            //case Search.Option.Range.ByDlg:
            //    break;
            case Search.Option.Range.BySelected:
                if (tab != null)
                {
                    Editor edit = tab.Tag as Editor;
                    setStatus("");
                    if (edit.search(option, getfunc))
                    {
                    }
                    else
                    {
                        setStatus("検索完了");
                    }
                }
                break;

            case Search.Option.Range.ByOpened:
                // 選択タブからチェック
                if (tab != null)
                {
                    int count = tabControlFile.TabCount;
                    int num   = tabindex;
                    option.repeat = false;     // editではリピートしないで
                    setStatus("");
                    do
                    {
                        tabControlFile.SelectedIndex = num;    // selectedが何度も起こり重そうだが、ちらつかない模様
                        TabPage t    = tabControlFile.TabPages[num];
                        Editor  edit = t.Tag as Editor;
                        bool    ret  = edit.search(option, getfunc);
                        if (ret)
                        {
                            Control con = edit.ActiveControl;
                            //tabControlFile.SelectedIndex = num;
                            // TODO:この順番でフォーカス移るんかいな フォーカスは移らない
                            break;
                        }

                        if (forward)
                        {
                            // next
                            ++num;
                            // 終端チェック
                            if (search_option.repeat == false && num >= count)
                            {
                                setStatus("検索完了");
                                break;
                            }
                        }
                        else
                        {
                            // prev
                            --num;
                            // 終端チェック
                            if (search_option.repeat == false && num < 0)
                            {
                                setStatus("検索完了");
                                break;
                            }
                        }
                        num = num % count;
                        if (num < 0)
                        {
                            num += count;
                        }

                        // 次のページに切り替えて検索する時は、mes/dlgのツリーを未初期化の冒頭状態にしておかないと、
                        // 2回目からひっかかってくれないなあ。
                        // 最初に戻る時の挙動はどうなるんだ?
                        // 見つかり続ける限り次のタブにいってくれないので、option弄らんとな
                        edit.treeReset();
                    } while (num != tabindex);
                }
                break;

            case Search.Option.Range.ByFileName:
                TreeNode select = treeViewFile.SelectedNode;
                if (select == null)
                {
                    if (treeViewFile.Nodes.Count > 0)
                    {
                        // これをselectにするとこいつは調べてくれない
                        // まあ今のところは調べる必要は薄いのだが
                        select = treeViewFile.Nodes[0];
                    }
                    else
                    {
                        return;
                    }
                }
                setStatus("");
                TreeNode node = searchFile(select, null, option, getfunc);
                if (node == null && option.repeat && select != treeViewFile.Nodes[0])
                {
                    node = searchFile(treeViewFile.Nodes[0], select, option, getfunc);
                }
                if (node != null)
                {
                    //treeViewFile.Focus();
                    treeViewFile.SelectedNode = node;
                }
                else
                {
                    setStatus("検索完了");
                }
                break;

            default:
                break;
            }
        }