private void LaunchBrowserProcess() { // 通信サーバ起動 Browser = new PipeCommunicator <IBrowser>( this, typeof(IBrowserHost), ServerUri, "BrowserHost"); try { // プロセス起動 if (System.IO.File.Exists(BrowserExeName)) { BrowserProcess = Process.Start(BrowserExeName, ServerUri); } else //デバッグ環境用 作業フォルダにかかわらず自分と同じフォルダのを参照する { BrowserProcess = Process.Start( System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + BrowserExeName, ServerUri); } // 残りはサーバに接続してきたブラウザプロセスがドライブする } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, "ブラウザプロセスの起動に失敗しました。"); MessageBox.Show("ブラウザプロセスの起動に失敗しました。\r\n" + ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 void LaunchBrowserProcess() { // 通信サーバ起動 Browser = new PipeCommunicator<IBrowser>( this, typeof( IBrowserHost ), ServerUri, "BrowserHost" ); try { // プロセス起動 if ( System.IO.File.Exists( BrowserExeName ) ) BrowserProcess = Process.Start( BrowserExeName, ServerUri ); else //デバッグ環境用 作業フォルダにかかわらず自分と同じフォルダのを参照する BrowserProcess = Process.Start( System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location ) + "\\" + BrowserExeName, ServerUri ); // 残りはサーバに接続してきたブラウザプロセスがドライブする } catch ( Exception ex ) { Utility.ErrorReporter.SendErrorReport( ex, Resources.FailedBrowserStart ); MessageBox.Show( Resources.FailedBrowserStart + ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error ); } }
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; } } }