public void WaitFor(Func <bool> done) { //int i = 0; //while (!done () && i < 10) { // Thread.Sleep (5); // i++; //} WpfExtensions.DoEvents(); }
protected void BlockUntilNavigationFinished() { BlockUntilNavigationFinishedDone = false; this.DocumentCompleted -= BlockUntilNavigationFinishedEvent; this.DocumentCompleted += BlockUntilNavigationFinishedEvent; this.NavigationError -= BlockUntilNavigationFinishedEvent; this.NavigationError += BlockUntilNavigationFinishedEvent; while (!BlockUntilNavigationFinishedDone) { WpfExtensions.DoEvents(); //Application.RaiseIdle (new EventArgs ()); } }
protected void InternalLoadContent(string content, string url, string contentType) { if (!IsHandleCreated) { WpfExtensions.DoEvents(); } using (var sContentType = new nsACString(contentType)) using (var sUtf8 = new nsACString("UTF8")) { ByteArrayInputStream inputStream = null; try { inputStream = ByteArrayInputStream.Create(System.Text.Encoding.UTF8.GetBytes(content != null ? content : string.Empty)); var docShell = Xpcom.QueryInterface <nsIDocShell> (this.WebBrowser); nsIURI uri = null; if (!string.IsNullOrEmpty(url)) { uri = IOService.CreateNsIUri(url); } nsIDocShellLoadInfo l = null; if (true) { l = Xpcom.QueryInterface <nsIDocShellLoadInfo> (this.WebBrowser); docShell.CreateLoadInfo(ref l); l.SetLoadTypeAttribute(new IntPtr(16)); } docShell.LoadStream(inputStream, uri, sContentType, sUtf8, l); Marshal.ReleaseComObject(docShell); if (l != null) { Marshal.ReleaseComObject(l); } } finally { if (inputStream != null) { inputStream.Close(); } } } }
public void MakeReady() { BlockUntilNavigationFinishedDone = true; if (!IsHandleCreated) { WpfExtensions.DoEvents(); } if (base.Document == null) { base.Navigate("about:blank"); for (int i = 0; i < 200 && IsBusy; i++) { WpfExtensions.DoEvents(); Thread.Sleep(5); } } else { Stop(); } }
protected virtual void ComposeStyle() { var style = new Style(); // set opacity to 50% if not enabled: var trigger = new DataTrigger { Value = false, Binding = WpfExtensions.Binding(this, o => o.IsEnabled, BindingMode.OneWay), }; var setter = new Setter { Property = UIElement.OpacityProperty, Value = 0.5, }; trigger.Setters.Add(setter); style.Triggers.Add(trigger); var baseStyle = ToolbarUtils.ToolbarItemStyle(this); style.TargetType = baseStyle.TargetType; style.BasedOn = baseStyle; this.Style = style; }