public Overlay(int height, int width) { browser = WebCore.CreateWebView(width, height, WebViewType.Offscreen); browser.Source = new Uri("http://www.google.com"); //surface = browser.Surface; }
//static void Main(string[] args) //{ //} public static void Main(String[] args) { Console.WriteLine("Started...."); WebView wv = WebCore.CreateWebView(1024, 600); wv.Source = new Uri("https://accounts.google.com/"); FrameEventHandler handler = null; handler = (s, e) => { if (e.IsMainFrame) { // we have finished loading main page, // let's unhook ourselves wv.LoadingFrameComplete -= handler; LoginAndTakeScreenShot(wv); } }; wv.LoadingFrameComplete += handler; WebCore.Run(); }
public WebView CreateWebView(int width, int height) { WebView webView = WebCore.CreateWebView(width, height); webViews.Add(webView); return(webView); }
private async void Button_Click(object sender, RoutedEventArgs e) { //var myimg = ByteToImage(await DownloadImageFromWebsiteAsync("https://sun9-63.userapi.com/c5231/u64641839/a_b11f50a2.jpg?ava=1")); //if (myimg != null) //{ // img.Source = myimg; //} //button.IsEnabled = false; //webView = WebCore.CreateWebView(1920, 1080); //webView.Source = new Uri("http://www.google.com"); //webView.LoadingFrameComplete += WebView_LoadingFrameComplete; ////webView.LoadingFrameComplete += (s, e) => ////{ ////}; //WebCore.Run(); //webView.Dispose(); //button.IsEnabled = true; Task t = new Task(() => { WebCore.Initialize(new WebConfig(), true); webView = WebCore.CreateWebView(1920, 1080, WebViewType.Window); webView.LoadingFrameComplete += WebView_LoadingFrameComplete; webView.Source = new Uri("https://my.mail.ru/mail/summer.68/video/_myvideo/37.html"); WebCore.Run(); }); t.Start(); }
private Task <SynchronizationContext> InitTask(string ipath) { TaskCompletionSource <SynchronizationContext> tcs = new TaskCompletionSource <SynchronizationContext>(); TaskCompletionSource <object> complete = new TaskCompletionSource <object>(); Task.Factory.StartNew(() => { WebCore.Initialize(new WebConfig()); WebSession session = WebCore.CreateWebSession(WebPreferences.Default); _EndTask = complete.Task; _Father._WebView = WebCore.CreateWebView(500, 500); ipath = ipath ?? "javascript\\index.html"; _Father._WebView.Source = new Uri(string.Format("{0}\\{1}", Assembly.GetExecutingAssembly().GetPath(), ipath)); WebCore.Started += (o, e) => { tcs.SetResult(SynchronizationContext.Current); }; while (_Father._WebView.IsLoading) { WebCore.Run(); } complete.SetResult(null); } ); return(tcs.Task); }
private void WebCoreInit() { int attemptCount = 0; int maxAttempts = 10; while (!WebCore.IsRunning && attemptCount < maxAttempts) { WebCoreConfig wcConfig = new WebCoreConfig() { SaveCacheAndCookies = true }; if (attemptCount > 0) { wcConfig.UserDataPath = "CSIDL_APPDATA/Awesomium/Default" + customCacheStr + attemptCount; } WebCore.Initialize(wcConfig); try { WebView wv = WebCore.CreateWebView(1, 1); wv.Close(); } catch (Exception e) { Debug.LogError("Caught webcore init exception, trying new path for cache..."); attemptCount++; } } error = attemptCount >= maxAttempts; }
public Test_ConvertToJSO() { _WebView = WebCore.CreateWebView(500, 500, WebViewType.Offscreen); _IJSOBuilder = new LocalBuilder(_WebView); _ICSharpMapper = Substitute.For <IJSCBridgeCache>(); _ICSharpMapper.GetCached(Arg.Any <object>()).Returns((IJSCSGlue)null); _ConverTOJSO = new CSharpToJavascriptMapper(_IJSOBuilder, _ICSharpMapper); _Test = new Test { S1 = "string", I1 = 25 }; _Tests = new List <Test>(); _Tests.Add(new Test() { S1 = "string1", I1 = 1 }); _Tests.Add(new Test() { S1 = "string2", I1 = 2 }); _Test2 = new Test2() { T1 = _Test, T2 = _Test }; _Tests_NG = new ArrayList(); _Tests_NG.Add(_Tests[0]); _Tests_NG.Add(_Tests[0]); }
public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent) : base(core) { webCore = core.GetService <IUIManagerService>().GetWebCore(); this.menuType = menuType; this.width = width; this.height = height; this.flags = flags; this.isTransparent = transparent; isLoading = false; pageLoaded = false; webTextureID = TextureFactory.CreateTexture(width, height, isTransparent); hudPosX = 0; hudPosY = 0; hud = new TVScreen2DImmediate(); Keyboard = core.GetService <IKeyboardService>(); Mouse = core.GetService <IMouseService>(); JoyStick = core.GetService <IJoyStickService>(); Gamepad = core.GetService <IGamepadsService>(); CanculateHudPosition(flags); View = webCore.CreateWebView(width, height, isTransparent, true); View.OnFinishLoading += OnFinishLoading; View.OnCallback += OnCallback; View.Focus(); buttonClickSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3")); buttonFocusSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3")); Core.GetService <ISoundManagerService>().SetVolume(buttonClickSound, 0.5f); Core.GetService <ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f); }
string GetPageFromAwesomium(string url) { var html = string.Empty; var finishedLoading = false; using (var webView = WebCore.CreateWebView(1920, 10800)) { webView.Source = new Uri(url); webView.LoadingFrameComplete += (s, e) => { if (!e.IsMainFrame) { return; } finishedLoading = true; html = webView.HTML; }; while (!finishedLoading) { // Thread.Sleep(20); Thread.Sleep(100); WebCore.Update(); } WebCore.Shutdown(); } return(html); }
/// <summary> /// Инициализируем Awesomium /// </summary> private void initAwesomium() { //Инициализируем параметры запуска ядра авесомиума WebCore.Initialize(new WebConfig() { LogLevel = LogLevel.None, UserAgent = compileUA() }); //Создаём сессию ss = WebCore.CreateWebSession(new WebPreferences { // ProxyConfig = "https://lv-134-87-2.fri-gate.biz:443", WebSecurity = true, LoadImagesAutomatically = false, RemoteFonts = false, JavascriptApplicationInfo = false }); //Инициализируем браузер, для работы с сайтом. wv = WebCore.CreateWebView( 1680, 1050, ss, WebViewType.Offscreen); }
public void InitializeWebCore() { if (IsWebCoreInitialized) { throw new InvalidOperationException("Cannot initialize WebBrowserPool more than once."); } _webViews = new Stack <WebView>(); Console.WriteLine("-- Initializing WebBrowserPool thread: " + Thread.CurrentThread.ManagedThreadId + " : " + Thread.CurrentThread.Name); Console.WriteLine("-- Initializing WebBrowserPool At " + DateTime.Now); dispatcher = Dispatcher.CurrentDispatcher; //Init Awesomium Webview correctly. //Note: Do we need special settings for WebCoreConfig? //var webCoreConfig = new WebCoreConfig(); WebCoreConfig config = new WebCoreConfig { // !THERE CAN ONLY BE A SINGLE WebCore RUNNING PER PROCESS! // We have ensured that our application is single instance, // with the use of the WPFSingleInstance utility. // We can now safely enable cache and cookies. SaveCacheAndCookies = true, // In case our application is installed in ProgramFiles, // we wouldn't want the WebCore to attempt to create folders // and files in there. We do not have the required privileges. // Furthermore, it is important to allow each user account // have its own cache and cookies. So, there's no better place // than the Application User Data Path. EnablePlugins = true, EnableVisualStyles = false, // ...See comments for UserDataPath. // Let's gather some extra info for this sample. LogLevel = LogLevel.Verbose }; WebCore.Initialize(config); for (int i = NUM_WEB_VIEWS - 1; i >= 0; i--) { WebView view = WebCore.CreateWebView(1024, 768); _webViews.Push(view); } Console.WriteLine("-- Done -- Initializing the WebBrowserPool At " + DateTime.Now); Console.WriteLine("Entering Update Loop"); DispatcherTimer updateTimer = new DispatcherTimer(DispatcherPriority.Send, Dispatcher.CurrentDispatcher) { Interval = TimeSpan.FromMilliseconds(20) }; updateTimer.Tick += (sender, args) => WebCore.Update(); updateTimer.Start(); IsWebCoreInitialized = true; Dispatcher.Run(); }
public WebWindow(int width, int height, string url) { this.width = width; this.height = height; views.Add(this); webView = WebCore.CreateWebView(width, height, session); webView.Source = new Uri("file:///" + System.IO.Directory.GetCurrentDirectory() + "/" + Resources.FindFile(url)); //webView.Source = new Uri("http://www.google.com"); //webView.Source = new Uri("http://www.chiptune.com/starfield/starfield.html"); webView.IsTransparent = true; webView.PropertyChanged += webView_PropertyChanged; webView.Crashed += webView_Crashed; webView.DocumentReady += webView_DocumentReady; descHM = new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.None, CpuAccessFlags = CpuAccessFlags.Write, Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm, Width = width, Height = height, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Staging, }; mappableTexture = new Texture2D(Display.device, descHM); mappableSurface = mappableTexture.QueryInterface <SharpDX.DXGI.Surface>(); descHM.Usage = ResourceUsage.Default; descHM.CpuAccessFlags = CpuAccessFlags.None; descHM.BindFlags = BindFlags.ShaderResource; InputManager.MouseDown += _onMouseDown; InputManager.MouseUp += _onMouseUp; InputManager.MouseMove += _onMouseMove; InputManager.Wheel += _onMouseWheel; Texture2D webTexture = new Texture2D(Display.device, descHM); webTex = new Texture(webTexture); position = new Vector2(0, 0); binds = new Stack <Tuple <string, JavascriptMethodEventHandler> >(); invokes = new Stack <Tuple <string, JSValue[]> >(); }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (webView == null) { webView = WebCore.CreateWebView(ClientSize.Width, ClientSize.Height, WebViewType.Window); } InitializeView(); }
public Program() { wv = WebCore.CreateWebView(1024, 600); wv.Source = new Uri("http://somecompany.app.com/ematrix/emxLogin.jsp"); login = "******"; passw = "aPassword"; wv.LoadingFrameComplete += MainPageLoadingFrameComplete; wv.DocumentReady += OnDocumentReadyHandler; WebCore.Run(); }
public void PrintHtml() { WebView view = WebCore.CreateWebView(1024, 768); string html = this.HtmlTemplate.GenerateHtmlTemplate(false); view.LoadHTML(html); view.LoadCompleted += delegate(object param0, System.EventArgs param1) { view.Print(); }; }
public override void Create(string streamerUri, string id) { _dispatcher.Invoke(() => { _browser = WebCore.CreateWebView(256, 256, WebViewType.Offscreen); _browser.DocumentReady += browser_DocumentReady; _browser.Source = new Uri("https://www.youtube.com/live_chat?is_popout=1&v=EeEbPh6zpHc"); }); // _timer.Start(); }
private void CreateBrowser() { _browser = null; _context.Post(state => { _browser = WebCore.CreateWebView(1100, 600); }, null); while (_browser == null) { Thread.Sleep(100); } }
public void Initialize(GraphicsDevice device, int renderTargetWidth, int renderTargetHeight, string basePath, string customCss = "") { mBasePath = basePath; //OnLoadCompleted = new OnLoadCompletedDelegate(); //WebCore.Initialize(new WebCoreConfig() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }); //WebCore.Initialize(new WebConfig() { CustomCSS = customCSS, SaveCacheAndCookies = true }); //1.7 //WebCore.Initialize(new WebCoreConfig() { CustomCSS = customCSS, SaveCacheAndCookies = true }); var webConfig = new WebConfig { LogPath = Environment.CurrentDirectory, LogLevel = LogLevel.Verbose }; WebCore.Initialize(webConfig); var webPreferences = new WebPreferences { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }; WebSession = WebCore.CreateWebSession(webPreferences); if (mLogger != null) { mLogger.Info("WEBCORE initialized."); } WebTexture = new Texture2D(device, renderTargetWidth, renderTargetHeight); if (mLogger != null) { mLogger.Info("Rendertarget created."); } WebView = WebCore.CreateWebView(renderTargetWidth, renderTargetHeight, WebSession); //LoadingFrameComplete still seems to take an //inordinate amout of time with local files... //SOMETIMES. //As long as you haven't navigated to an online //page and back it is instant. Odd. WebView.DocumentReady += OnDocumentReadyInternal; WebView.LoadingFrameComplete += OnLoadingFrameCompleteInternal; if (mLogger != null) { mLogger.Info("WebView created."); } WebView.IsTransparent = true; }
////////////////////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR & DESTRUCTOR /// <summary> /// Main constructor. /// </summary> /// <param name="device">The d3d11 device on which to connect the texture.</param> /// <param name="context">The context to be used for this webtexture.</param> /// <param name="url">The url to use.</param> /// /// <param name="updateIfSurfaceIsNotDirty">Look at member!</param> /// <param name="width">The webview's width.</param> /// <param name="height">The webview's height.</param> /// <param name="isTransparent">Defines, whether the background of the site shall be transparent or not.</param> public WebTexture( Device device, DeviceContext context, Uri url, bool updateIfSurfaceIsNotDirty = true, int width = 1920, int height = 1080, bool isTransparent = true) : base(device) { UpdateIfSurfaceIsNotDirty = updateIfSurfaceIsNotDirty; // setup awesomium view WebSession webSession = WebCore.CreateWebSession(new WebPreferences { CustomCSS = "::-webkit-scrollbar { width: 0px; height: 0px; } ", }); _view = WebCore.CreateWebView(width, height, webSession); _view.Source = url; _view.IsTransparent = isTransparent; while (_view.IsLoading) { WebCore.Update(); } // init texture Context = context; Texture2DDescription description = new Texture2DDescription { ArraySize = 1, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.Write, Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm, Height = _view.Height, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Dynamic, Width = _view.Width }; _texture = new Texture2D(Device, description); _surface = _view.Surface as BitmapSurface; }
public WebForm(Uri targetURL) { // Initialize the core and get a WebSession. WebSession session = InitializeCoreAndSession(); // Notice that 'Control.DoubleBuffered' has been set to true // in the designer, to prevent flickering. InitializeComponent(); // Initialize a new view. InitializeView(WebCore.CreateWebView(this.ClientSize.Width, this.ClientSize.Height, session), false, targetURL); }
public WebView Acquire() { lock (_poolLock) { if (_webViews.Count == 0) { Console.WriteLine("New Webview being created"); return(WebCore.CreateWebView(1024, 768)); } return(_webViews.Pop()); } }
static void Main(string[] args) { // Some informative message. Console.WriteLine("Getting a 800x600 snapshot of http://www.google.com ..."); // We demonstrate an easy way to hide the scrollbars by providing // custom CSS. Read more about how to style the scrollbars here: // http://www.webkit.org/blog/363/styling-scrollbars/. // Just consider that this setting is global. If you want to apply // a similar effect for single pages, you can use ExecuteJavascript // and pass: document.documentElement.style.overflow = 'hidden'; // (Unfortunately WebKit's scrollbar does not have a DOM equivalent yet) WebCore.Initialize(new WebCoreConfig() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }); // WebView implements IDisposable. You can dispose and destroy // the view by calling WebView.Close(). Here we demonstrate // wrapping it in a using statement. using (WebView webView = WebCore.CreateWebView(800, 600)) { webView.LoadURL("http://www.google.com"); webView.LoadCompleted += OnFinishLoading; while (!finishedLoading) { Thread.Sleep(100); // A Console application does not have a synchronization // context, thus auto-update won't be enabled on WebCore. // We need to manually call Update here. WebCore.Update(); } // Render to a pixel buffer and save the buffer // to a .png image. webView.Render().SaveToPNG("result.png", true); } // Announce. Console.Write("Hit any key to see the result..."); Console.ReadKey(true); // Start the application associated with .png files // and display the file. Process.Start("result.png"); // Shut down Awesomium before exiting. WebCore.Shutdown(); }
public Browser(Guid id, string url, int width, int height) { Id = id; _width = width; _height = height; webView = WebCore.CreateWebView(width, height); webView.ResizeComplete += webView_ResizeComplete; webView.IsDirtyChanged += webView_IsDirtyChanged; //webView.SelectLocalFiles += webView_SelectLocalFiles; webView.CursorChanged += webView_CursorChanged; webView.LoadCompleted += new EventHandler(webView_LoadCompleted); webView.LoadURL(url); webView.Focus(); }
private async void btnCheckIpAddress_Click(object sender, RoutedEventArgs e) { // browser = new Awesomium.Windows.Controls.WebControl(); btnCheckIpAddress.IsEnabled = false; using (Awesomium.Core.IWebView tempView = WebCore.CreateWebView(0, 0)) { await tempView.WaitPageLoadComplete(() => { tempView.Source = "api.ipify.org".ToUri(); }); string ipAddress = tempView.ExecuteJavascriptWithResult("document.body.textContent"); MessageBox.Show(string.Format("Reported IP Address [ipify.org]: {0}", ipAddress)); } btnCheckIpAddress.IsEnabled = true; }
/* private void MenuOpenFolder_OnClick(object sender, RoutedEventArgs e) * { * var fb = new FolderBrowserDialog {ShowNewFolderButton = false}; * var result = fb.ShowDialog(); * if (result != System.Windows.Forms.DialogResult.OK) return; * var files = Directory.GetFiles(fb.SelectedPath, "*.htm*"); * if (files.Length <= 0) return; * foreach (var file in files.Where(file => FileNames.IndexOf(file) ==-1)) * { * FileNames.Add(file); * } * Settings.CanScreenShot = true; * } */ private void ScreenShotButton_Click(object sender, System.Windows.RoutedEventArgs e) { var a = new FolderBrowserDialog(); var result = a.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return; } Settings.CanScreenShot = false; SavePath = a.SelectedPath; _browser = WebCore.CreateWebView(Settings.BrowserHeight, Settings.BrowserWidth); ScreenShot(); }
public WebForm() { WebCore.Initialize(WebConfig.Default); session = WebCore.CreateWebSession(WebPreferences.Default); Debug.Print(WebCore.Version.ToString()); // Notice that 'Control.DoubleBuffered' has been set to true // in the designer, to prevent flickering. InitializeComponent(); // Initialize the view. InitializeView(WebCore.CreateWebView(this.ClientSize.Width, this.ClientSize.Height, session)); }
public void PushScreen(string screenName) { // Create our screen. var screen = WebCore.CreateWebView(Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height, _session); // Force screen to be transparent and register callbacks. screen.DocumentReady += HandleWebViewDocumentReady; // Load the HTML for that screen and focus it. screen.LoadHTML(Game.Content.Load <string>("Screens/" + screenName)); screen.FocusView(); _screens.Push(screen); }
public WebForm() { // Initialize the core and get a WebSession. WebSession session = InitializeCoreAndSession(); // Notice that 'Control.DoubleBuffered' has been set to true // in the designer, to prevent flickering. InitializeComponent(); // Initialize a new view. InitializeView(WebCore.CreateWebView(this.ClientSize.Width, this.ClientSize.Height, session)); skinEngine1.SkinStream = new MemoryStream(Resources.DeepCyan); jsHandler = new MainFormJsHandler(webView); }
public FormApp(int userId, string url) { // Initialize the core and get a WebSession. session = InitializeCoreAndSession(); // Notice that 'Control.DoubleBuffered' has been set to true // in the designer, to prevent flickering. this.userId = userId; this.url = url; InitializeComponent(); // Initialize a new view. InitializeView(WebCore.CreateWebView(this.ClientSize.Width, this.ClientSize.Height)); }
private int browserheight; // Height of browser. /// <summary> /// Instantiates a new tab. /// </summary> /// <param name="id"></param> /// <param name="URL"></param> /// <param name="w"></param> /// <param name="h"></param> /// <param name="x"></param> /// <param name="y"></param> public BrowserTab(int id, string URL, int w, int h, int x, int y) { ID = id; url = URL; browserwidth = w; browserheight = h; s = new BitmapSurface(w, h); webBytes = new byte[w * h * 4]; BrowserTex = new Texture((uint)browserwidth, (uint)browserheight); View = new Sprite(BrowserTex); View.Position = new Vector2f((uint)x, (uint)y); WebSession session = WebCore.CreateWebSession(new WebPreferences() { WebSecurity = false, FileAccessFromFileURL = true, UniversalAccessFromFileURL = true, LocalStorage = true, }); MyTab = WebCore.CreateWebView(browserwidth, browserheight, session, WebViewType.Offscreen); MyTab.IsTransparent = true; MyTab.Source = new Uri(URL); MyTab.Surface = s; MyTab.ShowJavascriptDialog += (sender, e) => { Console.WriteLine("JS: " + e.Message + " : " + id + " " + this.GetType().ToString()); Callback(e.Message); }; s.Updated += (sender, e) => { if (!Active) { return; } for (int i = 0; i < GlobalData.UISmooth; i++) { UpdateTexture(); } }; }
public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent) : base(core) { webCore = core.GetService<IUIManagerService>().GetWebCore(); this.menuType = menuType; this.width = width; this.height = height; this.flags = flags; this.isTransparent = transparent; isLoading = false; pageLoaded = false; webTextureID = TextureFactory.CreateTexture(width, height, isTransparent); hudPosX = 0; hudPosY = 0; hud = new TVScreen2DImmediate(); Keyboard = core.GetService<IKeyboardService>(); Mouse = core.GetService<IMouseService>(); JoyStick = core.GetService<IJoyStickService>(); Gamepad = core.GetService<IGamepadsService>(); CanculateHudPosition(flags); View = webCore.CreateWebView(width, height, isTransparent, true); View.OnFinishLoading += OnFinishLoading; View.OnCallback += OnCallback; View.Focus(); buttonClickSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3")); buttonFocusSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3")); Core.GetService<ISoundManagerService>().SetVolume(buttonClickSound, 0.5f); Core.GetService<ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f); }