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

using System.Windows.Forms;

using nispi.controlclass;

namespace nispi
{
    class BoardIndexTabMainMenu
    {
        public ToolStripMenuItemParts menuItemOpenBrowserParts;
        public ToolStripMenuItemParts menuItemCopyURLParts;
        public ToolStripMenuItemParts menuItemCopyTitleParts;
        public ToolStripMenuItemParts menuItemReloadParts;

        public BoardIndexTabEvent boardIndexTabEvent;

        public BoardIndexTabMainMenu(ToolStripMenuItemParts menuItemParts)
        {
            menuItemOpenBrowserParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCopyURLParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCopyTitleParts = ToolStripMenuItemPartsManager.Pop();
            menuItemReloadParts = ToolStripMenuItemPartsManager.Pop();

            menuItemOpenBrowserParts.Text = "ブラウザーで開く(&B)";

            menuItemCopyURLParts.Text = "URLをコピー(&C)";

            menuItemCopyTitleParts.Text = "タイトルをコピー(&T)";

            menuItemReloadParts.Text = "再読み込み(&R)";

            menuItemParts.DropDownItemsAdd(menuItemOpenBrowserParts);
            menuItemParts.DropDownItemsAdd("-");
            menuItemParts.DropDownItemsAdd(menuItemCopyURLParts);
            menuItemParts.DropDownItemsAdd(menuItemCopyTitleParts);
            menuItemParts.DropDownItemsAdd("-");
            menuItemParts.DropDownItemsAdd(menuItemReloadParts);

            boardIndexTabEvent = new BoardIndexTabEvent(this);
        }

        public void SetMainMenu()
        {
            //お気に入りか、２ｃｈのインデックスか,
            if (Const.form.boardIndexTabControlParts.SelectedIndex <= 8)
            {
                TreeViewParts treeViewParts;

                if (Const.form.boardIndexTabControlParts.SelectedIndex == 0)
                    treeViewParts = MainFormConst.boardIndexTabMain.boardIndexView.boardIndexControls.treeViewParts;
                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 1)
                    treeViewParts = MainFormConst.boardIndexTabMain.scBoardIndexView.boardIndexControls.treeViewParts;
                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 2)
                    treeViewParts = MainFormConst.boardIndexTabMain.open2chBoardIndexView.boardIndexControls.treeViewParts;
                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 3)
                    treeViewParts = MainFormConst.boardIndexTabMain.next2chBoardIndexView.boardIndexControls.treeViewParts;

                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 4)
                    treeViewParts = MainFormConst.boardIndexTabMain.jikkyoBoardIndexView.boardIndexControls.treeViewParts;
                //else if (Const.form.boardIndexTabControlParts.SelectedIndex == 5)
                //    treeViewParts = MainFormConst.boardIndexTabMain.blogbanBoardIndexView.boardIndexControls.treeViewParts;
                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 5)
                    treeViewParts = MainFormConst.boardIndexTabMain.shizuBoardIndexView.boardIndexControls.treeViewParts;

                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 6)
                    treeViewParts = MainFormConst.boardIndexTabMain.vip2chBoardIndexView.boardIndexControls.treeViewParts;
                else if (Const.form.boardIndexTabControlParts.SelectedIndex == 7)
                    treeViewParts = MainFormConst.boardIndexTabMain.machibbsBoardIndexView.boardIndexControls.treeViewParts;

                else
                    return;

                if ((treeViewParts.SelectedNodeGetBool() == false) || (treeViewParts.SelectedNodeName.Length == 0))
                {
                    menuItemOpenBrowserParts.Enabled = false;
                    menuItemCopyURLParts.Enabled = false;
                    menuItemCopyTitleParts.Enabled = false;
                }
                else
                {
                    menuItemOpenBrowserParts.Enabled = true;
                    menuItemCopyURLParts.Enabled = true;
                    menuItemCopyTitleParts.Enabled = true;
                }
            }
            else
            {
                TreeViewParts treeViewParts = MainFormConst.boardIndexTabMain.favoriteBoardIndexView.boardIndexControls.treeViewParts;
                if ((treeViewParts.SelectedNodeGetBool() == false) || (treeViewParts.SelectedNodeName.Length == 0))
                {
                    menuItemOpenBrowserParts.Enabled = false;
                    menuItemCopyURLParts.Enabled = false;
                    menuItemCopyTitleParts.Enabled = false;
                }
                else
                {
                    menuItemOpenBrowserParts.Enabled = true;
                    menuItemCopyURLParts.Enabled = true;
                    menuItemCopyTitleParts.Enabled = true;
                }
            }
        }
    }
}