//////using System;
//////using System.Linq;
////////using System.Drawing;
//////using System.Windows.Forms;
//////using Gecko;

//////namespace myBuiltInMethod
//////{
//////    public class CopyOfbrowserLib
//////    {
//////        private GeckoWebBrowser web = null;
//////        public bool b_docCompleted { get; set; }
//////        public bool b_navigatingFired { get; set; }

//////        public string errmsg { set; get; }


//////        public Form frm { get; set; }



//////        public CopyOfbrowserLib(GeckoWebBrowser browser , Form frm)
//////        {
//////            this.frm = frm;
//////            this.web = browser;
//////        }

//////        /// <summary>
//////        /// Xpath指定で対象を取得し、０番目をクリックする。
//////        /// indexが指定された場合は、それをクリックする。
//////        /// マイナス指定のときは、すべてクリックする
//////        /// </summary>
//////        /// <param name="XPATH"></param>
//////        /// <param name="index"></param>
//////        public void ClickXpath(string XPATH, int index = 0)
//////        {
//////            //indexがマイナス指定のときは、すべてをクリック
//////            if (index < 0)
//////            {
//////                ClickXpath_All(XPATH);
//////                return;
//////            }

//////            try
//////            {
//////                GeckoElement[] elements = this.web.Document.GetElements(XPATH).ToArray<GeckoElement>();
//////                GeckoElement target;

//////                if (elements != null && elements.Length > 0)
//////                {
//////                    if (elements.Length > index)
//////                    {
//////                        target = elements[index];
//////                    }
//////                    else
//////                    {
//////                        target = elements[elements.Length - 1];
//////                    }
//////                    //web.StatusText = "クリックメニュー起動";
//////                    b_navigatingFired = false;
//////                    target.Click();
//////                    waitBrowser();
//////                }
//////            }
//////            catch
//////            {
//////                errmsg = "@@@@@@@@@@@@@@@@@@@@@@@" + Environment.NewLine 
//////                        + "クリックエラー" + Environment.NewLine
//////                        + XPATH + Environment.NewLine;
//////                System.Diagnostics.Debug.WriteLine(errmsg);

//////            }
//////        }




//////        public void waitBrowser()
//////        {
//////            while(web.IsBusy || web.IsAjaxBusy)
//////            {
//////                System.Threading.Thread.Sleep(100);
//////                Application.DoEvents();
//////                //↓これないと固まることが。。
//////                Application.RaiseIdle(new EventArgs());
//////            }
//////        }



//////        private void ClickXpath_All(string XPATH)
//////        {
//////            try
//////            {
//////                GeckoElement[] elements = this.web.Document.GetElements(XPATH).ToArray<GeckoElement>();

//////                if (elements != null && elements.Length > 0)
//////                {
//////                    foreach (GeckoElement item in elements)
//////                    {
//////                        //web.StatusText = "クリックメニュー起動";
//////                        item.Click();
//////                        waitBrowser();
//////                    }
//////                }
//////            }
//////            catch
//////            {
//////                errmsg = "@@@@@@@@@@@@@@@@@@@@@@@" + Environment.NewLine
//////                        + "クリックエラー ClickXpath_All " + Environment.NewLine
//////                        + XPATH + Environment.NewLine;
//////                System.Diagnostics.Debug.WriteLine(errmsg);
//////            }
//////        }

//////        public string[] GetInnerText(string XPATH)
//////        {
//////            if(XPATH == null) return null;

//////            GeckoElement[] temp = this.web.Document.GetElements(XPATH).ToArray<GeckoElement>();
//////            if (temp.Length == 0)
//////            {  
//////                string[] s = new string[] {""};
//////                return new string[] { "NULL" };
//////            }

//////            string[] ret = new string[temp.Length];
//////            for (int i = 0; i < temp.Length ; i++)
//////            {
//////                ret[i] = temp[i].TextContent;
//////            }
//////            return ret;
//////        }

//////        public void SetAttribute(GeckoElement ele, string attName, string attVal)
//////        {
//////            try
//////            {
//////                ele.SetAttribute(attName, attVal);
//////            }
//////            catch (Exception){}
//////        }

//////        public void SetAttribute(string Xpath, string attName, string attVal)
//////        {
//////            GeckoElement ele ;
//////            try
//////            {
//////                ele = web.Document.GetElements(Xpath).ToArray<GeckoElement>()[0];
//////                ele.SetAttribute(attName, attVal);
//////            }
//////            catch (Exception) { }
//////        }

