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

using System.Windows.Forms;

using nispi.Analysis;

namespace nispi.controlclass
{
    /*class AnalysisImageControlsEvent
    {
        AnalysisImage0 analysisImageView;
        AnalysisImageControls analysisImageControls;

        public AnalysisImageControlsEvent(AnalysisImage0 analysisImageView, AnalysisImageControls analysisImageControls)
        {
            this.analysisImageView = analysisImageView;
            this.analysisImageControls = analysisImageControls;

            //this.analysisImageControls.aiFormParts.control.FormClosing += new FormClosingEventHandler(aiForm_FormClosing);
            this.analysisImageControls.aiFormParts.SetFormClosing(new FormPartsDelegate.MultiFormClosingEventHandler(aiForm_FormClosing));

            this.analysisImageControls.browserParts.Document.MouseUp += new HtmlElementEventHandler(Document_MouseUp);

            this.analysisImageControls.addressButtonParts.Click += new EventHandler(addressButton_Click);

            this.analysisImageControls.thumbnailButtonParts.Click += new EventHandler(thumbnailButton_Click);

            this.analysisImageControls.addressBrowserButtonParts.Click += new EventHandler(addressBrowserButton_Click);

            this.analysisImageControls.thumbnailBrowserButtonParts.Click += new EventHandler(thumbnailBrowserButton_Click);
        }

        public void RemoveEvent()
        {
            //this.analysisImageControls.aiFormParts.control.FormClosing -= new FormClosingEventHandler(aiForm_FormClosing);
            this.analysisImageControls.aiFormParts.ReSetFormClosing();//new FormPartsDelegate.MultiFormClosingEventHandler(aiForm_FormClosing));

            this.analysisImageControls.browserParts.Document.MouseUp -= new HtmlElementEventHandler(Document_MouseUp);

            this.analysisImageControls.addressButtonParts.Click -= new EventHandler(addressButton_Click);

            this.analysisImageControls.thumbnailButtonParts.Click -= new EventHandler(thumbnailButton_Click);

            this.analysisImageControls.addressBrowserButtonParts.Click -= new EventHandler(addressBrowserButton_Click);

            this.analysisImageControls.thumbnailBrowserButtonParts.Click -= new EventHandler(thumbnailBrowserButton_Click);
        }

        private void aiForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;

            //この作業をしないとメインウィンドウが閉じない。
            this.analysisImageControls.aiFormParts.Owner = null;

            this.analysisImageView.Cloose();

            this.analysisImageView = null;
            this.analysisImageControls = null;
        }

        public void Document_MouseUp(object sender, HtmlElementEventArgs e)
        {
            try
            {
                string link = null;
                string href = null;
                int num = 0;

                if (false == HtmlUtil.GetHrefAndTextByPoint(analysisImageControls.browserParts, e.MousePosition,ref link, ref href))
                    return;

                if ((link != null) && (link != "") && (link[link.Length - 1] == 'ジ') && (link.StartsWith("h") != true))
                {

                    int pe = link.LastIndexOf("ペ");
                    if (pe > 0)
                    {
                        link = link.Remove(pe, 3);
                        if (Int32.TryParse(link, out num) == true)
                        {
                            //int num = Int32.Parse(link);
                           /// Const.form.mainForm.Invoke(new AnalysisImage.ChangePage_Delegate(analysisImageView.ChangePage), num);
                            analysisImageView.ChangePage(num);
                        }
                    }
                    return;
                }
            }
            catch { ;}
        }
        public void addressButton_Click(object sender, EventArgs e)
        {
            //AnalysisImage.VIEWTYPE = "Link";
            //Const.form.mainForm.BeginInvoke(new AnalysisImage.ChangePage_Delegate(analysisImageView.ChangePage),analysisImageView.pageNum);
        }
        public void thumbnailButton_Click(object sender, EventArgs e)
        {
            //AnalysisImage.VIEWTYPE = "Thumbnail";
            //Const.form.mainForm.BeginInvoke(new AnalysisImage.ChangePage_Delegate(analysisImageView.ChangePage), analysisImageView.pageNum);
        }
        public void addressBrowserButton_Click(object sender, EventArgs e)
        {
            //AnalysisImage.VIEWTYPE = "LinkBrowser";
            //Const.form.mainForm.BeginInvoke(new AnalysisImage.OpenByBrowser_Delegate(analysisImageView.OpenByBrowser));
        }
        public void thumbnailBrowserButton_Click(object sender, EventArgs e)
        {
            //AnalysisImage.VIEWTYPE = "ThumbnailBrowser";
            //Const.form.mainForm.BeginInvoke(new AnalysisImage.OpenByBrowser_Delegate(analysisImageView.OpenByBrowser));
        }
    }*/
}
