/// <summary> /// Show a new Web Control form /// </summary> /// <param name="sender">Object that raised the event</param> /// <param name="e">Event arguments</param> private void ShowBtn_Click(object sender, EventArgs e) { if (_service != null && !_service.IsClosed()) { MessageBox.Show(this, "Form already opened", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { _service?.Destroy(); //Generates client id and server id string appId = Guid.NewGuid().ToString("N"); string controlId = Guid.NewGuid().ToString("N"); _service = AppServer.Start(appId, controlId); _service.FormCompleted += Service_FormCompleted; _locator = new FormServiceLocator(appId, controlId); _element = _handle.CreateElement(_locator); _service.StartRemoteClient(); _service.Show((long)Handle); } catch (Exception ex) { MessageBox.Show(this, $"Unable to show message: {ex.Message}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public BrowserWindow(string url, IPersistGeometry geometry, string appDataPath) { InitializeComponent(); this.url = url; this.appDataPath = appDataPath; this.geometry = geometry; try { geometry?.Restore(this); safeAppHostChildHandle = new ChildProcessFactory() .Create("AppHostCefSharp.WebBrowser.dll"); locator = new BrowserServiceLocator(url, appDataPath); Content = safeAppHostChildHandle.CreateElement(locator); Closing += (sender, args) => { locator.Close(); geometry?.Persist(this); }; } catch (Exception ex) { Content = new TextBlock { Text = ex.ToString() }; } }
public void Refresh() { locator.Close(); geometry?.Persist(this); safeAppHostChildHandle = new ChildProcessFactory() .Create("AppHostCefSharp.WebBrowser.dll"); locator = new BrowserServiceLocator(url, appDataPath); Content = safeAppHostChildHandle.CreateElement(locator); }