コード例 #1
0
        public static HtmlDocumentHandle GetOrCreateDocumentHandle(HtmlDocument htmlDocument)
        {
            var guidObj = htmlDocument.InvokeScript (c_getDocumentIdentification);

              var docID = guidObj != null ? new HtmlDocumentHandle (Guid.Parse (guidObj.ToString())) : new HtmlDocumentHandle (Guid.NewGuid());

              htmlDocument.InvokeScript (c_addDocumentIdentification, new object[] { docID.ToString() });
              return docID;
        }
コード例 #2
0
 // ComList("WritePorts","Connected!");
 public void ComList(String COMfunction, String message)
 {
     System.Windows.Forms.HtmlDocument document = this.webBrowser1.Document;
     Object[] objArray = new Object[1];
     objArray[0] = (Object)(message);
     document.InvokeScript(COMfunction, objArray);
 }
コード例 #3
0
        public Int16 SetValuesToHTML(System.Windows.Forms.HtmlDocument document, ref Int32[] ValuesOfSource)
        {
            Object[] objArray = new Object[10];
            for (int i = 0; i < 10; i++)
            {
                objArray[i] = (Object)(ValuesOfSource[i]);
            }

            document.InvokeScript("SetValuesToHTML", objArray);
            return(0);
        }
コード例 #4
0
    // DocumentCompleted event handle
    void IEBrowser_DocumentCompleted(object sender, forms.WebBrowserDocumentCompletedEventArgs e)
    {
        forms.HtmlDocument doc = ((forms.WebBrowser)sender).Document;

        if (doc.Title.Equals("Welcome to Windows Live") && loginCount++ < 3)
        {
            // set email address and password, and try to login three times
            try { doc.GetElementById("i0116").SetAttribute("value", userName); } catch {
                ieBrowser.Navigate("http://login.live.com/#");
                return;
            }
            doc.GetElementById("i0118").SetAttribute("value", password);
            doc.GetElementById("idSIButton9").InvokeMember("click");
        }
        else
        {
            // request jscript to call c# callback function with a parameter of navigation counter
            doc.InvokeScript("setTimeout", new object[] { string.Format("window.external.getHtmlResult({0})", navigationCounter), 10 });
        }
    }
