private void FormBrowser_Load(object sender, EventArgs e) { SetWindowLong(this.Handle, GWL_STYLE, WS_CHILD); // ホストプロセスに接続 BrowserHost = new PipeCommunicator <IBrowserHost>( this, typeof(IBrowser), ServerUri + "Browser", "Browser"); BrowserHost.Connect(ServerUri + "/BrowserHost"); BrowserHost.Faulted += BrowserHostChannel_Faulted; ConfigurationChanged(BrowserHost.Proxy.Configuration); // ウィンドウの親子設定&ホストプロセスから接続してもらう BrowserHost.Proxy.ConnectToBrowser(this.Handle); // 親ウィンドウが生きているか確認 HeartbeatTimer.Tick += (EventHandler)((sender2, e2) => { BrowserHost.AsyncRemoteRun(() => { HostWindow = BrowserHost.Proxy.HWND; }); }); HeartbeatTimer.Interval = 2000; // 2秒ごと HeartbeatTimer.Start(); BrowserHost.AsyncRemoteRun(() => BrowserHost.Proxy.GetIconResource()); }
public void ConnectToBrowser(IntPtr hwnd) { BrowserWnd = hwnd; // 子ウィンドウに設定 SetParent(BrowserWnd, this.Handle); MoveWindow(BrowserWnd, 0, 0, this.Width, this.Height, true); //キー入力をブラウザに投げる Application.AddMessageFilter(new KeyMessageGrabber(BrowserWnd)); // デッドロックするので非同期で処理 BeginInvoke((Action)(() => { // ブラウザプロセスに接続 Browser.Connect(ServerUri + "Browser/Browser"); Browser.Faulted += Browser_Faulted; ConfigurationChanged(); Utility.Configuration.Instance.ConfigurationChanged += ConfigurationChanged; APIObserver.Instance.APIList["api_start2/getData"].ResponseReceived += (string apiname, dynamic data) => InitialAPIReceived(apiname, data); // プロキシをセット Browser.AsyncRemoteRun(() => Browser.Proxy.SetProxy(BuildDownstreamProxy())); APIObserver.Instance.ProxyStarted += () => { Browser.AsyncRemoteRun(() => Browser.Proxy.SetProxy(BuildDownstreamProxy())); }; InitializationStage |= InitializationStageFlag.BrowserConnected; })); }
public void ConnectToBrowser(IntPtr hwnd) { BrowserWnd = hwnd; // 子ウィンドウに設定 SetParent(BrowserWnd, this.Handle); MoveWindow(BrowserWnd, 0, 0, this.Width, this.Height, true); //キー入力をブラウザに投げる Application.AddMessageFilter(new KeyMessageGrabber(BrowserWnd)); // デッドロックするので非同期で処理 BeginInvoke((Action)(() => { // ブラウザプロセスに接続 Browser.Connect(ServerUri + "Browser/Browser"); Browser.Faulted += Browser_Faulted; ConfigurationChanged(); Utility.Configuration.Instance.ConfigurationChanged += ConfigurationChanged; Observer.APIObserver.Instance.APIList["api_start2"].ResponseReceived += (string apiname, dynamic data) => InitialAPIReceived(apiname, data); // プロキシをセット Browser.AsyncRemoteRun(() => Browser.Proxy.SetProxy(Utility.Configuration.Config.Connection.UpstreamProxyAddress, Observer.APIObserver.Instance.ProxyPort)); Observer.APIObserver.Instance.ProxyStarted += () => { Browser.AsyncRemoteRun(() => Browser.Proxy.SetProxy(Utility.Configuration.Config.Connection.UpstreamProxyAddress, Observer.APIObserver.Instance.ProxyPort)); }; ++initializeCompletionCount; if (initializeCompletionCount == 2) // APIロードも完了していたら実行 { if (Utility.Configuration.Config.FormBrowser.IsEnabled) { NavigateToLogInPage(); } } })); }
private void FormBrowser_Load( object sender, EventArgs e ) { SetWindowLong( this.Handle, GWL_STYLE, WS_CHILD ); // ホストプロセスに接続 BrowserHost = new PipeCommunicator<IBrowserHost>( this, typeof( IBrowser ), ServerUri + "Browser", "Browser" ); BrowserHost.Connect( ServerUri + "/BrowserHost" ); BrowserHost.Faulted += BrowserHostChannel_Faulted; ConfigurationChanged( BrowserHost.Proxy.Configuration ); // ウィンドウの親子設定&ホストプロセスから接続してもらう BrowserHost.Proxy.ConnectToBrowser( this.Handle ); // 親ウィンドウが生きているか確認 HeartbeatTimer.Tick += (EventHandler)( ( sender2, e2 ) => { BrowserHost.AsyncRemoteRun( () => { HostWindow = BrowserHost.Proxy.HWND; } ); } ); HeartbeatTimer.Interval = 2000; // 2秒ごと HeartbeatTimer.Start(); BrowserHost.AsyncRemoteRun( () => BrowserHost.Proxy.GetIconResource() ); }
private Timer HeartbeatTimer = new Timer(); // 親プロセスが生きているか定期的に確認するためのタイマー private void FormBrowser_Load(object sender, EventArgs e) { SetWindowLong(this.Handle, (-16), 0x40000000); // GWL_STYLE = (-16), WS_CHILD = 0x40000000 // ホストプロセスに接続 BrowserHost = new PipeCommunicator<BrowserLib.IBrowserHost>( this, typeof(BrowserLib.IBrowser), ServerUri + "Browser", "Browser"); BrowserHost.Connect(ServerUri + "/BrowserHost"); BrowserHost.Faulted += BrowserHostChannel_Faulted; ConfigurationChanged(BrowserHost.Proxy.Configuration); // ウィンドウの親子設定&ホストプロセスから接続してもらう BrowserHost.Proxy.ConnectToBrowser(this.Handle); // 親ウィンドウが生きているか確認 HeartbeatTimer.Tick += (EventHandler)((sender2, e2) => { BrowserHost.AsyncRemoteRun(() => { HostWindow = BrowserHost.Proxy.HWND; }); }); HeartbeatTimer.Interval = 2000; // 2秒ごと HeartbeatTimer.Start(); BrowserHost.AsyncRemoteRun(() => BrowserHost.Proxy.GetIconResource()); // Add Bookmark Sites to Menu try { string s = String.Empty; var bookmarkFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"CefEOBrowser\bookmarks.json"); using (StreamReader sr = File.OpenText(bookmarkFilePath)) { s = sr.ReadToEnd(); } var sites = DynamicJson.Parse(s); int count = 0; foreach (var site in sites) { var control = new ToolStripMenuItem(); control.Text = site.title; control.ToolTipText = site.url; int width = 1200; int height = 700; string fontName = "Meiryo"; if (site.width()) width = (int)site.width; if (site.height()) height = (int)site.height; if (site.font()) fontName = site.font; control.Click += (s1, e1) => OpenInPopupBrowser(site.url, site.title, width, height, fontName); ToolMenu_Other_OpenInNewWindow.DropDownItems.Insert(count, control); count++; } } catch (Exception ex) { switch (BrowserUILanguage) { case "zh": AddLog(2, $"读取书签文件失败。{ex}"); break; default: AddLog(2, $"ブックマークファイルの読み込みに失敗しました。{ex}"); break; } } }