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

using nispi.Analysis;
using nispi.controlclass;
using nispi.Menu;
using nispi.GetBoardIndexNS;

namespace nispi
{
    class MainFormConst
    {
        public static string urlLine;

        //GetBoardIndex
        public GetBoardIndex getBoardIndex;

        // BoardIndex
        public static BoardIndexTabMain boardIndexTabMain;

        // BoardList
        public static BoardListTabMain boardListTabMain;

        // ThreadList
        public static ThreadListTabMain threadListTabMain;

        public static HtmlPopUpWindowWidget htmlPopUpWindowWidget;


        public static MainMenuSetup menuSetup;

        public static FormShowStyle formShowStyle;

        public static CopyRightForm copyRightForm;


        public MainFormConst()
        {
            getBoardIndex = new GetBoardIndex();

            // BoardIndex
            boardIndexTabMain = new BoardIndexTabMain();

            //ツリービューに描画する。内部で板名とアドレスのリストも作る
            if (getBoardIndex.downloadStr.Length > 0)
            {
                //初回のみ実行される
                boardIndexTabMain.boardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStr);
            }
            else if (getBoardIndex.fileStr.Length > 0)
            {
                //２回目からはファイルを読み込むと同時に
                boardIndexTabMain.boardIndexView.LoadBoardListFromStr(getBoardIndex.fileStr);
                //この内部にスレッドがあり、そこでダウンロードを行う。２重に読み込んでいる
                boardIndexTabMain.boardIndexView.LoadBoardList();
            }

            //SC用ツリービューに描画する。内部で板名とアドレスのリストも作る
            if (getBoardIndex.downloadStrSC.Length > 0)
            {
                boardIndexTabMain.scBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrSC);
            }
            else if (getBoardIndex.fileStrSC.Length > 0)
            {
                boardIndexTabMain.scBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrSC);
                boardIndexTabMain.scBoardIndexView.LoadBoardList();
            }
            
            //おーぷん２ｃｈ
            if (getBoardIndex.downloadStrOPEN2CH.Length > 0)
            {
                boardIndexTabMain.open2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrOPEN2CH);
            }
            else if (getBoardIndex.fileStrOPEN2CH.Length > 0)
            {
                boardIndexTabMain.open2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrOPEN2CH);
                boardIndexTabMain.open2chBoardIndexView.LoadBoardList();
            }

            //Next2ch
            if (getBoardIndex.downloadStrNEXT2CH.Length > 0)
            {
                boardIndexTabMain.next2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrNEXT2CH);
            }
            else if (getBoardIndex.fileStrNEXT2CH.Length > 0)
            {
                boardIndexTabMain.next2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrNEXT2CH);
                boardIndexTabMain.next2chBoardIndexView.LoadBoardList();
            }
            //

            //jikkyo
            if (getBoardIndex.downloadStrJIKKYO.Length > 0)
            {
                boardIndexTabMain.jikkyoBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrJIKKYO);
            }
            else if (getBoardIndex.fileStrJIKKYO.Length > 0)
            {
                boardIndexTabMain.jikkyoBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrJIKKYO);
                boardIndexTabMain.jikkyoBoardIndexView.LoadBoardList();
            }
            //blogban
            /*if (getBoardIndex.downloadStrBLOGBAN.Length > 0)
            {
                boardIndexTabMain.blogbanBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrBLOGBAN);
            }
            else if (getBoardIndex.fileStrBLOGBAN.Length > 0)
            {
                boardIndexTabMain.blogbanBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrBLOGBAN);
                boardIndexTabMain.blogbanBoardIndexView.LoadBoardList();
            }*/
            //shizu
            if (getBoardIndex.downloadStrSHIZU.Length > 0)
            {
                boardIndexTabMain.shizuBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrSHIZU);
            }
            else if (getBoardIndex.fileStrSHIZU.Length > 0)
            {
                boardIndexTabMain.shizuBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrSHIZU);
                boardIndexTabMain.shizuBoardIndexView.LoadBoardList();
            }


            //vip2ch
            if (getBoardIndex.downloadStrVIP2CH.Length > 0)
            {
                boardIndexTabMain.vip2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrVIP2CH);
            }
            else if (getBoardIndex.fileStrVIP2CH.Length > 0)
            {
                boardIndexTabMain.vip2chBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrVIP2CH);
                boardIndexTabMain.vip2chBoardIndexView.LoadBoardList();
            }
            //machibbs
            if (getBoardIndex.downloadStrMACHIBBS.Length > 0)
            {
                boardIndexTabMain.machibbsBoardIndexView.LoadBoardListFromStr(getBoardIndex.downloadStrMACHIBBS);
            }
            else if (getBoardIndex.fileStrMACHIBBS.Length > 0)
            {
                boardIndexTabMain.machibbsBoardIndexView.LoadBoardListFromStr(getBoardIndex.fileStrMACHIBBS);
                boardIndexTabMain.machibbsBoardIndexView.LoadBoardList();
            }


            //
            LoadFavoriteBoardList();

            // BoardList
            boardListTabMain = new BoardListTabMain();

            // ThreadList
            threadListTabMain = new ThreadListTabMain();

            htmlPopUpWindowWidget = new HtmlPopUpWindowWidget();

            menuSetup = new MainMenuSetup();
            
            formShowStyle = new FormShowStyle();

            copyRightForm = new CopyRightForm();
        }
        
        //板を開くBoardViewで開く
        public static void ShowBoard(string url)
        {
            boardListTabMain.show_board(url, true);
        }

        //スレッドをThreadViewで開く
        public static void ShowThread(string url, string thread_name)
        {
            threadListTabMain.ShowThread(url, thread_name);
        }

        //板をBoardIndexで開く
        public static void LoadBoardList()
        {
            boardIndexTabMain.boardIndexView.LoadBoardList(); ;
        }

        //お気に入り板をFavoriteBoardIndexで開く
        public static void LoadFavoriteBoardList()
        {
            boardIndexTabMain.favoriteBoardIndexView.LoadFavoriteBoardList();
        }

        //ポップアップウィンドウ追加
        public static void PopUpWindow(Point point, ThreadViewCommon threadView, string datUrl, string number)
        {
            htmlPopUpWindowWidget.AddPopUp(point, threadView, datUrl, number);
        }

        //ポップアップウィンドウ複雑系追加
        public static void PopUpWindow(Point point, ThreadViewCommon threadView, string datUrl, string number, string type)
        {
            htmlPopUpWindowWidget.AddPopUp(point, threadView, datUrl, number, type);
        }

        //書き込みタブのページを開く
        public static void ShowWriteTab(string url, string thread_name)
        {
            threadListTabMain.ShowThread(url, thread_name);
        }
    }
}