コード例 #5
0
        private void ActionsBuilderWebView_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            // Set common properties (name, is scene or object, etc.)
            _document = ActionsBuilderWebView.Document;
            _document.GetElementById("ActionsBuilderObjectName").SetAttribute("value", _objectName);

            if (isRootNode)
                _document.InvokeScript("setIsScene");
            else
                _document.InvokeScript("setIsObject");

            _document.InvokeScript("updateObjectName");

            if (getProperty())
            {
                _document.GetElementById("ActionsBuilderJSON").SetAttribute("value", _jsonResult);
                _document.InvokeScript("updateGraphFromJSON");
            }

            // Set lists of meshes, lights, cameras etc.
            var gameScene = Loader.Global.IGameInterface;
            gameScene.InitialiseIGame(false);

            var meshes = gameScene.GetIGameNodeByType(Autodesk.Max.IGameObject.ObjectTypes.Mesh);
            fillObjectsList(meshes, "setMeshesNames");

            var lights = gameScene.GetIGameNodeByType(Autodesk.Max.IGameObject.ObjectTypes.Light);
            fillObjectsList(lights, "setLightsNames");

            var cameras = gameScene.GetIGameNodeByType(Autodesk.Max.IGameObject.ObjectTypes.Camera);
            fillObjectsList(cameras, "setCamerasNames");

            fillSoundsList(meshes, "setSoundsNames");

            // Need to subclass this, then allow 3ds Max usage 
            //Win32.SubClass(this.ActionsBuilderWebView.Handle);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: carpedm20/UNIST-robot
        /**********************************************************
         *
         *  포탈
         *
         **********************************************************/
        private void mainBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            /**********************************************************
             *
             *  PMS 막힘 확인 확인
             *
             **********************************************************/

            if (e.Url.ToString().IndexOf("http://10.99.1.4/IIWeb/default.htm") != -1 && pmsError == false)
            {
                pmsError = true;
                MessageBox.Show("PMS를 설치 혹은 우회 하셔야 합니다 :(", "Robot의 경고");
                System.Diagnostics.Process.Start("http://10.99.1.4/IIWeb/default.htm");

                System.Diagnostics.Process[] mProcess = System.Diagnostics.Process.GetProcessesByName(Application.ProductName);
                foreach (System.Diagnostics.Process p in mProcess)
                    p.Kill();
                Application.Exit();
            }

            /**********************************************************
             *
             *  최신 버전 확인
             *
             **********************************************************/

            if (e.Url.ToString().IndexOf("carpedm20.net76.net/robot_version.html") != -1)
            {
                doc = mainBrowser.Document as HtmlDocument;

                /************************************
                 *  최신 버전 확인중
                 ************************************/
                loadingLabel.Text = "최신 버전 확인중";
                loadingProgressBar.Value += 2;

                if (doc.GetElementById("version") == null)
                {
                    loadingLabel.Text = "최신 버전 확인 실패 :(";
                    mainBrowser.Navigate("https://portal.unist.ac.kr/EP/web/login/unist_acube_login_int.jsp");
                }

                lastestVersion = doc.GetElementById("version").InnerText.Trim();

                /************************************
                 *  작동하지 않는 서비스 있을시
                 ************************************/
                if (doc.GetElementById("urlError").InnerText.Trim() == "true")
                {
                    urlError = true;

                    bbStartUrl = doc.GetElementById("bbStartUrl").InnerText.Trim();
                    bbEndUrl = doc.GetElementById("bbEndUrl").InnerText.Trim();
                    bbAnnounceUrl = doc.GetElementById("bbAnnounceUrl").InnerText.Trim();
                    libraryStartUrl = doc.GetElementById("libraryStartUrl").InnerText.Trim();
                    libraryEndUrl = doc.GetElementById("libraryEndUrl").InnerText.Trim();
                    dormStartUrl = doc.GetElementById("dormStartUrl").InnerText.Trim();
                    dormEndUrl = doc.GetElementById("dormEndUrl").InnerText.Trim();
                    mailStartUrl = doc.GetElementById("mailStartUrl").InnerText.Trim();
                    mailEndUrl = doc.GetElementById("mailEndUrl").InnerText.Trim();
                }

                /************************************
                 * 공지사항
                 ************************************/
                if (doc.GetElementById("announce").InnerText != null)
                {
                    MessageBox.Show(doc.GetElementById("announce").InnerText, doc.GetElementById("announceTitle").InnerText);
                }

                if (currentVersion.IndexOf(lastestVersion) != -1)
                {
                    loadingLabel.Text = "최신 버전입니다 :)";
                }

                else
                {
                    loadingLabel.Text = "최신 버전이 아닙니다 :(";
                }

                mainBrowser.Navigate("https://portal.unist.ac.kr/EP/web/login/unist_acube_login_int.jsp");
            }

            /**********************************************************
             *
             *  로그인 창에서 변수 입력
             *
             **********************************************************/

            loadingProgressBar.Value += 1;

            if (e.Url.ToString() == "https://portal.unist.ac.kr/EP/web/login/unist_acube_login_int.jsp")
            {
                System.Threading.Thread.Sleep(2000);
                doc = mainBrowser.Document as HtmlDocument;

                doc.GetElementById("id").SetAttribute("value", Program.id);
                doc.GetElementsByTagName("input")["UserPassWord"].SetAttribute("value", Program.password);
                doc.InvokeScript("doLogin");

                /************************************
                 *  포탈 로그인 단계
                 ************************************/
                loadingLabel.Text = "포탈 로그인중";
                loadingProgressBar.Value += 5;
            }

            /**********************************************************
             *
             *  첫 로그인, 이름 저장, 학사 공지로 이동
             *
             **********************************************************/

            if (e.Url.ToString() == "http://portal.unist.ac.kr/EP/web/portal/jsp/EP_TopFixed.jsp")
            {
                if (isPortalComplete == false)
                {
                    /************************************
                     *  포탈 로그인 완료
                     ************************************/
                    loadingLabel.Text = "포탈 로그인 완료";
                    loadingProgressBar.Value += 5;

                    portalCookie = mainBrowser.Document.Cookie;
                    welcomeLabel.Click += new EventHandler(welcomeLabel_Click);

                    userName = mainBrowser.DocumentTitle.ToString().Split('-')[1].Split('/')[0];
                    welcomeLabel.Text = userName + " 님 환영합니다 :^)";

                    portal = new Portal(portalCookie, this);
                    showBoardGrid(1);

                    isPortalComplete = true;

                    browser.Navigate(bbStartUrl);
                }

                else
                {
                    browser.Navigate(bbStartUrl);
                }
            }
        }
