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

namespace nispi
{
    class FavoriteBoardView : BoardViewCommon
    {
        public FavoriteBoardView()
        {
            try
            {
                this.boardListControls = new BoardListControls(this as BoardViewCommon);
                this.boardListControls.closeTabButtonParts.Enabled = false;

                this.boardListControls.listViewParts.VirtualListSize = 0;
                this.boardListControls.listViewParts.boardView = this as BoardViewCommon;

                Const.form.boardListTabControlParts.AddControl(this.boardListControls.tabPageExParts);



                this.boardListControls.listViewParts.Size =
                    new Size(Const.form.boardListTabControlParts.Size.Width - 2,
                        Const.form.boardListTabControlParts.Size.Height - 27);
            }
            catch { ;}
        }
        public override void Dispoose()
        {
            try
            {
                this.boardListControls.RemoveAllControls();

                MainFormConst.boardListTabMain.remove_view((BoardViewCommon)this);

                Const.form.boardListTabControlParts.Refresh();
            }
            catch { ;}
        }

        public void Register(string datUrl, string title, string resNum)
        {
            try
            {
                if (threadInfo != null)
                {
                    // 同じものがないか調べる
                    foreach (ThreadData temp in threadInfo.threadDataList)
                    {
                        if (temp.datUrl.Equals(datUrl) == true)
                            return;
                    }
                }
                else
                {
                    threadInfo = new ThreadInfo();
                }

                threadInfo.AddList(datUrl, title, resNum);

                this.WriteLogFile(threadInfo.threadDataList);
            }
            catch (System.Exception ex)
            {
                Const.debugForm.OutPutDebug("BoardList", ex);
                return;
            }
        }

        public void Delete(string datUrl)
        {
            try
            {
                if (threadInfo != null)
                {
                    // 同じものがないか調べる
                    /*foreach (ThreadData temp in threadInfo.threadDataList)
                    {
                        if (temp.datUrl.Equals(datUrl) == true)
                            threadInfo.threadDataList.Remove(temp);
                    }*/
                    this.threadInfo.threadDataList = 
                        this.threadInfo.threadDataList.Where(a => a.datUrl.Equals(datUrl) == false).ToList();
                    this.WriteLogFile(threadInfo.threadDataList);
                }
            }
            catch (System.Exception ex)
            {
                Const.debugForm.OutPutDebug("BoardList", ex);
                return;
            }
        }
    }
}