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

using nispi.controlclass;

namespace nispi
{
    class BoardListTabMainMenu
    {
        public ToolStripMenuItemParts menuItemCloseTabParts;
        public ToolStripMenuItemParts menuItemCloseAllTabParts;
        public ToolStripMenuItemParts menuItemAddFavoriteParts;
        public ToolStripMenuItemParts menuItemCreateNewThreadParts;
        public ToolStripMenuItemParts menuItemOpenBrowserParts;
        public ToolStripMenuItemParts menuItemCopyURLParts;
        public ToolStripMenuItemParts menuItemCopyTitleParts;
        public ToolStripMenuItemParts menuItemReloadParts;

        public BoardListTabEvent boardListTabEvent;

        public BoardListTabMainMenu(ToolStripMenuItemParts menuItem)
        {
            menuItemCloseTabParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCloseAllTabParts = ToolStripMenuItemPartsManager.Pop();
            menuItemAddFavoriteParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCreateNewThreadParts = ToolStripMenuItemPartsManager.Pop();
            menuItemOpenBrowserParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCopyURLParts = ToolStripMenuItemPartsManager.Pop();
            menuItemCopyTitleParts = ToolStripMenuItemPartsManager.Pop();
            menuItemReloadParts = ToolStripMenuItemPartsManager.Pop();

            //メインメニュー設定
            menuItemCloseTabParts.Text = "タブを閉じる(&W)(CTRL+W)";
            menuItemCloseAllTabParts.Text = "すべてのタブを閉じる(&Q)(CTRL+Q)";
            menuItemAddFavoriteParts.Text = "お気に入りに追加する(&F)(CTRL+F)";

            menuItemCreateNewThreadParts.Text = "新規スレッド作成(&V)";
            menuItemOpenBrowserParts.Text = "ブラウザーで開く(&B)";

            menuItemCopyURLParts.Text = "URLをコピー(&C)";
            menuItemCopyTitleParts.Text = "板の名前をコピー(&T)";
            menuItemReloadParts.Text = "再読み込み(&R)(CTRL+R)";

            menuItem.DropDownItemsAdd("-");
            menuItem.DropDownItemsAdd(menuItemCloseTabParts);
            menuItem.DropDownItemsAdd(menuItemCloseAllTabParts);
            menuItem.DropDownItemsAdd("-");
            //menuItem.DropDownItemsAdd(menuItemAddFavoriteParts);
            menuItem.DropDownItemsAdd(menuItemCreateNewThreadParts);

            //menuItem.DropDownItemsAdd(menuItemOpenBrowserParts);
            //menuItem.DropDownItemsAdd("-");
            //menuItem.DropDownItemsAdd(menuItemCopyURLParts);
            //menuItem.DropDownItemsAdd(menuItemCopyTitleParts);
            //menuItem.DropDownItemsAdd("-");
            menuItem.DropDownItemsAdd(menuItemReloadParts);

            boardListTabEvent = new BoardListTabEvent(this);
            menuItem.DropDownItemsAdd("-");
        }

        public void SetMenu()
        {
            int selectNum = Const.form.boardListTabControlParts.SelectedIndex;
            if ((selectNum == 0) || (selectNum == 1))
            {
                //お気に入りの場合
                menuItemCloseTabParts.Enabled = false;
                menuItemCloseAllTabParts.Enabled = false;
                menuItemAddFavoriteParts.Enabled = false;
                menuItemCreateNewThreadParts.Enabled = false;
                menuItemOpenBrowserParts.Enabled = true;
                menuItemCopyURLParts.Enabled = true;
                menuItemCopyTitleParts.Enabled = true;
                menuItemReloadParts.Enabled = true;
            }
            else
            {
                if (Const.form.boardListTabControlParts.SelectedTabText.Length == 0)
                {
                    menuItemCloseTabParts.Enabled = false;
                    menuItemCloseAllTabParts.Enabled = false;
                    menuItemAddFavoriteParts.Enabled = false;
                    menuItemCreateNewThreadParts.Enabled = false;
                    menuItemOpenBrowserParts.Enabled = false;
                    menuItemCopyURLParts.Enabled = false;
                    menuItemCopyTitleParts.Enabled = false;
                    menuItemReloadParts.Enabled = false;
                }
                else
                {
                    menuItemCloseTabParts.Enabled = true;
                    menuItemCloseAllTabParts.Enabled = true;
                    menuItemAddFavoriteParts.Enabled = true;
                    menuItemCreateNewThreadParts.Enabled = true;
                    menuItemOpenBrowserParts.Enabled = true;
                    menuItemCopyURLParts.Enabled = true;
                    menuItemCopyTitleParts.Enabled = true;
                    menuItemReloadParts.Enabled = true;
                }
            }
        }
    }
}