コード例 #7
0
 public void JQ(HtmlDocument HD)
 {
     HtmlElement HE = HD.CreateElement("SCRIPT");
      HE.SetAttribute("src", "https://code.jquery.com/jquery-1.11.1.min.js");
      HD.Body.AppendChild(HE);
      HtmlElement HE2 = HD.CreateElement("SCRIPT");
      HE2.SetAttribute("text", Properties.Resources.attrNodeTopLeft);
      HD.Body.AppendChild(HE2);
      HD.InvokeScript("attrNodeTopLeft");
 }
コード例 #8
0
        // callback function to get the content of page in the WebBrowser control
        public void getHtmlResult(int count)
        {
            // unequal means the content is not stable
            if (owner.navigationCounter != count)
            {
                return;
            }

            // get HTML content
            owner.htmlResult = owner.ieBrowser.DocumentText;

            forms.HtmlDocument doc = owner.ieBrowser.Document;
            if (doc.Cookie != null)
            {
                // get cookies
                owner.htmlCookieTable = "<table border=1 cellspacing=0 cellpadding=2><tr><th>Name</th><th>Value</th><tr>";
                foreach (string cookie in Regex.Split(doc.Cookie, @";\s*"))
                {
                    string[] arr = cookie.Split(new char[] { '=' }, 2);
                    owner.htmlCookieTable += string.Format("<td>{0}</td><td>{1}</td></tr>", arr[0], (arr.Length == 2) ? arr[1] : "&nbsp;");
                }
                owner.htmlCookieTable += "</table><p />";
            }

            forms.HtmlElementCollection inputs = doc.GetElementsByTagName("INPUT");
            if (inputs.Count != 0)
            {
                // get ids, names, values and types of input elements
                owner.htmlInputTable = "<table border=1 cellspacing=0 cellpadding=2><tr><th>Id</th><th>Name</th><th>Value</th><th>Type</th><tr>";
                foreach (forms.HtmlElement input in inputs)
                {
                    owner.htmlInputTable += string.Format("<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", input.GetAttribute("Id"), input.GetAttribute("Name"), input.GetAttribute("Value"), input.GetAttribute("Type"));
                }
                owner.htmlInputTable += "</table><p />";
                owner.htmlInputTable  = owner.htmlInputTable.Replace("<td></td>", "<td>&nbsp;</td>");
            }

            forms.HtmlElementCollection scripts = doc.GetElementsByTagName("SCRIPT");
            if (scripts.Count != 0)
            {
                string vars = string.Empty;
                foreach (forms.HtmlElement script in scripts)
                {
                    if (script.InnerHtml == null)
                    {
                        continue;
                    }

                    foreach (string name in getVariableNames(script.InnerHtml).Split(new char[] { ';' }))
                    {
                        if (name.Trim().Length == 0)
                        {
                            continue;
                        }
                        if (vars.Contains("\"" + name + "\""))
                        {
                            continue;
                        }

                        // one row of the script variable table - <tr>getValue([script variable name]</tr> - getValue() is a script function in JScript.js
                        vars += string.Format("+\"<tr>\"+getValue(\"{0}\")+\"</tr>\"", name);
                    }
                }

                // request script to send back the names, values and types of script variables
                doc.InvokeScript("setTimeout", new object[] { scriptPattern.Replace("{0}", vars.Substring(1)), 10 });
            }
            else
            {
                // set resultEvent to let main thread continue
                owner.resultEvent.Set();
            }
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: petrind/SRTesis2
 private void docHandler(object sender,
 WebBrowserDocumentCompletedEventArgs e)
 {
     doc = ((WebBrowser)sender).Document;
     doc.InvokeScript("connectSocketServer");
 }