//////        public string  GetAttribute(string Xpath, string attName)
//////        {
//////            string ret = "";

//////            GeckoElement ele;
//////            try
//////            {
//////                ele = web.Document.GetElements(Xpath).ToArray<GeckoElement>()[0];
//////                ret = ele.GetAttribute(attName);
//////            }
//////            catch(Exception) { }

//////            return ret;
//////        }

//////        public void SetTextcontents(string Xpath, string textcontent)
//////        {
//////            GeckoElement ele;
//////            try
//////            {
//////                ele = web.Document.GetElements(Xpath).ToArray<GeckoElement>()[0];
//////                ele.TextContent = textcontent;
//////            }
//////            catch (Exception) { }
//////        }

//////        public string GetTextcontents(string Xpath)
//////        {
//////            GeckoElement ele;
//////            string ret="";
//////            try
//////            {
//////                ele = web.Document.GetElements(Xpath).ToArray<GeckoElement>()[0];
//////                ret = ele.TextContent;
//////            }
//////            catch (Exception) { }

//////            return ret;
//////        }

//////        public void CreateElement(GeckoElement ele)
//////        {
//////            web.Document.Body.AppendChild(ele);
//////        }

//////        public void RemoveElement(GeckoElement ele)
//////        {
//////            web.Document.Body.RemoveChild(ele);
//////        }

//////        public void WaitAndNavigate(string URL)
//////        {
//////            b_navigatingFired = false;
//////            this.web.Navigate(URL);
//////            BrowserWait();
//////        }

//////        public void BrowserWait()
//////        {
//////            //System.Diagnostics.Debug.WriteLine("browserwait...start");

//////            //ナビゲート開始まで0.2秒まつ
//////            DateTime t = DateTime.Now;
//////            TimeSpan ts;
//////            while (b_navigatingFired == false)
//////            {
//////                //System.Diagnostics.Debug.Write("*");
//////                Application.DoEvents();
//////                //↓これないと固まることが。。
//////                Application.RaiseIdle(new EventArgs());

//////                ts = DateTime.Now - t;
//////                if(ts.Milliseconds > 200)
//////                    break;

//////            }
            

//////            while (web.StatusText.Length > 0 || web.IsBusy == true || this.b_docCompleted == false)
//////            {
//////                //System.Diagnostics.Debug.Write("*");
//////                Application.DoEvents();
//////                //↓これないと固まることが。。
//////                Application.RaiseIdle(new EventArgs());
//////            }
//////            //System.Diagnostics.Debug.WriteLine("browserwait...end");
//////        }


//////        public string getXpathFromElement(GeckoElement ele)
//////        {
//////            //現在の位置から、さかのぼる
//////            //同階層にいる同じタグを数えて、自分が何番目の兄弟か得る
//////            //親がいる場合は、その親をポイントして同じ処理を繰り返す
//////            //同じタグがなく、自分だけのときは[1]をつけない（XPATHエラーなるので）
//////            //後ろに兄弟がいるかもチェックする（複数ヒットをさけるため）
//////            if(ele == null) return "";

//////            int cntNodes = 0;
//////            int elepos = 0;
//////            string xpath ="";
//////            string targetTagname = ele.TagName.ToLower();

//////            if (ele.Parent == null)
//////            {
//////                return "/" + targetTagname;
//////            }

//////            foreach (GeckoNode node in ele.Parent.ChildNodes)
//////            {
//////                GeckoElement e = node.PreviousSibling as GeckoElement;
//////                if (e != null && e.TagName.ToLower() == targetTagname)
//////                {
//////                    cntNodes++;
//////                    if(e.Equals(ele))
//////                    {
//////                        elepos = cntNodes;
//////                    }
//////                }
//////            }

//////            if (elepos > 1)
//////            {
//////                xpath = targetTagname + "[" + elepos.ToString() + "]";
//////            }
//////            else
//////            {
//////                xpath = targetTagname;
//////            }

//////            //上へさかのぼる
//////            if (ele.ParentElement != null)
//////            {
//////                GeckoElement e = ele.ParentElement as GeckoElement;
//////                if (e != null)
//////                {
//////                    xpath = getXpathFromElement(e) + "/" + xpath;
//////                }
//////            }
//////            return xpath;
//////        }






//////    }//class

//////}//name