void ControlLoaded(object sender, RoutedEventArgs e) { control.Loaded -= ControlLoaded; var session = WebCore.CreateWebSession(baseDirectory, new WebPreferences(true) { WebGL = true, EnableGPUAcceleration = true, SmoothScrolling = true, CustomCSS = @"body { font-family: Segoe UI, sans-serif; font-size:0.8em;} ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background-color: white; } ::-webkit-scrollbar-thumb { background-color: #B9B9B9; } ::-webkit-scrollbar-thumb:hover { background-color: #000000; }" }); markpadDataSource = new MarkpadDataSource(); session.AddDataSource("markpad", markpadDataSource); wb = new WebControl { WebSession = session, UseLayoutRounding = true, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Source = new Uri("asset://markpad/MarkpadPreviewRender.html"), }; wb.Loaded += WbLoaded; AwesomiumResourceHandler.Host = this; WebCore.ResourceInterceptor = AwesomiumResourceHandler.ResourceInterceptor; wb.ShowCreatedWebView += AwesomiumResourceHandler.ShowCreatedWebView; LoadHtml(Html); control.Content = wb; }
void ControlLoaded(object sender, RoutedEventArgs e) { control.Loaded -= ControlLoaded; var session = WebCore.CreateWebSession(baseDirectory, new WebPreferences(true) { CustomCSS = @"body { font-family: Segoe UI, sans-serif; font-size:0.8em;} ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background-color: white; } ::-webkit-scrollbar-thumb { background-color: #B9B9B9; } ::-webkit-scrollbar-thumb:hover { background-color: #000000; }" }); wb = new WebControl { WebSession = session, UseLayoutRounding = true, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; wb.Loaded += WbLoaded; AwesomiumResourceHandler.Host = this; WebCore.ResourceInterceptor = AwesomiumResourceHandler.ResourceInterceptor; wb.ShowCreatedWebView += AwesomiumResourceHandler.ShowCreatedWebView; wb.LoadHTML(Html); control.Content = wb; }
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); }
IWebView IWebViewLifeCycleManager.Create() { if (_Session == null) { _Session = (_WebSessionPath != null) ? WebCore.CreateWebSession(_WebSessionPath, new WebPreferences()) : WebCore.CreateWebSession(new WebPreferences()); WebCore.ShuttingDown += WebCore_ShuttingDown; } WebControl nw = new WebControl() { WebSession = _Session, 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); }
private WebSession InitializeCoreAndSession() { if (!WebCore.IsInitialized) { WebCore.Initialize(new WebConfig() { AssetProtocol = "https", LogLevel = LogLevel.Normal }); } // Build a data path string. In this case, a Cache folder under our executing directory. // - If the folder does not exist, it will be created. // - The path should always point to a writeable location. string dataPath = String.Format("{0}{1}Cache", Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar); // Check if a session synchronizing to this data path, is already created; // if not, create a new one. session = WebCore.Sessions[dataPath] ?? WebCore.CreateWebSession(dataPath, new WebPreferences() { }); session.AddDataSource(DataSource.CATCH_ALL, new MyDataSource()); // The core must be initialized by now. Print the core version. Debug.Print(WebCore.Version.ToString()); // Return the session. return(session); }
public static void AwesomiumThread() { // Initialize the WebCore with some configuration settings. WebCore.Initialize(new WebConfig() { //UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.76 Safari/537.36", //LogPath = Environment.CurrentDirectory + "/awesomium.log", //LogLevel = LogLevel.Verbose, }); WebCore.CreateWebSession(new WebPreferences() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }); // Check if the WebCore is already automatically updating. // A background thread has no message loop and synchronization context. if (WebCore.UpdateState != WebCoreUpdateState.NotUpdating) { return; } // Tell the WebCore to create an Awesomium-specific // synchronization context and start an update loop. // The current thread will be blocked until WebCore.Shutdown // is called. For details about the new auto-updating and // synchronization model of Awesomium.NET, read the documentation // of WebCore.Run. WebCore.Run((s, e) => webCoreStarted = true); }
private Task RawInit() { var running = new TaskCompletionSource <object>(); WebCore.Initialize(new WebConfig()); WebCore.ShuttingDown += (o, e) => { if (e.Exception != null) { Console.WriteLine($"Exception on main thread {e.Exception}"); e.Cancel = true; } _EndTaskCompletionSource.TrySetResult(null); }; WebCore.Started += (o, e) => { AwesomiumWPFWebWindowFactory.WebCoreThread = Thread.CurrentThread; running.TrySetResult(null); }; WebCore.CreateWebSession(WebPreferences.Default); _Runing = true; return(running.Task); }
/// <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 MainWindow() { if (!WebCore.IsInitialized) { WebCore.Initialize(new WebConfig() { HomeURL = new Uri("http://localhost"), RemoteDebuggingPort = 8001, }); } // Create a WebSession. WebSession session = WebCore.CreateWebSession(new WebPreferences() { SmoothScrolling = true }); session.AddDataSource("core", new ResourceDataSource(ResourceType.Embedded, Assembly.GetExecutingAssembly())); InitializeComponent(); webControl.DocumentReady += onDocumentReady; webControl.ConsoleMessage += onConsoleMessage; webControl.LoadingFrameComplete += onLoadingFrameComplete; webControl.WebSession = session; }
public static void Initialize() { views = new List <WebWindow>(); WebConfig config = new WebConfig() { AutoUpdatePeriod = 30, #if DEBUG LogLevel = LogLevel.Normal #endif }; WebCore.Initialize(config, true); //WebCore.PackagePath = System.IO.Directory.GetCurrentDirectory(); session = WebCore.CreateWebSession( new WebPreferences() { CustomCSS = "textarea, input { outline: none; }", CanScriptsCloseWindows = false, CanScriptsOpenWindows = false, Plugins = false, WebGL = false, WebAudio = false, SmoothScrolling = true, FileAccessFromFileURL = false, UniversalAccessFromFileURL = false, AppCache = false, Databases = false, CanScriptsAccessClipboard = true, } ); }
public void InitilaizeSession(string contentsPath) { var prefs = new WebPreferences(); var session = WebCore.CreateWebSession(prefs); session.AddDataSource("content", new Awesomium.Core.Data.DirectoryDataSource(contentsPath)); htmlRenderer.WebSession = session; }
public MainWindow() { var session = WebCore.CreateWebSession(@"SessionDataPath", WebPreferences.Default); InitializeComponent(); webControl.WebSession = session; GetTreeview(); }
public AwesomiumWPFWebWindowFactory(string iWebSessionPath = null) { if (_Session == null) { _Session = (iWebSessionPath != null) ? WebCore.CreateWebSession(iWebSessionPath, new WebPreferences()) : WebCore.CreateWebSession(new WebPreferences()); } }
public MainWindow() { InitializeComponent(); // Persist web local storage var webSession = WebCore.CreateWebSession(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), Awesomium.Core.WebPreferences.Default); PART_WebView.WebSession = webSession; PART_WebView.Source = new Uri(ServiceUrl); }
////////////////////////////////////////////////////////////////////////////////////////// // 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 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; }
public AwesomiumWPFWebWindowFactory(string webSessionPath = null) { if (_Session != null) { return; } _Session = (webSessionPath != null) ? WebCore.CreateWebSession(webSessionPath, new WebPreferences()) : WebCore.CreateWebSession(new WebPreferences()); WebCore.ShuttingDown += WebCore_ShuttingDown; }
public AuthorizeWindow(int appId) { InitializeComponent(); webBrowser.WebSession = WebCore.CreateWebSession(AppPaths.WebSessionPath, new WebPreferences { AcceptLanguage = "ru-ru,ru" }); webBrowser.Source = new Uri(CreateAuthorizeUrlFor(appId)); webBrowser.AddressChanged += webBrowser_AddressChanged; }
public FormMain() { InitializeComponent(); string sessionFolder = Path.Combine(_appData, "TweetDeckSA"); Width = PrefWidth; Height = PrefHeight; Debug.Print(sessionFolder); WebSession session = WebCore.CreateWebSession(@sessionFolder, WebPreferences.Default); webControl.ShowCreatedWebView += (sender, args) => Process.Start(args.TargetURL.ToString()); }
public MainWindow() { var webSession = WebCore.CreateWebSession(SessionPath, new WebPreferences() { Javascript = true, AllowInsecureContent = true, WebAudio = true, Plugins = true }); InitializeComponent(); Browser.WebSession = webSession; hotKey = new GlobalHotKey(this); }
private void CreateSession() { _session = WebCore.CreateWebSession( _cacheDir, new WebPreferences { SmoothScrolling = true, WebGL = true, EnableGPUAcceleration = true, }); _session.AddDataSource("demo", new DirectoryDataSource( Path.GetDirectoryName(@"html\greeter.html"))); }
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)); }
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(); } }; }
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.ShowJavascriptDialog += (sender, e) => //{ // Console.WriteLine(e.Message); // BrowserManager.DestroyTab(ID); // BrowserManager.NewTab(ID, url, w, h, x, y); //}; MyTab.Source = new Uri(URL); MyTab.Surface = s; s.Updated += (sender, e) => { unsafe { fixed(Byte *byteptr = webBytes) { s.CopyTo((IntPtr)byteptr, s.RowSpan, 4, true, false); BrowserTex.Update(webBytes); } } }; }
public FrameworkElement Initialize() { if (_session == null) { if (!WebCore.IsInitialized) { WebCore.Initialize(new WebConfig { UserAgent = DefaultUserAgent, ReduceMemoryUsageOnNavigation = true, LogLevel = LogLevel.None, #if DEBUG RemoteDebuggingHost = @"127.0.0.1", RemoteDebuggingPort = 45451, #endif AdditionalOptions = new[] { @"disable-desktop-notifications" }, CustomCSS = @" ::-webkit-scrollbar { width: 8px!important; height: 8px!important; } ::-webkit-scrollbar-track { box-shadow: none!important; border-radius: 0!important; background: #000!important; } ::-webkit-scrollbar-corner { background: #000 !important; } ::-webkit-scrollbar-thumb { border: none !important; box-shadow: none !important; border-radius: 0 !important; background: #333 !important; } ::-webkit-scrollbar-thumb:hover { background: #444 !important; } ::-webkit-scrollbar-thumb:active { background: #666 !important; }" }); } _session = WebCore.CreateWebSession(FilesStorage.Instance.GetTemporaryFilename(@"Awesomium"), new WebPreferences { EnableGPUAcceleration = true, WebGL = true, SmoothScrolling = false, FileAccessFromFileURL = true, UniversalAccessFromFileURL = true }); } _inner = new BetterWebControl { WebSession = _session, UserAgent = DefaultUserAgent }; _inner.LoadingFrame += OnLoadingFrame; _inner.LoadingFrameComplete += OnLoadingFrameComplete; _inner.LoadingFrameFailed += OnLoadingFrameComplete; _inner.DocumentReady += OnDocumentReady; return(_inner); }
private WebSession CreateBattlelogWebSession() { Utilities.Log("BattlelogiumMain.CreateBattlelogWebSession() Called"); WebSession session = WebCore.CreateWebSession( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Battlelogium", "WebSession"), new WebPreferences { CustomCSS = config.CSS, EnableGPUAcceleration = true, }); session.AddDataSource("local", new ResourceDataSource(ResourceType.Packed)); WebCore.HomeURL = new Uri("http://battlelog.battlefield.com/bf3"); WebCore.Download += new DownloadEventHandler(WebCore_Download); return(session); }
static void Main(string[] args) { WebCore.Initialize(WebConfig.Default); Uri url = new Uri("http://www.google.com"); using (WebSession session = WebCore.CreateWebSession(WebPreferences.Default)) { // WebView implements IDisposable. Here we demonstrate // wrapping it in a using statement. using (WebView view = WebCore.CreateWebView(1100, 600, session)) { bool finishedLoading = false; bool finishedResizing = false; Console.WriteLine(String.Format("Loading: {0} ...", url)); // Load a URL. view.Source = url; // This event is fired when a frame in the // page finished loading. view.LoadingFrameComplete += (s, e) => { Console.WriteLine(String.Format("Frame Loaded: {0}", e.FrameId)); // The main frame usually finishes loading last for a given page load. if (e.IsMainFrame) { finishedLoading = true; } }; 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(); } // Print some more information. Console.WriteLine(String.Format("Page Title: {0}", view.Title)); Console.WriteLine(String.Format("Loaded URL: {0}", view.Source)); } // Destroy and dispose the view. } // Release and dispose the session. // Shut down Awesomium before exiting. WebCore.Shutdown(); Console.WriteLine("Press any key to exit..."); Console.Read(); }
public Form1() { WebCore.Initialize(new WebConfig()); WebPreferences wp = new WebPreferences(); wp.AcceptLanguage = "ru-ru"; wp.ProxyConfig = "5.1.50.138:8080"; WebSession ws = WebCore.CreateWebSession(wp); InitializeComponent(); webControl1.WebSession = ws; /* * var ws = WebCore.CreateWebSession(new WebPreferences() { ProxyConfig = "255.255.255:8080" }); * webControl1 = new Awesomium.Windows.Forms.WebControl() { WebSession = ws }; * this.Controls.Add(webControl1);*/ }
public override string Fetch(Uri uri) { WebCore.Initialize(new WebConfig() { LogPath = Environment.CurrentDirectory, LogLevel = LogLevel.Verbose, ManagedConsole = true }); FinishedLoading = false; FinishedNavigating = false; var loadCount = 0; var navigateCount = 0; using (var session = WebCore.CreateWebSession(new WebPreferences() { })) { using (var view = WebCore.CreateWebView(1024, 768, session)) { PerformLoading(uri, view); while (!FinishedLoading) { Thread.Sleep(100); WebCore.Update(); ++loadCount; } PerformNavigation(view); while (!FinishedNavigating) { Thread.Sleep(100); WebCore.Update(); ++navigateCount; } var surface = (BitmapSurface)view.Surface; surface.SaveToPNG("result.png", true); } } Console.WriteLine("Loaded for " + loadCount * 100 + " ms and navigated for " + navigateCount * 100 + " ms."); WebCore.Shutdown(); return(null); }
public Form1() { if (!WebCore.IsInitialized) { WebCore.Initialize(new WebConfig(), true); } InitializeComponent(); this.webControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.webControl1.Location = new System.Drawing.Point(0, 0); this.webControl1.Size = new System.Drawing.Size(1134, 681); this.webControl1.TabIndex = 0; this.webControl1.WebSession = WebCore.CreateWebSession("%APPDATA%\\Test", new WebPreferences { CustomCSS = "body { overflow:hidden; }", WebSecurity = false, DefaultEncoding = "UTF-8", }); this.webControl1.Source = new Uri("http://localhost:8080/Test/test.html"); }