Ejemplo n.º 1
0
 public void WaitFor(Func <bool> done)
 {
     //int i = 0;
     //while (!done () && i < 10) {
     //    Thread.Sleep (5);
     //    i++;
     //}
     WpfExtensions.DoEvents();
 }
Ejemplo n.º 2
0
 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 ());
     }
 }
Ejemplo n.º 3
0
        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();
                        }
                    }
                }
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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;
        }