private void ActionMenu(object[] args) { switch ((int)args[0]) { case 1: browserMenu.Destroy(); Events.CallLocal("CallAnimList"); Cursor.Visible = false; break; case 2: browserMenu.Destroy(); browserMenu = new HtmlWindow("package://statics/settings/info.html"); break; case 3: browserMenu.Destroy(); browserMenu = new HtmlWindow("package://statics/settings/settings.html"); break; case 4: browserMenu.Destroy(); Cursor.Visible = false; Events.CallLocal("PedirAyuda"); break; } }
private void SaveSettings(HtmlWindow window) { // save selection foreach (HtmlElement element in window.Document.GetElementsByTagName("option")) { string selected = element.GetAttribute("selected"); if (selected.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { SetSettings(element.GetAttribute("value")); } } foreach (HtmlElement element in window.Document.GetElementsByTagName("input")) { if (element.GetAttribute("type").Equals("checkbox", StringComparison.InvariantCultureIgnoreCase)) { string selected = element.GetAttribute("checked"); if (selected.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { SetSettings(element.GetAttribute("value")); } else { SetSettings(element.GetAttribute("not")); } } } foreach (HtmlWindow frame in window.Frames) { SaveSettings(frame); } }
////////////////////////////////////////////////////////////////////////// // Web Document 操作 処理関数 /// <summary> /// id = fileurl の filePathを取得する /// </summary> /// <param name="url"></param> /// <returns></returns> public static String GetPathByID(String url) { // create a hidden web browser, which will navigate to the page System.Windows.Forms.WebBrowser web = new System.Windows.Forms.WebBrowser(); web.ScrollBarsEnabled = false; // we don't want scrollbars on our image web.ScriptErrorsSuppressed = true; // don't let any errors shine through web.Navigate(url); // let's load up that page! // wait until the page is fully loaded while (web.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } //System.Threading.Thread.Sleep(1500); // allow time for page scripts to update // the appearance of the page HtmlWindow currentWindow = web.Document.Window; String fileurl = ""; if (web.Document.GetElementById("fileurl") != null) { fileurl = web.Document.GetElementById("fileurl").InnerText; fileurl = Url2Path(fileurl); } web.Dispose(); return(fileurl); }
public void reload() { WebBrowser webBrowser = (WebBrowser)base.Owner.Controls.Find("webBrowser1", true)[0]; HtmlWindow htmlWindow = webBrowser.Document.Window.Frames["mainFrame"].Frames["rightFrame"]; htmlWindow.Navigate(htmlWindow.Url); }
private HtmlDocument GetHtmlDocument(FindAction findElementAction) { if (findElementAction.ActionContext != null) { HtmlWindow htmlWindow = null; if (findElementAction.ActionContext.FrameIndex >= 0) { htmlWindow = this.webBrowser.Document.Window.Frames[findElementAction.ActionContext.FrameIndex]; } else if (!string.IsNullOrEmpty(findElementAction.ActionContext.FrameName)) { htmlWindow = this.webBrowser.Document.Window.Frames[findElementAction.ActionContext.FrameName]; } if (htmlWindow == null) { return(null); } //IHTMLWindow2 htmlWindow2 = (IHTMLWindow2)htmlWindow.DomWindow; //IHTMLDocument2 document2 = CrossFrameIE.GetDocumentFromWindow(htmlWindow2); //mshtml.HTMLDocument d = (mshtml.HTMLDocument)document2; return(htmlWindow.Document); } else { return(this.Call <WebBrowserEx, HtmlDocument>(delegate(WebBrowserEx ex) { return ex.Document; }, this.webBrowser)); } }
private void OpenFromXML(string titel, string applicationUrl) { SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("OpenFromXML:titel=" + titel + " applicationUrl=" + applicationUrl); ViewModel.Context.MainPanel.SetTitel(titel); using (XmlReader reader = XmlReader.Create(new StringReader(applicationUrl))) { XElement xmlClient = XElement.Load(reader); var temp = from c in xmlClient.DescendantsAndSelf("System") select c; string AssemblyName = temp.Elements("AssemblyName").SingleOrDefault().Value.Trim(); string strUrl = temp.Elements("PageParameter").SingleOrDefault().Value.Trim(); string strOid = temp.Elements("ApplicationOrder").SingleOrDefault().Value.Trim(); if (AssemblyName == "GiftApplyMaster" || AssemblyName == "GiftPlan" || AssemblyName == "SumGiftPlan") { loading.Stop(); try { HtmlWindow wd = HtmlPage.Window; strUrl = strUrl.Split(',')[0]; if (strUrl.IndexOf('?') > -1) { strUrl = strUrl + "&uid=" + SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID + "&oid=" + strOid; } else { strUrl = strUrl + "?uid=" + SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID + "&oid=" + strOid; } string strHost = SMT.SAAS.Main.CurrentContext.Common.HostAddress.ToString().Split('/')[0]; strUrl = "http://" + strHost + "/" + strUrl; Uri uri = new Uri(strUrl); HtmlPopupWindowOptions options = new HtmlPopupWindowOptions(); options.Directories = false; options.Location = false; options.Menubar = false; options.Status = false; options.Toolbar = false; options.Status = false; options.Resizeable = true; options.Left = 280; options.Top = 100; options.Width = 800; options.Height = 600; // HtmlPage.PopupWindow(uri, AssemblyName, options); string strWindow = System.DateTime.Now.ToString("yyMMddHHmsssfff"); wd.Navigate(uri, strWindow, "directories=no,fullscreen=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no"); } catch (Exception ex) { SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(ex.ToString()); MessageBox.Show("模块链接异常:" + strUrl); } } else { CheckeDepends(AssemblyName); } } }
private void CheckForLogoutCompleted() { // Check if the frame we're waiting for has loaded var Frames = WebBrowser.Document.GetElementsByTagName("frame"); foreach (HtmlElement Frame in Frames) { if (Frame.Name.ToLower() == "tddetails") { // We found our frame, check for the sub-frame (seriously TD, frames within frames?!?) HtmlWindow DetailsFrame = Frame.Document.Window.Frames["tddetails"]; var SubFrames = DetailsFrame.Document.GetElementsByTagName("frame"); foreach (HtmlElement SubFrame in SubFrames) { if (SubFrame.Name.ToLower() == "logoutframe") { // We found our subframe, so logout must have succeeded _ScraperState = ScraperState.LoggedOut; DialogResult = DialogResult.OK; return; } } } } }
private void button12_Click(object sender, EventArgs e) { ////this.textBox7.AppendText(getNowMessage(this.mainWebBrowser.DocumentText)); HtmlWindow hw = this.mainWebBrowser.Document.Window.Frames["Framewindow"]; hw.Document.InvokeScript("formSubmit"); }
private void BtnSave_Click(object sender, RoutedEventArgs e) { HtmlWindow wd = HtmlPage.Window; //string strHost = Application.Current.Resources["PlatformWShost"].ToString().Split('/')[0]; string strUrl = ""; string MenuCode = this.txtEntityCode.Text.ToString(); //strUrl = "http://" + strHost + "/" + strUrl; if (!string.IsNullOrEmpty(MenuCode)) { MenuCode = MenuCode.Trim(); } strUrl = "http://demo.smt-online.net/New/Services/ckeditor/Default2.aspx?menucode=" + MenuCode; Uri uri = new Uri(strUrl); //wd.Navigate(uri, "_bank"); HtmlPopupWindowOptions options = new HtmlPopupWindowOptions(); options.Directories = false; options.Location = false; options.Menubar = false; options.Status = false; options.Toolbar = false; options.Status = false; options.Resizeable = true; options.Left = 280; options.Top = 100; options.Width = 800; options.Height = 600; // HtmlPage.PopupWindow(uri, AssemblyName, options); string strWindow = System.DateTime.Now.ToString("yyMMddHHmsssfff"); wd.Navigate(uri, strWindow, "directories=no,fullscreen=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no"); }
public ScriptableTest() { plugin = HtmlPage.Plugin; window = HtmlPage.Window; content = plugin.GetProperty("Content") as ScriptObject; //bool ispopupon = HtmlPage.IsPopupWindowAllowed; //HtmlWindow popup = HtmlPage.PopupWindow (new Uri ("about:blank"), "_blank", new HtmlPopupWindowOptions ()); calc = new Calculator(); scriptable = new Scriptable(); scriptabletype = new ScriptableType(); HtmlPage.RegisterScriptableObject("calc", calc); HtmlPage.RegisterScriptableObject("scriptable", scriptable); HtmlPage.RegisterScriptableObject("scriptabletype", scriptabletype); HtmlPage.RegisterCreateableType("createable", typeof(CreateableType)); if (Environment.OSVersion.Platform == PlatformID.Unix) { strplugin = "document.getElementById('silverlight')"; } else { strplugin = "document.getElementById('silverlightControlHost').getElementsByTagName('object')[0]"; } }
// must be called on UI thread public static void LoadScript() { //0 indicates that the script was not injected. if (0 != Interlocked.Exchange(ref _scriptInjected, 1)) { return; } //JavaScript Debug - v0.4 - 6/22/2010 //http://benalman.com/projects/javascript-debug-console-log/ //Copyright (c) 2010 "Cowboy" Ben Alman const string script = @"window.debug=(function(){var i=this,b=Array.prototype.slice,d=i.console,h={},f,g,m=9,c=[""error"",""warn"",""info"",""debug"",""log""],l=""assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace"".split("" ""),j=l.length,a=[];while(--j>=0){(function(n){h[n]=function(){m!==0&&d&&d[n]&&d[n].apply(d,arguments)}})(l[j])}j=c.length;while(--j>=0){(function(n,o){h[o]=function(){var q=b.call(arguments),p=[o].concat(q);a.push(p);e(p);if(!d||!k(n)){return}d.firebug?d[o].apply(i,q):d[o]?d[o](q):d.log(q)}})(j,c[j])}function e(n){if(f&&(g||!d||!d.log)){f.apply(i,n)}}h.setLevel=function(n){m=typeof n===""number""?n:9};function k(n){return m>0?m>n:c.length+m<=n}h.setCallback=function(){var o=b.call(arguments),n=a.length,p=n;f=o.shift()||null;g=typeof o[0]===""boolean""?o.shift():false;p-=typeof o[0]===""number""?o.shift():n;while(p<n){e(a[p++])}};return h})();"; try { HtmlWindow window = HtmlPage.Window; window.Eval(script); // get handle to methods _debugError = window.Eval("debug.error") as ScriptObject; _debugWarn = window.Eval("debug.warn") as ScriptObject; _debugInfo = window.Eval("debug.info") as ScriptObject; _debugLog = window.Eval("debug.log") as ScriptObject; } catch (Exception ex) { Debug.WriteLine("Error loading debug.log script: " + ex); } }
private void tts8888WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (tts8888WebBrowser.ReadyState == WebBrowserReadyState.Complete) { return; } FileIniDataParser parser = new FileIniDataParser(); IniData parserData = parser.LoadFile("C:/test.ini"); KeyDataCollection Keycol = parserData["Info"]; string iniUsername = Keycol["user"]; string iniPassWord = Keycol["pass"]; HtmlWindow windows = tts8888WebBrowser.Document.Window; var inputTagName = windows.Document.GetElementsByTagName("input"); if (inputTagName.Count == 3) { if (inputTagName[0] == null || inputTagName[1] == null || inputTagName[2] == null) { return; } else { inputTagName[0].SetAttribute("value", iniUsername); inputTagName[2].SetAttribute("value", iniPassWord); inputTagName[1].InvokeMember("click"); } } }
public void SwitchToParentFrame() { if (frame != null && frame.Parent != null) { frame = frame.Parent; } }
} // public void log(String txt) /// <summary> /// Save map config to server. /// Send http req. and set location.hash in brawser /// </summary> private void saveMap2Server() { currentCfg = getMapConfig(); var hash = VExtClass.computeSHA1Hash(currentCfg).ToLower(); log(string.Format("VSave.save2Server, hash='{0}'", hash)); // hash='310342AE3F6C2E7FD2C4C9FCC146E5ABB1E5A670' // c:\Inetpub\wwwroot\Apps\app3\Config\Tools.xml // <Tool.ConfigData>http://vdesk.algis.com/kvsproxy/Proxy.ashx</Tool.ConfigData> var servUrl = configDialog.InputTextBox.Text; log(string.Format("VSave.save2Server, base url='{0}'", servUrl)); try { HtmlWindow window = HtmlPage.Window; var func = (window.Eval("saveMap2Server") as ScriptObject); func.InvokeSelf(servUrl, hash, currentCfg); sendSaveRequest(servUrl, hash, currentCfg); } catch (Exception ex) { var msg = string.Format("VSave.save2Server failed, error: \n {0}", ex.Message); log(msg); //MessageBox.Show(msg); } } // private void saveMap2Server()
public void PrintAllElements(HtmlWindow n) { richTextBox1.Text += "Search Started--------\n"; foreach (HtmlElement e in n.Document.All) { richTextBox1.Text += "---------Record Started--------\n"; if (string.IsNullOrEmpty(e.OuterHtml) == false) { richTextBox1.Text += e.OuterHtml + "\n\n"; } if (string.IsNullOrEmpty(e.Id) == false) { richTextBox1.Text += "ID= " + e.Id + "\n\n"; } if (string.IsNullOrEmpty(e.Name) == false) { richTextBox1.Text += "NAME= " + e.Name + "\n\n"; } if (string.IsNullOrEmpty(e.TagName) == false) { richTextBox1.Text += "TAGNAME= " + e.TagName + "\n"; } richTextBox1.Text += "--------Record Ended--------\n"; } richTextBox1.Text += "Search Ended--------\n\n\n\n"; }
//<SNIPPET2> private void GetLinksFromFrames() { Hashtable linksTable = new Hashtable(); string frameUrl; if (!(webBrowser1.Document == null)) { HtmlWindow currentWindow = webBrowser1.Document.Window; if (currentWindow.Frames.Count > 0) { foreach (HtmlWindow frame in currentWindow.Frames) { frameUrl = frame.Url.ToString(); Hashtable frameLinksHash = new Hashtable(); linksTable.Add(frameUrl, frameLinksHash); foreach (HtmlElement hrefElement in frame.Document.Links) { frameLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url"); } } } else { Hashtable docLinksHash = new Hashtable(); linksTable.Add(webBrowser1.Document.Url.ToString(), docLinksHash); foreach (HtmlElement hrefElement in webBrowser1.Document.Links) { docLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url"); } } } }
public static HtmlWindow CreateBrowser(string path, object[] parameters) { HtmlWindow browser = new HtmlWindow(path); // Bind the browser creation event Events.OnBrowserCreated += (window) => { if (window.Id != browser.Id) { return; } // Enable the cursor Cursor.Visible = true; if (parameters != null && parameters.Length > 0) { // Get the function name string function = parameters[0].ToString(); object[] arguments = parameters.Skip(1).ToArray(); // Call the function passed as parameter ExecuteBrowserFunction(browser, function, arguments); } }; return(browser); }
public void PrintStatus(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlWindow currWin = wb.Document.Window; HtmlWindowCollection frames = currWin.Frames; System.Console.WriteLine("Frame count: " + frames.Count); }
/// <summary> /// Gets all ancestor frames in a HtmlWindow /// </summary> /// <param name="window"></param> /// <returns></returns> public static List <HtmlWindow> GetAllFrames(this HtmlWindow window) { List <HtmlWindow> ancestors = new List <HtmlWindow> { window }; bool added; int count = 0; do { // Keep recursing until we no longer // have anything else to add. added = false; foreach (HtmlWindow ancestor in ancestors.ToArray()) { foreach (HtmlWindow frame in ancestor.Frames) { if (!ancestors.Contains(frame)) { ancestors.Add(frame); added = true; count++; } } } } while (added && count < 100); // Limit to 100 frames return(ancestors); }
private void TryToScrapeAccountInformation() { // Check if the frame we're waiting for has loaded var Frames = WebBrowser.Document.GetElementsByTagName("frame"); foreach (HtmlElement Frame in Frames) { if (Frame.Name.ToLower() == "tddetails") { bool FoundAccountDivs = false; // We found our frame, check for the account details divs HtmlWindow DetailsFrame = Frame.Document.Window.Frames["tddetails"]; var Divs = DetailsFrame.Document.GetElementsByTagName("div"); foreach (HtmlElement Div in Divs) { switch (Div.GetAttribute("className")) { case "td-target-banking": // Banking accounts ParseAccounts(Div, false); FoundAccountDivs = true; break; case "td-target-creditcards": // Credit accounts, so flip the sign on the balance ParseAccounts(Div, true); FoundAccountDivs = true; break; case "td-target-investing": // Investment accounts ParseAccounts(Div, false); FoundAccountDivs = true; break; } } if (FoundAccountDivs) { // And now that we've parsed the account details, let's log out var Anchors = DetailsFrame.Document.GetElementsByTagName("a"); foreach (HtmlElement Anchor in Anchors) { if (!string.IsNullOrWhiteSpace(Anchor.InnerText) && (Anchor.InnerText.Trim().ToLower() == "logout")) { Anchor.InvokeMember("click"); } } // Presumably we found a logout button above, if not we'll still switch states and hopefully // the user will manually click the Logout button after waiting a few seconds _ScraperState = ScraperState.WaitingForLogout; } break; } } }
//<SNIPPET5> private void OpenNewWindowOverBrowser() { if (webBrowser1.Document != null) { HtmlWindow docWindow = webBrowser1.Document.Window; HtmlWindow newWindow = docWindow.OpenNew(new Uri("http://www.adatum.com/popup.htm"), "left=" + docWindow.Position.X + ",top=" + docWindow.Position.Y + ",width=" + webBrowser1.Width + ",height=" + webBrowser1.Height); } }
private void OpenRestrictedWindow() { if (webBrowser1.Document != null) { restrictedWindow = webBrowser1.Document.Window.OpenNew(new Uri("http://www.adatum.com/"), "width=300,height=300,resizable=yes"); // restrictedWindow.ResizeStart += new HtmlElementEventHandler(restrictedWindow_ResizeStart); } }
public static void DestroyBrowser(object[] args) { // Disable the cursor Cursor.Visible = false; // Destroy the browser MainBrowser.Destroy(); MainBrowser = null; }
public static void DestroyBrowser(HtmlWindow browser) { // Disable the cursor Cursor.Visible = false; // Destroy the browser browser.Destroy(); }
public Chat() { RAGE.Events.Add("SendToChat", OnSendToChat); RAGE.Events.Add("setChatState", OnSetChatState); RAGE.Chat.Show(false); ChatBrowser = new HtmlWindow("package://CEF/chat/index.html"); ChatBrowser.MarkAsChat(); }
private void ResizeWindow() { if (webBrowser1.Document != null) { resizableWindow = webBrowser1.Document.Window.OpenNew(new Uri("http://www.microsoft.com/"), ""); resizableWindow.ResizeTo(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); } }
private void ShowMenuWindowEvent(object[] args) { // Destroy the previous window BrowserHandler.DestroyBrowser(browser); // Create the menu browser browser = BrowserHandler.CreateBrowser("package://statics/gameselector.html", null); }
private void ShowImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Image img = sender as Image; string url = (img.Source as BitmapImage).UriSource.AbsoluteUri; HtmlWindow html = HtmlPage.Window; html.Navigate(new Uri(url, UriKind.RelativeOrAbsolute), "_blank"); }
private void ShowSkinSelectorEvent(object[] args) { // Destroy the previous broswer DestroyConnectionBrowserEvent(null); // Create the menu browser browser = BrowserHandler.CreateBrowser("package://statics/skinselector.html", null); }
public static void Main() { GameLocations = LocationLoader.Load(); Game = new GameEngine(GameLocations[LocationName.Main]); Window = new HtmlWindow(); Window.DrawLocation(Game.CurrentState); }
internal BrowserInformation (HtmlWindow window) { navigator = window.GetProperty ("navigator") as ScriptObject; }
/// <summary> /// Returns an observable sequence that contains the values of the underlying Internet Explorer event. /// </summary> public static Observable FromIEEvent(HtmlWindow window, string eventName) { return default(Observable); }
public static bool op_Inequality(HtmlWindow left, HtmlWindow right) {}