/// <include file='doc\HtmlWindowCollection.uex' path='docs/doc[@for="HtmlWindowCollection.GetEnumerator"]/*' /> /// <internalonly/> public IEnumerator GetEnumerator() { HtmlWindow[] htmlWindows = new HtmlWindow[this.Count]; ((ICollection)this).CopyTo(htmlWindows, 0); return(htmlWindows.GetEnumerator()); }
internal HtmlWindow.HtmlWindowShim GetWindowShim(HtmlWindow window) { if ((this.htmlWindowShims != null) && this.htmlWindowShims.ContainsKey(window)) { return(this.htmlWindowShims[window]); } return(null); }
public HtmlElement GetEl(string id, HtmlWindow frame) { HtmlDocument doc = GetDoc(frame); if (doc != null) { return doc.GetElementById(id); } return null; }
internal void OnWindowUnloaded(HtmlWindow unloadedWindow) { Debug.Assert(unloadedWindow != null, "Why are we calling this with a null window?"); if (unloadedWindow != null) { // // prune documents // if (htmlDocumentShims != null) { HtmlDocument.HtmlDocumentShim[] shims = new HtmlDocument.HtmlDocumentShim[htmlDocumentShims.Count]; htmlDocumentShims.Values.CopyTo(shims, 0); foreach (HtmlDocument.HtmlDocumentShim shim in shims) { if (shim.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { htmlDocumentShims.Remove(shim.Document); shim.Dispose(); } } } // // prune elements // if (htmlElementShims != null) { HtmlElement.HtmlElementShim[] shims = new HtmlElement.HtmlElementShim[htmlElementShims.Count]; htmlElementShims.Values.CopyTo(shims, 0); foreach (HtmlElement.HtmlElementShim shim in shims) { if (shim.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { htmlElementShims.Remove(shim.Element); shim.Dispose(); } } } // // prune the particular window from the list. // if (htmlWindowShims != null) { if (htmlWindowShims.ContainsKey(unloadedWindow)) { HtmlWindow.HtmlWindowShim shim = htmlWindowShims[unloadedWindow]; htmlWindowShims.Remove(unloadedWindow); shim.Dispose(); } } } }
private IEnumerable<HtmlWindow> WalkFrame(HtmlWindow frame) { if (frame == null) //|| frame.Url == null || frame.Url.AbsoluteUri == c_blankSite) yield break; yield return frame; if (frame.Frames != null) foreach (var subframe in frame.Frames.Cast<HtmlWindow>().SelectMany (WalkFrame)) yield return subframe; }
public void RefreshFrame() { try { HtmlWindowCollection collection = mBrowser.Document.Window.Frames; mMainWindow = collection[collection.Count - 1]; } catch (Exception ex) { System.Diagnostics.Trace.Write("Page not ready" + ex.ToString()); } }
internal HtmlDocumentShim(HtmlDocument htmlDocument) { this.htmlDocument = htmlDocument; if (this.htmlDocument != null) { HtmlWindow window = htmlDocument.Window; if (window != null) { this.associatedWindow = window.NativeHtmlWindow; } } }
internal HtmlWindow.HtmlWindowShim GetWindowShim(HtmlWindow window) { if (htmlWindowShims == null) { return(null); } if (htmlWindowShims.ContainsKey(window)) { return(htmlWindowShims[window]); } return(null); }
/// <summary> /// recursively retrieves frames from browser window /// </summary> /// <param name="fs"></param> /// <param name="window"></param> void get_frames(System.Windows.Forms.HtmlWindow window, string path) { foreach (System.Windows.Forms.HtmlWindow f in window.Frames) { //if (HtmlFrameDocs == null) // HtmlFrameDocs = new HtmlFrames(); string current_path = path + ((path == null) ? "" : ">") + f.Name; HtmlFrameDocs[current_path] = f.Document; get_frames(f, current_path); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if ((this.htmlWindow != null) && (this.htmlWindow.NativeHtmlWindow != null)) { Marshal.FinalReleaseComObject(this.htmlWindow.NativeHtmlWindow); } this.htmlWindow = null; } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (_htmlWindow is not null && _htmlWindow.NativeHtmlWindow is not null) { Marshal.FinalReleaseComObject(_htmlWindow.NativeHtmlWindow); } _htmlWindow = null; } }
internal HtmlDocumentShim(HtmlDocument htmlDocument) { _htmlDocument = htmlDocument; // snap our associated window so we know when to disconnect. if (_htmlDocument != null) { HtmlWindow window = htmlDocument.Window; if (window != null) { _associatedWindow = window.NativeHtmlWindow; } } }
public BasePageRender(WebBrowser browser) { lockObject = new Object(); try { mBrowser = browser; HtmlWindowCollection collection = browser.Document.Window.Frames; mMainWindow = collection[collection.Count - 1]; //always the last one the main AR_event = new AutoResetEvent(false); } catch (Exception ex) { System.Diagnostics.Trace.Write("Page not ready" + ex.ToString()); } }
/// <summary> /// recursively retrieves frames from browser window /// </summary> /// <param name="fs"></param> /// <param name="window"></param> void get_frames(System.Windows.Forms.HtmlWindow window, string path) { foreach (System.Windows.Forms.HtmlWindow f in window.Frames) { try { //string current_path = path + ((path == null) ? "" : ">") + f.Name; //HtmlFrameDocs[current_path] = f.Document; //get_frames(f, current_path); } catch (Exception e) { Log.Error(e); } } }
public HtmlElementShim(HtmlElement element) { this.htmlElement = element; if (this.htmlElement != null) { HtmlDocument document = this.htmlElement.Document; if (document != null) { HtmlWindow window = document.Window; if (window != null) { this.associatedWindow = window.NativeHtmlWindow; } } } }
/// <devdoc> AddWindowShim - adds a HtmlWindowShim to list of shims to manage ///</devdoc> public void AddWindowShim(HtmlWindow window) { HtmlWindow.HtmlWindowShim shim = null; if (htmlWindowShims == null) { htmlWindowShims = new Dictionary<HtmlWindow,HtmlWindow.HtmlWindowShim>(); shim = new HtmlWindow.HtmlWindowShim(window); htmlWindowShims[window] = shim; } else if (!htmlWindowShims.ContainsKey(window)) { shim = new HtmlWindow.HtmlWindowShim(window); htmlWindowShims[window] = shim; } if (shim != null) { // strictly not necessary, but here for future use. OnShimAdded(shim); } }
public HtmlElementShim(HtmlElement element) { _htmlElement = element; // snap our associated window so we know when to disconnect. if (_htmlElement != null) { HtmlDocument doc = _htmlElement.Document; if (doc != null) { HtmlWindow window = doc.Window; if (window != null) { _associatedWindow = window.NativeHtmlWindow; } } } }
public void AddWindowShim(HtmlWindow window) { HtmlWindow.HtmlWindowShim addedShim = null; if (this.htmlWindowShims == null) { this.htmlWindowShims = new Dictionary <HtmlWindow, HtmlWindow.HtmlWindowShim>(); addedShim = new HtmlWindow.HtmlWindowShim(window); this.htmlWindowShims[window] = addedShim; } else if (!this.htmlWindowShims.ContainsKey(window)) { addedShim = new HtmlWindow.HtmlWindowShim(window); this.htmlWindowShims[window] = addedShim; } if (addedShim != null) { this.OnShimAdded(addedShim); } }
public void AddWindowShim(HtmlWindow window) { HtmlWindow.HtmlWindowShim addedShim = null; if (this.htmlWindowShims == null) { this.htmlWindowShims = new Dictionary<HtmlWindow, HtmlWindow.HtmlWindowShim>(); addedShim = new HtmlWindow.HtmlWindowShim(window); this.htmlWindowShims[window] = addedShim; } else if (!this.htmlWindowShims.ContainsKey(window)) { addedShim = new HtmlWindow.HtmlWindowShim(window); this.htmlWindowShims[window] = addedShim; } if (addedShim != null) { this.OnShimAdded(addedShim); } }
/// <summary> AddWindowShim - adds a HtmlWindowShim to list of shims to manage ///</summary> public void AddWindowShim(HtmlWindow window) { HtmlWindow.HtmlWindowShim shim = null; if (htmlWindowShims == null) { htmlWindowShims = new Dictionary <HtmlWindow, HtmlWindow.HtmlWindowShim>(); shim = new HtmlWindow.HtmlWindowShim(window); htmlWindowShims[window] = shim; } else if (!htmlWindowShims.ContainsKey(window)) { shim = new HtmlWindow.HtmlWindowShim(window); htmlWindowShims[window] = shim; } if (shim != null) { // strictly not necessary, but here for future use. OnShimAdded(shim); } }
public object ExecuteScript(HtmlWindow frame, string name, string par, string scripts, params object[] args) { object rlt = null; if (frame == null) { frame = Iframe; } if (string.IsNullOrEmpty(name)) { name = UniqueName(); } if (frame != null) { HtmlElement el = frame.Document.CreateElement("script"); IHTMLScriptElement script = el.DomElement as IHTMLScriptElement; script.text = string.Format("function {0}({1}){{ {2} }}", name, par, scripts); frame.Document.Body.AppendChild(el); rlt = InvokeScript(frame, name, args); } return rlt; }
internal void OnWindowUnloaded(HtmlWindow unloadedWindow) { if (unloadedWindow != null) { if (this.htmlDocumentShims != null) { HtmlDocument.HtmlDocumentShim[] array = new HtmlDocument.HtmlDocumentShim[this.htmlDocumentShims.Count]; this.htmlDocumentShims.Values.CopyTo(array, 0); foreach (HtmlDocument.HtmlDocumentShim shim in array) { if (shim.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { this.htmlDocumentShims.Remove(shim.Document); shim.Dispose(); } } } if (this.htmlElementShims != null) { HtmlElement.HtmlElementShim[] shimArray2 = new HtmlElement.HtmlElementShim[this.htmlElementShims.Count]; this.htmlElementShims.Values.CopyTo(shimArray2, 0); foreach (HtmlElement.HtmlElementShim shim2 in shimArray2) { if (shim2.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { this.htmlElementShims.Remove(shim2.Element); shim2.Dispose(); } } } if ((this.htmlWindowShims != null) && this.htmlWindowShims.ContainsKey(unloadedWindow)) { HtmlWindow.HtmlWindowShim shim3 = this.htmlWindowShims[unloadedWindow]; this.htmlWindowShims.Remove(unloadedWindow); shim3.Dispose(); } } }
/// <summary> /// Returns an observable sequence wrapping the Error event on the HtmlWindow instance. /// </summary> /// <param name="instance">The HtmlWindow instance to observe.</param> /// <returns>An observable sequence wrapping the Error event on the HtmlWindow instance.</returns> public static IObservable <EventPattern <HtmlElementErrorEventArgs> > ErrorObservable(this HtmlWindow instance) { return(Observable.FromEventPattern <HtmlElementErrorEventHandler, HtmlElementErrorEventArgs>( handler => instance.Error += handler, handler => instance.Error -= handler)); }
public HtmlWindowShim(HtmlWindow window) { this.htmlWindow = window; }
public HTMLWindowEvents2(HtmlWindow htmlWindow) { this.parent = htmlWindow; }
public HtmlDocument GetDoc(HtmlWindow frame) { HtmlDocument doc = null; if (frame != null) { doc = frame.Document; } else if (Iframe != null) { doc = Iframe.Document; } else if (Browser != null) { doc = Browser.Document; } return doc; }
/// <summary> /// 正規賽賽事資料處理 /// </summary> /// <param name="allianceID">聯盟編號</param> /// <param name="gameType">賽事種類</param> /// <param name="acH">是否主客互換</param> /// <param name="calendar">arenaCalendar HtmlWindow 物件</param> /// <param name="schedules">賽程資料</param> /// <returns>賽程資料</returns> private Dictionary<string, GameInfo> GetScheduleOnRegular(int allianceID, string gameType, bool acH, HtmlWindow calendar, Dictionary<string, GameInfo> schedules) { DateTime gameDate = DateTime.Now.AddDays(-100);//初始化 DateTime gameDate_old = DateTime.Now.AddDays(-100);//初始化 DateTime gameTime = DateTime.Now; WebClient client = new WebClient(); HtmlElementCollection dataDoc = calendar.Document.GetElementsByTagName("table"); // 資料 foreach (HtmlElement table in dataDoc) { HtmlElementCollection trDoc = table.GetElementsByTagName("tr"); // 沒有資料就往下處理 if (trDoc.Count <= 2) continue; if (string.IsNullOrEmpty(trDoc[0].InnerText) || !DateTime.TryParse(trDoc[0].InnerText, out gameDate)) continue; string html = String.Empty; foreach (HtmlElement tr in trDoc) { // 沒有資料就往下處理 if (string.IsNullOrEmpty(tr.InnerText)) continue; HtmlElementCollection td = tr.GetElementsByTagName("td"); string webId = null; bool isReschedule = false; #region 取得日期 if (td.Count == 1) { // 轉成日期失敗就往下處理 if (!DateTime.TryParse(tr.InnerText, out gameDate)) { continue; } else if (gameDate != gameDate_old) { gameDate_old = gameDate; html = GetScoreBoardWeb(gameDate, client); if (html != null && html.IndexOf("No games scheduled.") != -1) { //没有赛事 尝试去热身赛 html = GetScoreBoardWeb2(gameDate, client); } if (String.IsNullOrEmpty(html)) { continue; } } } #endregion #region 取得時間 if (td.Count < 6) continue; // 轉成時間失敗就往下處理 string dateTime = String.Format("{0:yyyy-MM-dd} {1}", gameDate, td[2].InnerText); if (!DateTime.TryParse(dateTime, out gameTime)) { continue; } #endregion #region 跟盤 ID // HtmlDocument HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); // 取得跟盤編號 string away = td[0].InnerText.Trim(); string home = td[1].InnerText.Trim(); webId = FindScheduleWebID(schedules, doc, ref away, ref home); // 沒有編號就往下處理 if (string.IsNullOrEmpty(webId)) continue; #endregion GameInfo schedule = new GameInfo(allianceID, gameType, gameTime, webId, isReschedule) { AcH = acH, Away = away, Home = home }; // 加入比賽資料 schedules[schedule.WebID] = schedule; } } // 傳回 return schedules; }
/// <summary> /// Returns an observable sequence wrapping the Unload event on the HtmlWindow instance. /// </summary> /// <param name="instance">The HtmlWindow instance to observe.</param> /// <returns>An observable sequence wrapping the Unload event on the HtmlWindow instance.</returns> public static IObservable <EventPattern <HtmlElementEventArgs> > UnloadObservable(this HtmlWindow instance) { return(Observable.FromEventPattern <HtmlElementEventHandler, HtmlElementEventArgs>( handler => instance.Unload += handler, handler => instance.Unload -= handler)); }
internal HtmlWindow.HtmlWindowShim GetWindowShim(HtmlWindow window) { if (htmlWindowShims == null) { return null; } if (htmlWindowShims.ContainsKey(window)) { return htmlWindowShims[window]; } return null; }
public void setBrowser(HtmlWindow browser) { this.browser = browser; }
internal HtmlWindow.HtmlWindowShim GetWindowShim(HtmlWindow window) { if ((this.htmlWindowShims != null) && this.htmlWindowShims.ContainsKey(window)) { return this.htmlWindowShims[window]; } return null; }
public object InvokeScript(HtmlWindow frame, string name, params object[] args) { HtmlDocument doc = GetDoc(frame); return doc.InvokeScript(name, args); }
protected bool TryGetMainFrame(out HtmlWindow mainFrame) { mainFrame = null; if (Document == null) return false; if (Document.Window == null) return false; if (Document.Window.Frames == null) return false; mainFrame = GetFrame("main"); return mainFrame != null; }
public HtmlWindowShim(HtmlWindow window) { _htmlWindow = window; }
/// <devdoc> /// HtmlWindowShim calls back on us when it has unloaded the page. At this point we need to /// walk through our lists and make sure we've cleaned up /// </devdoc> internal void OnWindowUnloaded(HtmlWindow unloadedWindow) { Debug.Assert(unloadedWindow != null, "Why are we calling this with a null window?"); if (unloadedWindow != null) { // // prune documents // if (htmlDocumentShims != null) { HtmlDocument.HtmlDocumentShim[] shims = new HtmlDocument.HtmlDocumentShim[htmlDocumentShims.Count]; htmlDocumentShims.Values.CopyTo(shims,0); foreach (HtmlDocument.HtmlDocumentShim shim in shims) { if (shim.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { htmlDocumentShims.Remove(shim.Document); shim.Dispose(); } } } // // prune elements // if (htmlElementShims != null) { HtmlElement.HtmlElementShim[] shims = new HtmlElement.HtmlElementShim[htmlElementShims.Count]; htmlElementShims.Values.CopyTo(shims,0); foreach (HtmlElement.HtmlElementShim shim in shims) { if (shim.AssociatedWindow == unloadedWindow.NativeHtmlWindow) { htmlElementShims.Remove(shim.Element); shim.Dispose(); } } } // // prune the particular window from the list. // if (htmlWindowShims != null) { if (htmlWindowShims.ContainsKey(unloadedWindow)) { HtmlWindow.HtmlWindowShim shim = htmlWindowShims[unloadedWindow]; htmlWindowShims.Remove(unloadedWindow); shim.Dispose(); } } } }
public IEnumerator GetEnumerator() { HtmlWindow[] array = new HtmlWindow[this.Count]; ((ICollection)this).CopyTo(array, 0); return(array.GetEnumerator()); }
/// <include file='doc\HtmlWindowCollection.uex' path='docs/doc[@for="HtmlWindowCollection.GetEnumerator"]/*' /> /// <internalonly/> public IEnumerator GetEnumerator() { HtmlWindow[] htmlWindows = new HtmlWindow[this.Count]; ((ICollection)this).CopyTo(htmlWindows, 0); return htmlWindows.GetEnumerator(); }
/// <summary> /// Returns an observable sequence wrapping the LostFocus event on the HtmlWindow instance. /// </summary> /// <param name="instance">The HtmlWindow instance to observe.</param> /// <returns>An observable sequence wrapping the LostFocus event on the HtmlWindow instance.</returns> public static IObservable <EventPattern <HtmlElementEventArgs> > LostFocusObservable(this HtmlWindow instance) { return(Observable.FromEventPattern <HtmlElementEventHandler, HtmlElementEventArgs>( handler => instance.LostFocus += handler, handler => instance.LostFocus -= handler)); }
public IEnumerator GetEnumerator() { HtmlWindow[] array = new HtmlWindow[this.Count]; ((ICollection) this).CopyTo(array, 0); return array.GetEnumerator(); }
public void RefreshIframe() { if (Browser != null) { iframe = Browser.Document.Window.Frames[0]; } }