internal CefGlueWPFWebWindow() { _WpfCefBrowser = new WpfCefBrowser() { Visibility = Visibility.Hidden, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, ContextMenu = new ContextMenu() { Visibility = Visibility.Collapsed } }; }
public WpfCefClient(WpfCefBrowser owner) { if (owner == null) throw new ArgumentNullException("owner"); _owner = owner; _lifeSpanHandler = new WpfCefLifeSpanHandler(owner); _displayHandler = new WpfCefDisplayHandler(owner); _renderHandler = new WpfCefRenderHandler(owner, new NLogLogger("WpfCefRenderHandler"), new UiHelper(new NLogLogger("WpfCefRenderHandler"))); }
public WpfCefClient(WpfCefBrowser owner) { if (owner == null) throw new ArgumentNullException("owner"); _owner = owner; _lifeSpanHandler = new WpfCefLifeSpanHandler(owner); _displayHandler = new WpfCefDisplayHandler(owner); _CefNoContextMenuHandler = new CefNoContextMenuHandler(); _renderHandler = new WpfCefRenderHandler(owner, Logger.Log, new UiHelper(Logger.Log)); _loadHandler = new WpfCefLoadHandler(owner); }
internal CefGlueWPFWebWindow(NeutroniumCefApp app) { _WpfCefBrowser = new WpfCefBrowser(app) { Visibility = Visibility.Hidden, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, ContextMenu = new ContextMenu() { Visibility = Visibility.Collapsed } }; }
public WpfCefRenderHandler(WpfCefBrowser owner, ILogger logger, IUiHelper uiHelper) { if (owner == null) { throw new ArgumentNullException("owner"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (uiHelper == null) { throw new ArgumentNullException("uiHelper"); } _owner = owner; _logger = logger; _uiHelper = uiHelper; }
public WpfCefLoadHandler(WpfCefBrowser owner) { this._owner = owner; }
public WpfCefDisplayHandler(WpfCefBrowser owner) { if (owner == null) throw new ArgumentNullException("owner"); _owner = owner; }
internal void Associate(CefBrowser browser, WpfCefBrowser wpfBrowser) { _Browsers.Add(browser.Identifier, wpfBrowser); }
private void Switch(Task<IHTMLBinding> iBinding, HTMLLogicWindow iwindow, TaskCompletionSource<IHTMLBinding> tcs) { object oldvm = (Binding != null) ? Binding.Root : null; Binding = iBinding.Result; if (_CurrentWebControl!=null) { _CurrentWebControl.ConsoleMessage -= ConsoleMessage; _IWebViewLifeCycleManager.Dispose(_CurrentWebControl); } else if (OnFirstLoad != null) OnFirstLoad(this, EventArgs.Empty); _CurrentWebControl = _NextWebControl; _NextWebControl = null; //_CurrentWebControl.Crashed += Crashed; _IWebViewLifeCycleManager.Display(_CurrentWebControl); _Window = iwindow; _Window.State = WindowLogicalState.Opened; _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root)); _Navigating = false; var inav = _UseINavigable ? Binding.Root as INavigable : null; if (inav != null) inav.Navigation = this; FireNavigate(Binding.Root, oldvm); if (tcs != null) tcs.SetResult(Binding); }
private void CleanWebControl(ref WpfCefBrowser iWebControl) { if (iWebControl == null) return; //iWebControl.Crashed -= Crashed; iWebControl.ConsoleMessage -= ConsoleMessage; _IWebViewLifeCycleManager.Dispose(iWebControl); iWebControl = null; }
//private void Crashed(object sender, CrashedEventArgs e) //{ // if ((WebCore.IsShuttingDown) || (!WebCore.IsInitialized) || (Application.Current==null)) // return; // var dest = _CurrentWebControl.Source; // var vm = Binding.Root; // LogCritical("WebView crashed trying recover"); // _IWebViewLifeCycleManager.Dispose(_CurrentWebControl); // _CurrentWebControl.ConsoleMessage -= ConsoleMessage; // _CurrentWebControl.Crashed -= Crashed; // _CurrentWebControl = null; // Binding = null; // WebCore.QueueWork(() => Navigate(dest, vm, JavascriptBindingMode.TwoWay)); //} public Task Navigate(string iUri, object iViewModel, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if (iUri == null) throw ExceptionHelper.GetArgument(string.Format("ViewModel not registered: {0}", iViewModel.GetType())); _Navigating = true; INavigable oldvm = (Binding != null) ? Binding.Root as INavigable : null; if (_UseINavigable && (oldvm!=null)) { oldvm.Navigation = null; } var wh = new WindowHelper(new HTMLLogicWindow()); //if (_CurrentWebControl != null) // _CurrentWebControl.Crashed -= Crashed; Task closetask = ( _CurrentWebControl!=null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _IWebViewLifeCycleManager.Create(); _NextWebControl.ConsoleMessage += ConsoleMessage; TaskCompletionSource<IHTMLBinding> tcs = new TaskCompletionSource<IHTMLBinding>(); EventHandler<LoadEndEventArgs> sourceupdate = null; sourceupdate = (o, e) => { _NextWebControl.LoadEnd -= sourceupdate; HTML_Binding.Bind(_NextWebControl, iViewModel, iMode, wh). WaitWith(closetask, t => Switch(t, wh.__window__, tcs)); }; _NextWebControl.LoadEnd += sourceupdate; _NextWebControl.NavigateTo(iUri); return tcs.Task; }
void IWebViewLifeCycleManager.Dispose(WpfCefBrowser ioldwebview) { //var wb = (ioldwebview as WebControl); ioldwebview.Visibility = Visibility.Hidden; //if (!ioldwebview.IsCrashed) //{ // ioldwebview.Source = new Uri("about:blank"); //} //WebCore.ShuttingDown -= WebCore_ShuttingDown; this.MainGrid.Children.Remove(ioldwebview); ioldwebview.Dispose(); }
//private void WebCore_ShuttingDown(object sender, CoreShutdownEventArgs e) //{ // //It is possible that webcore is shutting because the window is closing // //In this case I don't have to raise a session error // if (Application.Current == null) // { // e.Cancel = true; // return; // } // _IWebSessionWatcher.LogCritical("Critical: WebCore ShuttingDown!!"); // Trace.WriteLine(string.Format("MVVM for awesomium: WebCoreShutting Down exception: {0}", e.Exception)); // _IWebSessionWatcher.OnSessionError(e.Exception, () => e.Cancel = true); //} void IWebViewLifeCycleManager.Display(WpfCefBrowser webview) { webview.Visibility = Visibility.Visible; }
WpfCefBrowser IWebViewLifeCycleManager.Create() { //if (_Session == null) //{ // _Session = (_WebSessionPath != null) ? WebCore.CreateWebSession(_WebSessionPath, new WebPreferences()) : // WebCore.CreateWebSession(new WebPreferences()); // WebCore.ShuttingDown += WebCore_ShuttingDown; //} WpfCefBrowser nw = new WpfCefBrowser() { Visibility = Visibility.Hidden, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, ContextMenu = new ContextMenu() { Visibility = Visibility.Collapsed } }; Grid.SetColumnSpan(nw, 2); Grid.SetRowSpan(nw, 2); Panel.SetZIndex(nw, 0); this.MainGrid.Children.Add(nw); return nw; }