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

using System.Windows.Forms;

using nispi.controlclass;
using nispi.Menu;
using nispi.OptionControl;
using nispi.AgeOnDebuger;

namespace nispi
{
    partial class MainForm
    {
        public void MainType1PanelResize(object sender, EventArgs e)
        {
            MainType1PanelResize();
        }

        public void MainType1PanelResize()
        {
            mainSplitContainerParts.Size = new Size(Const.MainFormType1Size.Width - Scale.GetMainSplitContainerMinusSize().Width, 
                Const.MainFormType1Size.Height - Scale.GetMainSplitContainerMinusSize().Height);

            //停止
            subMainSplitContainerParts.Panel1_Resize -= new EventHandler(SubType1PanelResize);

            subMainSplitContainerParts.Size = new Size(mainSplitContainerParts.Size.Width - mainSplitContainerParts.SplitterDistance - 2,
                mainSplitContainerParts.Size.Height);
            //開始
            subMainSplitContainerParts.Panel1_Resize += new EventHandler(SubType1PanelResize);

            /*if (mainSplitContainerParts.SplitterDistance < 170)
                mainSplitContainerParts.SplitterDistance = 170;
            if ((mainSplitContainerParts.Size.Width - mainSplitContainerParts.SplitterDistance) < 170)
                mainSplitContainerParts.SplitterDistance = mainSplitContainerParts.Size.Width - 170;
            
            if (Const.MainFormType1Size.Width - mainSplitContainerParts.SplitterDistance < 680)
            {
                mainSplitContainerParts.SplitterDistance = Const.MainFormType1Size.Width - 680;
            }*/

            MainFormConst.formShowStyle.ReSizeType1();
        }

        public void SubType1PanelResize(object sender, EventArgs e)
        {
            SubType1PanelResize();
        }

        public void SubType1PanelResize()
        {

            //mainSplitContainerParts.Size = new Size(Const.MainFormType1Size.Width - Scale.GetMainSplitContainerMinusSize().Width,
            //    Const.MainFormType1Size.Height - Scale.GetMainSplitContainerMinusSize().Height);

            subMainSplitContainerParts.Size = new Size(mainSplitContainerParts.Size.Width - mainSplitContainerParts.SplitterDistance - 2,
                mainSplitContainerParts.Size.Height);

            /*if (subMainSplitContainerParts.SplitterDistance < 100)
                subMainSplitContainerParts.SplitterDistance = 100;
            if ((subMainSplitContainerParts.Size.Height - subMainSplitContainerParts.SplitterDistance) < 100)
                subMainSplitContainerParts.SplitterDistance = subMainSplitContainerParts.Size.Height - 100;
            */

            MainFormConst.formShowStyle.ReSizeType1();
        }

        public void FormResizeType1(object sender, EventArgs e)
        {
            //ちらつき防止
            MainFormConst.boardIndexTabMain.boardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.scBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.open2chBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.next2chBoardIndexView.boardIndexControls.treeViewParts.Visible = false;

            MainFormConst.boardIndexTabMain.jikkyoBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.blogbanBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.shizuBoardIndexView.boardIndexControls.treeViewParts.Visible = false;

            MainFormConst.boardIndexTabMain.vip2chBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            MainFormConst.boardIndexTabMain.machibbsBoardIndexView.boardIndexControls.treeViewParts.Visible = false;

            MainFormConst.boardIndexTabMain.favoriteBoardIndexView.boardIndexControls.treeViewParts.Visible = false;
            
            mainSplitContainerParts.Panel1_Resize -= new EventHandler(MainType1PanelResize);
            subMainSplitContainerParts.Panel1_Resize -= new EventHandler(SubType1PanelResize);
            
            Control control = (Control)sender;


            //解除しないとループになる処理群
            if ((control.Size.Width < Const.form.mainForm.MinimumSize.Width) ||
                (control.Size.Height < Const.form.mainForm.MinimumSize.Height))
            {
                Const.MainFormType1Size = new Size(Const.form.mainForm.MinimumSize.Width, Const.form.mainForm.MinimumSize.Height);
            }

            Const.MainFormType1Size = control.Size;

            FormResizeType1(); 
            
            mainSplitContainerParts.Panel1_Resize += new EventHandler(MainType1PanelResize);
            subMainSplitContainerParts.Panel1_Resize += new EventHandler(SubType1PanelResize);

            MainFormConst.formShowStyle.ReSizeType1();

            //ちらつき防止後処理
            MainFormConst.boardIndexTabMain.boardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.scBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.open2chBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.next2chBoardIndexView.boardIndexControls.treeViewParts.Visible = true;

            MainFormConst.boardIndexTabMain.jikkyoBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.blogbanBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.shizuBoardIndexView.boardIndexControls.treeViewParts.Visible = true;

            MainFormConst.boardIndexTabMain.vip2chBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
            MainFormConst.boardIndexTabMain.machibbsBoardIndexView.boardIndexControls.treeViewParts.Visible = true;

            MainFormConst.boardIndexTabMain.favoriteBoardIndexView.boardIndexControls.treeViewParts.Visible = true;
        }
        
        public void FormResizeType1()
        {
            //ToolStrip
            toolStripParts.Size = new Size(mainSplitContainerParts.Size.Width - 200, toolStripTextBoxParts.Size.Height);
            //toolStripTextBoxParts.Size = new Size(mainSplitContainerParts.Size.Width - 250, toolStripTextBoxParts.Size.Height);

            //{
            //    mainSplitContainerParts.SplitterDistance = Const.MainFormType1Size.Width - 680;
                //mainSplitContainerParts.Size = new Size(670, Const.MainFormType1Size.Height - 117);
            //}
            mainSplitContainerParts.Size = new Size(Const.MainFormType1Size.Width - Scale.GetMainSplitContainerMinusSize().Width,
                Const.MainFormType1Size.Height - Scale.GetMainSplitContainerMinusSize().Height);

            //del 3/3
            //mainSplitContainerParts.SplitterDistance = Const.MainFormType1Size.Width / 4;

            subMainSplitContainerParts.Size = new Size(mainSplitContainerParts.Size.Width - mainSplitContainerParts.SplitterDistance - 2,
                mainSplitContainerParts.Size.Height);

            //mainForm.Text = mainSplitContainerParts.Size.Width.ToString() + ":" + mainSplitContainerParts.Size.Height.ToString();
        }
    }
}
