private Task <CfxBrowser> RawInit(string path) { var loadTaskCompletionSource = new TaskCompletionSource <CfxBrowser>(); var cfxWindowInfo = new CfxWindowInfo(); _CfxClient = new CfxClient(); var loadHandler = new CfxLoadHandler(); loadHandler.OnLoadEnd += (sender, args) => { loadTaskCompletionSource.TrySetResult(args.Browser); }; _CfxClient.GetLoadHandler += (o, e) => e.SetReturnValue(loadHandler); var lifeSpanHandler = new CfxLifeSpanHandler(); _CfxClient.GetLifeSpanHandler += (o, e) => e.SetReturnValue(lifeSpanHandler); var renderHandler = new CfxRenderHandler(); _CfxClient.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); if (!CfxBrowserHost.CreateBrowser(cfxWindowInfo, _CfxClient, path, GetSettings(), null, null)) { throw new Exception("Problem initializing CEF"); } return(loadTaskCompletionSource.Task); }
public ArkDesktopBrowserControl() { #region Handler lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += LifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); //renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; //renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; //renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.GetScreenPoint += RenderHandler_GetScreenPoint; renderHandler.GetViewRect += RenderHandler_GetViewRect; renderHandler.OnPaint += RenderHandler_OnPaint; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += LoadHandler_OnLoadError; loadHandler.OnLoadEnd += LoadHandler_OnLoadEnd; #endregion client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); var settings = new CfxBrowserSettings(); settings.BackgroundColor = new CfxColor(0, 0, 0, 0); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(IntPtr.Zero); CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null); }
private void Register() { lifeSpanHandler = new CfxLifeSpanHandler(); renderHandler = new CfxRenderHandler(); loadHandler = new CfxLoadHandler(); client = new CfxClient(); windowInfo = new CfxWindowInfo(); browserSettings = new CfxBrowserSettings { WindowlessFrameRate = 60 }; mouseEvent = new CfxMouseEvent(); lifeSpanHandler.OnAfterCreated += (sender, args) => { browser = args.Browser; Thread.Sleep(100); }; renderHandler.GetViewRect += (sender, args) => { CalculatedStyle dimensions = GetDimensions(); args.Rect.X = 0; args.Rect.Y = 0; args.Rect.Width = (int)dimensions.Width; args.Rect.Height = (int)dimensions.Height; args.SetReturnValue(true); }; renderHandler.GetScreenPoint += (sender, args) => { args.ScreenX = 0; args.ScreenY = 0; args.SetReturnValue(true); }; loadHandler.OnLoadError += (sender, args) => { if (args.ErrorCode == CfxErrorCode.Aborted) { var url = args.FailedUrl; var frame = args.Frame; ThreadPool.QueueUserWorkItem(state => { Thread.Sleep(200); frame.LoadUrl(url); }); } }; client.GetLifeSpanHandler += (sender, args) => args.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, args) => args.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, args) => args.SetReturnValue(loadHandler); windowInfo.SetAsWindowless(IntPtr.Zero); CfxBrowserHost.CreateBrowser(windowInfo, client, URL, browserSettings, null); }
/// <summary> /// Creates the underlying CfxBrowser with the given CfxRequestContext. /// This method should only be called if this ChromiumWebBrowser /// was instanciated with createImmediately == false. /// </summary> public void CreateBrowser(CfxRequestContext requestContext) { // avoid illegal cross-thread calls if (InvokeRequired) { Invoke((MethodInvoker)(() => CreateBrowser(requestContext))); return; } var windowInfo = new CfxWindowInfo(); windowInfo.SetAsChild(Handle, 0, 0, Height > 0 ? Height : 500, Width > 0 ? Width : 500); if (!CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, DefaultBrowserSettings, requestContext)) { throw new ChromiumWebBrowserException("Failed to create browser instance."); } }
private void CreateBrowser() { var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(IntPtr.Zero); windowInfo.WindowlessRenderingEnabled = true; windowInfo.SharedTextureEnabled = true; windowInfo.ExternalBeginFrameEnabled = InitSettings.FrameRequestFromVvvv; if (Browser != null) { Browser.Host.CloseBrowser(true); Browser = null; } CfxBrowserHost.CreateBrowser(windowInfo, Client, "", Settings, null); }
public HtmlWidgetForm(string initialUrl) { FormBorderStyle = FormBorderStyle.None; mutex = new Mutex(false, string.Format("NanUIWidget{0}", Process.GetCurrentProcess().Id), out locked); lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; renderHandler.GetScreenPoint += renderHandler_GetScreenPoint; renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.OnPaint += renderHandler_OnPaint; //renderHandler.OnPopupShow += renderHandler_OnPopupShow; //renderHandler.OnPopupSize += renderHandler_OnPopupSize; //renderHandler.OnScrollOffsetChanged += renderHandler_OnScrollOffsetChanged; //renderHandler.StartDragging += renderHandler_StartDragging; //renderHandler.UpdateDragCursor += renderHandler_UpdateDragCursor; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); var settings = new CfxBrowserSettings(); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(false); windowInfo.TransparentPaintingEnabled = true; CreateHandle(); CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, settings, null); }
public void Create(CfxWindowInfo windowInfo) { if (windowInfo == null) { windowInfo = new CfxWindowInfo(); } if (string.IsNullOrEmpty(startUrl)) { startUrl = ABOUT_BLANK; } windowInfo.SetAsDisabledChild(OwnerHandle); if (!CfxBrowserHost.CreateBrowser(windowInfo, Client, startUrl, browserSettings, null, null)) { throw new WebBrowserException("Failed to create browser instance."); } }
/// <summary> /// Creates the underlying CfxBrowser with the given CfxRequestContext. /// This method should only be called if this ChromiumWebBrowser /// was instanciated with createImmediately == false. /// </summary> public void CreateBrowser(CfxRequestContext requestContext) { // avoid illegal cross-thread calls if (InvokeRequired) { Invoke((MethodInvoker)(() => CreateBrowser(requestContext))); return; } var parentHandle = this.Handle; //var rect = this.ClientRectangle; //if (this.Parent != null) //{ // parentHandle = this.Parent.Handle; // rect = this.Parent.ClientRectangle; //} var windowInfo = new CfxWindowInfo(); //this.ImeMode = ImeMode.Inherit; //if (WindowLess) { // // in order to avoid focus issues when creating browsers offscreen, // // the browser must be created with a disabled child window. // windowInfo.SetAsDisabledChild(parentHandle); // //windowInfo.SetAsChild (); //} else { //windowInfo.SetAsChild(parentHandle, rect.Left, rect.Top, rect.Width, rect.Height); //windowInfo.SetAsDisabledChild(parentHandle); // //windowInfo.Style = WindowStyle.WS_CHILD; //} // this work in windows. windowInfo.SetAsDisabledChild(parentHandle); if (!CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, DefaultBrowserSettings, requestContext)) { throw new ChromiumWebBrowserException("Failed to create browser instance."); } }
public ArkDesktopBrowserControl(ArkDesktop.LayeredWindow window) { #region Handler lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += LifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); //renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; //renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; //renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.GetScreenPoint += RenderHandler_GetScreenPoint; renderHandler.GetViewRect += RenderHandler_GetViewRect; renderHandler.OnPaint += RenderHandler_OnPaint; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += LoadHandler_OnLoadError; loadHandler.OnLoadEnd += LoadHandler_OnLoadEnd; requestHandler = new CfxRequestHandler(); requestHandler.GetResourceHandler += RequestHandler_GetResourceHandler; #endregion client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); //client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); client.GetRequestHandler += (sender, e) => e.SetReturnValue(requestHandler); var settings = new CfxBrowserSettings(); settings.BackgroundColor = new CfxColor(0, 0, 0, 0); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(IntPtr.Zero); CfxBrowserHost.CreateBrowser(windowInfo, client, "http://www.bing.com/", settings, null); this.window = window; window.MouseDown += Window_MouseDown; window.MouseUp += Window_MouseUp; window.MouseMove += Window_MouseMove; }
public BrowserControl() { SetStyle(ControlStyles.AllPaintingInWmPaint, true); lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; renderHandler.GetScreenPoint += renderHandler_GetScreenPoint; renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.OnPaint += renderHandler_OnPaint; //renderHandler.OnPopupShow += renderHandler_OnPopupShow; //renderHandler.OnPopupSize += renderHandler_OnPopupSize; //renderHandler.OnScrollOffsetChanged += renderHandler_OnScrollOffsetChanged; //renderHandler.StartDragging += renderHandler_StartDragging; //renderHandler.UpdateDragCursor += renderHandler_UpdateDragCursor; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); var settings = new CfxBrowserSettings(); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(false); // Create handle now for InvokeRequired to work properly CreateHandle(); CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null); }
public ArkDesktopBrowserControl() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); #region Handler lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += LifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); //renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; //renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; //renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.GetScreenPoint += RenderHandler_GetScreenPoint; renderHandler.GetViewRect += RenderHandler_GetViewRect; renderHandler.OnPaint += RenderHandler_OnPaint; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += LoadHandler_OnLoadError; #endregion client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); var settings = new CfxBrowserSettings(); settings.BackgroundColor = new CfxColor(0, 0, 0, 0); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(IntPtr.Zero); // Create handle now for InvokeRequired to work properly CreateHandle(); CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null); }
/// <summary> /// 创建一个浏览器窗口 /// </summary> /// <param name="formHandle">当前承载浏览器窗口的 Form 窗体的句柄号(Handle)</param> /// <param name="defWidth">默认宽度</param> /// <param name="defHeight">默认高度</param> /// <param name="initialUrl">初始的超链接,默认为空白页</param> /// <returns></returns> public IWebBrowserWindow CreateBrowser(IntPtr formHandle, int defWidth, int defHeight, string initialUrl = "about:blank") { if (!Bootstrapper.Current.IsStarted) { Bootstrapper.Current.Start(); } var browserWindow = new WebBrowserWindow(defWidth, defHeight); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsDisabledChild(formHandle); var browserSettings = new CfxBrowserSettings(); if (!CfxBrowserHost.CreateBrowser(windowInfo, browserWindow._browserClient, initialUrl, browserSettings, null)) { throw new WebEngineException("对不起!浏览器窗口创建失败,请确认所有配置正确后重试。"); } _browsers.Add(new WebBrowserReference(browserWindow)); return(browserWindow); }
//called when data for any output pin is requested public void Update(int SpreadMax) { if (this.FTextureOutput[0] == null) { this.FTextureOutput[0] = new DX11Resource <DX11DynamicTexture2D>(); } if (!init) { width = DEFAULT_WIDTH; height = DEFAULT_HEIGHT; lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; lifeSpanHandler.OnBeforePopup += lifeSpanHandler_OnBeforePopup; renderHandler = new CfxRenderHandler(); renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.OnPaint += renderHandler_OnPaint; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; loadHandler.OnLoadingStateChange += loadHandler_OnLoadingStateChange; requestHandler = new CfxRequestHandler(); requestHandler.OnBeforeBrowse += requestHandler_OnBeforeBrowse; requestHandler.OnBeforeResourceLoad += requestHandler_OnBeforeResourceLoad; displayHandler = new CfxDisplayHandler(); displayHandler.OnConsoleMessage += displayHandler_OnConsoleMessage; client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); client.GetRequestHandler += (sender, e) => e.SetReturnValue(requestHandler);; client.GetDisplayHandler += (sender, e) => e.SetReturnValue(displayHandler);; settings = new CfxBrowserSettings(); settings.WindowlessFrameRate = 60; settings.Webgl = CfxState.Enabled; settings.Plugins = CfxState.Enabled; settings.ApplicationCache = CfxState.Enabled; settings.CaretBrowsing = CfxState.Enabled; settings.Javascript = CfxState.Enabled; settings.FileAccessFromFileUrls = CfxState.Enabled; settings.UniversalAccessFromFileUrls = CfxState.Enabled; settings.WebSecUrity = CfxState.Disabled; visitor = new CfxStringVisitor(); visitor.Visit += visitor_Visit; // set path to js string lpPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "livepage"); LIVEPAGE_LOAD_FUNC = File.ReadAllText(Path.Combine(lpPath, "load.js")) + File.ReadAllText(Path.Combine(lpPath, "live_resource.js")) + File.ReadAllText(Path.Combine(lpPath, "livepage.js")); LIVEPAGE_UNLOAD_FUNC = File.ReadAllText(Path.Combine(lpPath, "unload.js")); mouseEvent = new CfxMouseEvent(); keyCode = new List <int>(); createBrowser = true; invalidate = true; init = true; } if (FTransparentIn.IsChanged) { createBrowser = true; } if (createBrowser) { var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(FTransparentIn[0]); //windowInfo.WindowlessRenderingEnabled = true; //windowInfo.TransparentPaintingEnabled = false; if (browser != null) { browser.Host.CloseBrowser(true); browser = null; } CfxBrowserHost.CreateBrowser(windowInfo, client, "", settings, null); createBrowser = false; } if (FMethodIn.IsChanged) { if (method == null || method.Length != FMethodIn.SliceCount) { method = new bool[FMethodIn.SliceCount]; } FResultOut.SliceCount = FMethodIn.SliceCount; FMethodOut.SliceCount = FMethodIn.SliceCount; } if (FLivePageIn.IsChanged) { ExecuteJavascript(FLivePageIn[0] ? LIVEPAGE_LOAD_FUNC : LIVEPAGE_UNLOAD_FUNC); } if (FZoomLevelIn.IsChanged) { zoomLevel = VMath.Map(FZoomLevelIn[0], 0, 1, 0, 10, TMapMode.Clamp); } for (int i = 0; i < FMethodOut.SliceCount; i++) { FMethodOut[i] = method[i]; method[i] = false; } if (browser != null) { if (FShowDevToolsIn.IsChanged && FShowDevToolsIn[0]) { CfxWindowInfo windowInfo = new CfxWindowInfo(); windowInfo.Style = WindowStyle.WS_OVERLAPPEDWINDOW | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_VISIBLE; windowInfo.ParentWindow = IntPtr.Zero; windowInfo.WindowName = "DevTools"; windowInfo.X = 200; windowInfo.Y = 200; windowInfo.Width = 800; windowInfo.Height = 600; browser.Host.ShowDevTools(windowInfo, new CfxClient(), new CfxBrowserSettings(), null); } // mouse if (FTouchIn.IsChanged && FTouchIn.SliceCount > 0) { mouseEvent.X = (int)VMath.Map(FTouchIn[0].x, -1, 1, 0, width, TMapMode.Float); mouseEvent.Y = (int)VMath.Map(FTouchIn[0].y, 1, -1, 0, height, TMapMode.Float); if (!isTouch) { browser.Host.SendMouseClickEvent(mouseEvent, CfxMouseButtonType.Left, false, 1); } else { browser.Host.SendMouseMoveEvent(mouseEvent, false); } isTouch = true; } if (isTouch && FTouchIn.SliceCount == 0) { browser.Host.SendMouseClickEvent(mouseEvent, CfxMouseButtonType.Left, true, 1); isTouch = false; } // keyboard for (int i = 0; i < keyCode.Count; i++) { if (!FKeyCodeIn.Contains(keyCode[i])) { CfxKeyEvent keyEvent = new CfxKeyEvent(); keyEvent.Type = CfxKeyEventType.Keyup; keyEvent.WindowsKeyCode = keyCode[i]; keyEvent.NativeKeyCode = keyCode[i]; browser.Host.SendKeyEvent(keyEvent); keyCode.RemoveAt(i); i--; } } if (FKeyCharIn.SliceCount > 0 && FKeyCodeIn.SliceCount > 0) { int count = Math.Max(FKeyCharIn.SliceCount, FKeyCodeIn.SliceCount); for (int i = 0; i < count; i++) { int code = FKeyCodeIn[i]; if (code >= 0 && FKeyEventTypeIn[i] != KeyNotificationKind.KeyUp && !keyCode.Contains(code)) { CfxKeyEvent keyEvent = new CfxKeyEvent(); keyEvent.Type = CfxKeyEventType.Keydown; keyEvent.WindowsKeyCode = code; keyEvent.NativeKeyCode = code; browser.Host.SendKeyEvent(keyEvent); } short ch = (short)(FKeyCharIn[i].Length > 0 ? FKeyCharIn[i][0] : 0); if (ch > 0) { CfxKeyEvent keyEvent = new CfxKeyEvent(); keyEvent.Type = CfxKeyEventType.Char; keyEvent.Character = ch; keyEvent.UnmodifiedCharacter = ch; keyEvent.WindowsKeyCode = ch; keyEvent.NativeKeyCode = ch; browser.Host.SendKeyEvent(keyEvent); } } } if (FReloadIn[0]) { browser.ReloadIgnoreCache(); } if (zoomLevel != browser.Host.ZoomLevel) { browser.Host.ZoomLevel = zoomLevel; } if (FUpdateDomIn[0]) { browser.MainFrame.GetSource(visitor); } if (isDocumentReady) { if (FBindIn.IsChanged && FBindIn[0] && FMethodIn.SliceCount > 0) { BindFunctions(FObjectIn[0], FMethodIn.ToArray()); } if (FScrollToIn.IsChanged) { scroll = FScrollToIn[0]; ExecuteJavascript( string.Format(System.Globalization.CultureInfo.InvariantCulture, @"window.scrollTo({0} * document.body.scrollWidth, {1} * document.body.scrollHeight);", scroll.x, scroll.y ) ); } } if (FExecuteIn[0]) { ExecuteJavascript(FJavaScriptIn[0]); } if (FEvaluateJavaScriptIn[0]) { EvaluateJavascript(FJavaScriptIn[0], (value, exception) => { FResultJSOut[0] = CfrV8ValueToString(value); }); } } if (FWidthIn.IsChanged || FHeightIn.IsChanged) { if (FWidthIn.SliceCount > 0 && FHeightIn.SliceCount > 0 && FWidthIn[0] > 0 && FHeightIn[0] > 0) { lock (bLock) { width = FWidthIn[0]; height = FHeightIn[0]; image = new byte[width * height * 4]; isImageReady = false; } if (browser != null) { browser.Host.WasResized(); } invalidate = true; } } FIsLoadingOut[0] = !isDocumentReady; this.Mouse = FMouseIn[0]; this.Keyboard = FKeyboardIn[0]; //CfxRuntime.DoMessageLoopWork(); }
private void MyCtor(Control parent) { _mono = Type.GetType("Mono.Runtime") != null; this.Parent = parent; //SetStyle( // ControlStyles.ResizeRedraw // | ControlStyles.FixedWidth // | ControlStyles.FixedHeight // | ControlStyles.StandardClick // | ControlStyles.StandardDoubleClick // | ControlStyles.UserMouse // | ControlStyles.SupportsTransparentBackColor // | ControlStyles.DoubleBuffer // | ControlStyles.OptimizedDoubleBuffer // | ControlStyles.Opaque // , false); SetStyle(ControlStyles.AllPaintingInWmPaint, true); Console.WriteLine("can enable ime:" + this.CanEnableIme); this.ImeMode = ImeMode.On; client = new BrowserClient(this); //client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); //client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); //client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); //client.GetKeyboardHandler += (sender, e) => e.SetReturnValue(keyboardHandler); //lifeSpanHandler = new CfxLifeSpanHandler(); //lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; renderHandler = client.RenderHandler;// new CfxRenderHandler(); renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; renderHandler.GetScreenPoint += renderHandler_GetScreenPoint; renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.OnPaint += renderHandler_OnPaint; //renderHandler.OnPopupShow += renderHandler_OnPopupShow; //renderHandler.OnPopupSize += renderHandler_OnPopupSize; //renderHandler.OnScrollOffsetChanged += renderHandler_OnScrollOffsetChanged; //renderHandler.StartDragging += renderHandler_StartDragging; //renderHandler.UpdateDragCursor += renderHandler_UpdateDragCursor; loadHandler = client.LoadHandler;// new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; keyboardHandler = new CfxKeyboardHandler(); keyboardHandler.OnPreKeyEvent += KeyboardHandler_OnPreKeyEvent; lifeSpanHandler = client.lifeSpanHandler; lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; var settings = new CfxBrowserSettings(); var windowInfo = new CfxWindowInfo(); if (CfxRuntime.PlatformOS == CfxPlatformOS.Windows) { windowInfo.SetAsWindowless(this.Parent.Handle); } else { windowInfo.SetAsWindowless(this.Parent.Handle); } //windowInfo.SetAsWindowless(this.Parent.Handle); // Create handle now for InvokeRequired to work properly // CreateHandle(); if (string.IsNullOrEmpty(initialUrl)) { initialUrl = "about:version"; } GlobalObject = new JSObject(); GlobalObject.SetBrowser("window", this); // CreateHandle(); // CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null); //Browser = CfxBrowserHost.CreateBrowserSync(windowInfo, client, initialUrl, settings, null); //if (!CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, settings, null)) // throw new ChromiumWebBrowserException("Failed to create browser instance."); CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, settings, null); }
private void MyCtor(Control parent) { _mono = Type.GetType("Mono.Runtime") != null; this.Parent = parent; SetStyle(ControlStyles.AllPaintingInWmPaint, true); Console.WriteLine("can enable ime:" + this.CanEnableIme); this.ImeMode = ImeMode.On; lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; renderHandler.GetScreenPoint += renderHandler_GetScreenPoint; renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.OnPaint += renderHandler_OnPaint; //renderHandler.OnPopupShow += renderHandler_OnPopupShow; //renderHandler.OnPopupSize += renderHandler_OnPopupSize; //renderHandler.OnScrollOffsetChanged += renderHandler_OnScrollOffsetChanged; //renderHandler.StartDragging += renderHandler_StartDragging; //renderHandler.UpdateDragCursor += renderHandler_UpdateDragCursor; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; keyboardHandler = new CfxKeyboardHandler(); keyboardHandler.OnPreKeyEvent += KeyboardHandler_OnPreKeyEvent; client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); client.GetKeyboardHandler += (sender, e) => e.SetReturnValue(keyboardHandler); var settings = new CfxBrowserSettings(); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(this.Parent.Handle); //windowInfo.SetAsWindowless(this.Parent.Handle); // Create handle now for InvokeRequired to work properly // CreateHandle(); if (string.IsNullOrEmpty(initialUrl)) { initialUrl = "about:version"; } CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, settings, null); }
public BrowserControl(Control parent) { _mono = Type.GetType("Mono.Runtime") != null; this.Parent = parent; SetStyle(ControlStyles.AllPaintingInWmPaint, true); Console.WriteLine("can enable ime:" + this.CanEnableIme); this.ImeMode = ImeMode.On; lifeSpanHandler = new CfxLifeSpanHandler(); lifeSpanHandler.OnAfterCreated += lifeSpanHandler_OnAfterCreated; renderHandler = new CfxRenderHandler(); renderHandler.GetRootScreenRect += renderHandler_GetRootScreenRect; renderHandler.GetScreenInfo += renderHandler_GetScreenInfo; renderHandler.GetScreenPoint += renderHandler_GetScreenPoint; renderHandler.GetViewRect += renderHandler_GetViewRect; renderHandler.OnCursorChange += renderHandler_OnCursorChange; renderHandler.OnPaint += renderHandler_OnPaint; //renderHandler.OnPopupShow += renderHandler_OnPopupShow; //renderHandler.OnPopupSize += renderHandler_OnPopupSize; //renderHandler.OnScrollOffsetChanged += renderHandler_OnScrollOffsetChanged; //renderHandler.StartDragging += renderHandler_StartDragging; //renderHandler.UpdateDragCursor += renderHandler_UpdateDragCursor; loadHandler = new CfxLoadHandler(); loadHandler.OnLoadError += loadHandler_OnLoadError; keyboardHandler = new CfxKeyboardHandler(); keyboardHandler.OnPreKeyEvent += KeyboardHandler_OnPreKeyEvent; client = new CfxClient(); client.GetLifeSpanHandler += (sender, e) => e.SetReturnValue(lifeSpanHandler); client.GetRenderHandler += (sender, e) => e.SetReturnValue(renderHandler); client.GetLoadHandler += (sender, e) => e.SetReturnValue(loadHandler); client.GetKeyboardHandler += (sender, e) => e.SetReturnValue(keyboardHandler); var settings = new CfxBrowserSettings(); var windowInfo = new CfxWindowInfo(); windowInfo.SetAsWindowless(this.Handle); //windowInfo.SetAsWindowless(this.Parent.Handle); // Create handle now for InvokeRequired to work properly // CreateHandle(); // CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null); //browser = CfxBrowserHost.CreateBrowserSync(windowInfo, client, "about:blank", settings, null); if (!CfxBrowserHost.CreateBrowser(windowInfo, client, "about:blank", settings, null)) { throw new ChromiumWebBrowserException("Failed to create browser instance."); } }