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); }
private void Window_Closing(object sender, CancelEventArgs e) { Utilities.Log("this.Window_Closing() called"); if (GetBattlefield3Process() != null) { Utilities.Log("GetBattlefield3Process() != null"); this.Battlelog.ExecuteJavascript(JSDialog.ShowJavascriptDialog(new OKDialog("Battlefield 3 is still running", "Quit Battlefield 3 before closing Battlelogium"))); e.Cancel = true; return; } // Shutdown WebCore try { Utilities.Log("WebCore.Shutdown()"); WebCore.Shutdown(); } catch (Exception ex) { Utilities.Log("Exception occured when WebCore shutdown"); Utilities.Log(ex.ToString()); } Timer cleanupOriginTimer = new Timer(config.WaitTimeToKillOrigin); cleanupOriginTimer.AutoReset = false; cleanupOriginTimer.Elapsed += delegate { Dispatcher.Invoke(new Action(delegate { if (config.HandleOrigin) { Utilities.Log("managedOrigin.KillOriginProcess()"); managedOrigin.KillOriginProcess(); } Utilities.Log("Utilities.KillProcess(sonarhost)"); Utilities.KillProcess("sonarhost", false, false); if (this.retainOrigin) { Utilities.Log("retainOrigin = True"); //We do not want this instance of Origin to be a child process, otherwise Steam will think we're still in Battlefield 3 Utilities.Log("ManagedOrigin.CreateUnmanagedInstance"); ManagedOrigin.CreateUnmanagedInstance(); } Utilities.Log("!---End Log---!"); Utilities.Log("Press Enter to Exit. Remember to submit battlelogium.log"); Utilities.FreeConsole(); })); }; Utilities.Log("Waiting " + config.WaitTimeToKillOrigin * 1000 + " milliseconds to kill Origin"); notifyIcon.Text = "Battlelogium is waiting for Origin and ESN Sonar to close"; cleanupOriginTimer.Start(); this.Hide(); System.Threading.Thread.Sleep(config.WaitTimeToKillOrigin * 1000 + 5000); notifyIcon.Visible = false; }
void timer_Tick(object sender, EventArgs e) { WebCore.Update(); if (webView.IsDirty()) { Render(); } }
void WebForm_Resize(object sender, EventArgs e) { if (webViewBitmap.Width != 0 && webViewBitmap.Height != 0) { webView.Resize(webViewBitmap.Width, webViewBitmap.Height); WebCore.Update(); } }
private static void OnApplicationExit(object sender, EventArgs e) { // Make sure we shutdown the core last. if (WebCore.IsInitialized) { WebCore.Shutdown(); } }
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 static void DisposeAll() { for (int i = 0; i < views.Count; i++) { views[i].Dispose(); } WebCore.Shutdown(); }
protected override void OnExit(ExitEventArgs e) { // Make sure we shutdown the core last. if (WebCore.IsInitialized) WebCore.Shutdown(); base.OnExit(e); }
static WebBrowser() { DefaultStyleKeyProperty.OverrideMetadata(typeof(WebBrowser), new FrameworkPropertyMetadata(typeof(WebBrowser))); webCore = new WebCore(); CompositionTarget.Rendering += delegate { webCore.Update(); }; }
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[]> >(); }
public void Update() { if (PauseUiUpdate) { return; } WebCore.Update(); }
public void Dispose() { if (_Session != null) { _Session.Dispose(); } WebCore.Shutdown(); }
public AwesomiumWPFWebWindowFactory(string iWebSessionPath = null) { if (_Session == null) { _Session = (iWebSessionPath != null) ? WebCore.CreateWebSession(iWebSessionPath, new WebPreferences()) : WebCore.CreateWebSession(new WebPreferences()); } }
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(); }
private void update(object sender, EventArgs e) { WebCore.Update(); foreach (TabView i in tabViewList) { i.render(); } }
public MainWindow() { WebCore.Initialize(new WebConfig() { LogLevel = LogLevel.Verbose }); InitializeComponent(); }
public MainForm() { InitializeComponent(); if (!WebCore.IsInitialized) { WebCore.Initialize(WebConfig.Default, true); WebCore.ResourceInterceptor = new ResourceInterceptor(LoginHelper.GetOAToken()); } }
private static void OnApplicationExit(object sender, EventArgs e) { #if !__MonoCS__ if (WebCore.IsInitialized) { WebCore.Shutdown(); } #endif }
public MainWindow() { var session = WebCore.CreateWebSession(@"SessionDataPath", WebPreferences.Default); InitializeComponent(); webControl.WebSession = session; GetTreeview(); }
static AwesomiumWPFWebWindowFactory() { WebCore.Started += (o, e) => { WebCoreThread = Thread.CurrentThread; }; if (!WebCore.IsInitialized) { WebCore.Initialize(_WebConfig); } }
public void Dispose() { try { _Session?.Dispose(); } catch { } WebCore.Shutdown(); }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (webView == null) { webView = WebCore.CreateWebView(ClientSize.Width, ClientSize.Height, WebViewType.Window); } InitializeView(); }
// Awake is called only once during the lifetime // of the script instance and always before any Start functions // are called. This is the best place to initialize our WebCore. void Awake() { if (!WebCore.IsRunning) { WebCore.Initialize(new WebCoreConfig() { SaveCacheAndCookies = true }); } }
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(); }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); this.selfHost.Close(); // shutdown awesomium Awesomium.Dispose(); WebCore.Shutdown(); }
/// <summary> /// Initializes Awesomium. /// </summary> private void InitAwesomium() { // Initialize the WebCore with some configuration settings. WebCore.Initialize(new WebConfig { LogPath = Environment.CurrentDirectory, LogLevel = LogLevel.Verbose, RemoteDebuggingPort = 1225 }); }
private void OnApplicationQuit() { // We shutdown the WebCore only once if (WebCore.IsRunning) { Destroy(GameObject.Find("WebCoreHelperInstance")); WebCore.Shutdown(); } }
public override void Dispose() { foreach (var gm in gameMenu) { gm.Key.Dispose(); } gameMenu.Clear(); webCore.Dispose(); webCore = null; }
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(); }; }
static EngageWidget() { DefaultStyleKeyProperty.OverrideMetadata(typeof(EngageWidget), new FrameworkPropertyMetadata(typeof(EngageWidget))); #if DEBUG var config = WebCoreConfig.Default; config.LogLevel = LogLevel.Verbose; config.LogPath = Environment.CurrentDirectory; WebCore.Initialize(config, false); #endif }
private void RunOnContext(Action act) { if (Thread.CurrentThread == AwesomiumWPFWebWindowFactory.WebCoreThread) { act(); } else { WebCore.QueueWork(act); } }
public static void Initialize(WebCore.Config config) { StringHelper userDataPathStr = new StringHelper(config.userDataPath); StringHelper pluginPathStr = new StringHelper(config.pluginPath); StringHelper logPathStr = new StringHelper(config.logPath); StringHelper userAgentOverrideStr = new StringHelper(config.userAgentOverride); StringHelper proxyServerStr = new StringHelper(config.proxyServer); StringHelper proxyConfigScriptStr = new StringHelper(config.proxyConfigScript); StringHelper customCSSStr = new StringHelper(config.customCSS); awe_webcore_initialize(config.enablePlugins, config.enableJavascript, userDataPathStr.value(), pluginPathStr.value(), logPathStr.value(), config.logLevel, userAgentOverrideStr.value(), proxyServerStr.value(), proxyConfigScriptStr.value(), config.saveCacheAndCookies, config.maxCacheSize, config.disableSameOriginPolicy, customCSSStr.value()); activeWebViews = new List<Object>(); }
public override void Initialize() { // Register object in Lua. ScriptManager.SetGlobal("Menu", this); ScriptManager.SetGlobal("isLastScene", false); webCore = new WebCore(LogLevel.None); gameMenu = new Dictionary<UIView, bool>(); // Load main menu mainMenu = new UIMain(Core, UIType.Main, 512, 512, UIFlags.Center, true); mainMenu.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/main.html")); gameMenu.Add(mainMenu, false); // Load select level menu selectLevel = new UISelectLevel(Core, UIType.SelectLevel, 512, 512, UIFlags.Center, true); selectLevel.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/select_level.html")); gameMenu.Add(selectLevel, false); // Load level finished menu levelFinished = new UILevelFinished(Core, UIType.Win, 512, 512, UIFlags.Center, true); levelFinished.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/level_finished.html")); gameMenu.Add(levelFinished, false); // Load pause menu paused = new UIPaused(Core, UIType.Pause, 512, 512, UIFlags.Center, true); paused.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/paused.html")); gameMenu.Add(paused, false); // Load dead menu dead = new UIDead(Core, UIType.Dead, 512, 512, UIFlags.Center, true); dead.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/dead.html")); gameMenu.Add(dead, false); // Load options menu options = new UIOptions(Core, UIType.Options, 512, 512, UIFlags.Center, true); options.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/options.html")); gameMenu.Add(options, false); // Load game finished menu gameFinished = new UIGameFinished(Core, UIType.Finished, 512, 512, UIFlags.Center, true); gameFinished.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/game_finished.html")); gameMenu.Add(gameFinished, false); // Load credits menu credits = new UICredits(Core, UIType.Credits, 512, 512, UIFlags.Center, true); credits.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/credits.html")); gameMenu.Add(credits, false); // Load statistics menu statistics = new UIStatistics(Core, UIType.Statistics, 512, 512, UIFlags.Center, true); statistics.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/statistics.html")); gameMenu.Add(statistics, false); // Load tutorial menu tutorial = new UITutorial(Core, UIType.Tutorial, 512, 512, UIFlags.BottomCenter, true); tutorial.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/tutorial.html")); gameMenu.Add(tutorial, false); // Load inGame menu inGame = new UIInGame(Core, UIType.InGame, 512, 512, UIFlags.BottomRight, true); inGame.LoadFile(Path.Combine(Application.StartupPath, @"data/ui/ingame.html")); gameMenu.Add(inGame, false); Helpers.GameState = Helpers.State.InMainMenu; // Set active menu only if we didn't came from an editor. if (!Core.Settings.PreviewMode) { gameMenu[mainMenu] = true; } }