//ライセンス情報はAgeOnフォルダのLISENCEフォルダを参照してください
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace nispi
/*{
    class WordExtraction
    {
        BoardViewCommon boardView;
        public ThreadInfo threadInfo;

        public WordExtraction(BoardViewCommon boardView)
        {
            this.boardView = boardView;

        }

        //時間の抽出をリセットしないとここの変更が表に出ない
        public void GetWordExtraction(string word)
        { 
            this.threadInfo = new ThreadInfo();
            
            foreach (ThreadData threadData in boardView.threadInfo.threadDataList)
            {
                if (threadData.title.Contains(word) == true)
                {
                    this.threadInfo.AddList(
                        threadData.orderNum,
                        threadData.datUrl,
                        threadData.title,
                        threadData.resNum,
                        threadData.readNum,
                        threadData.openTime,
                        threadData.openTimeString,
                        threadData.nowUnixTime,
                        threadData.speed,
                        threadData.fileName,
                        threadData.boardName);
                }
            }
        }

        public void Clear()
        {
            if (this.threadInfo != null)
            {
                this.threadInfo.threadDataList.Clear();
                this.threadInfo = null;
            }
        }
    }
}*/

{
    class WordExtraction
    {
        BoardViewCommon boardView;
        public ThreadInfo threadInfo;
        //private List<ThreadData> beforeThreadDataList;

        public WordExtraction(BoardViewCommon boardView)
        {
            this.boardView = boardView;

        }

        public void GetWordExtraction(string word)
        { 
            this.threadInfo = new ThreadInfo();
            List<ThreadData> threadDataList;

            if ((this.boardView.bvTimeExtraction != null) &&
                (this.boardView.bvTimeExtraction.threadInfo != null) &&
                (this.boardView.bvTimeExtraction.threadInfo.threadDataList != null) &&
                (this.boardView.bvTimeExtraction.threadInfo.threadDataList.Count != 0))
            {
                //時間による抽出データがある場合は、クローンを作る。読み込みメソッドで読み込まれないように
                //クリアしてnull化しておく。
                threadDataList = this.boardView.bvTimeExtraction.threadInfo.CloneObject(this.boardView.bvTimeExtraction.threadInfo).threadDataList;
                this.boardView.bvTimeExtraction.threadInfo.threadDataList.Clear();
                this.boardView.bvTimeExtraction.threadInfo.threadDataList = null;
                this.boardView.bvTimeExtraction.threadInfo = null;

                //beforeThreadDataList = threadDataList;
            }
            /*else if (beforeThreadDataList != null)
            {
                //すでにワード抽出のデータがあるならばそれを使う
                threadDataList = beforeThreadDataList;
                beforeThreadDataList = threadDataList;
            }*/
            else
            {
                threadDataList = boardView.threadInfo.threadDataList;
                //beforeThreadDataList = threadDataList;     
            }

            foreach (ThreadData threadData in threadDataList)
            {
                if (threadData.title.Contains(word) == true)
                {
                    this.threadInfo.AddList(
                        threadData.orderNum,
                        threadData.datUrl,
                        threadData.title,
                        threadData.resNum,
                        threadData.readNum,
                        threadData.openTime,
                        threadData.openTimeString,
                        threadData.nowUnixTime,
                        threadData.speed,
                        threadData.fileName,
                        threadData.boardName);
                }
            }
        }

        public void Clear()
        {
            if (this.threadInfo != null)
            {
                this.threadInfo.threadDataList.Clear();
                this.threadInfo = null;

                //this.beforeThreadDataList.Clear();
                //this.beforeThreadDataList = null;
            }
        }
    }
}
