public MainPage() { System.Diagnostics.Debug.WriteLine("UserAgent: " + getUserAgent()); _instance = this; _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; updateScreenSize(); InitializeComponent(); ApplicationBar.IsVisible = false; _screenOrientation = Orientation; try { // initialize C# extensions factories CSharpExtensions.InitializeExtensions(); // create rhodes runtime object var _rhoruntime = CRhoRuntime.getInstance(new MainPageWrapper(this)); _rhoruntime.setCryptoEngine(new CryptoEngineWrapper(new RhoCrypt())); // create and start rhodes main thread _rhoruntimeThread = new Thread(_rhoruntime.Execute); _rhoruntimeThread.Start(); //temporary solutions, to do refactoring //Thread.Sleep(200); _rhoruntime.onActivate(0); } catch (Exception e) { RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>"); } }
private void RhodesWebBrowser_JSNotify(object sender, NotifyEventArgs e) { String answer = CRhoRuntime.getInstance().onJSInvoke(e.Value); RhodesWebBrowser.IsScriptEnabled = true; RhodesWebBrowser.InvokeScript("nativeCallback", new string[] { answer }); }
// *** WEBVIEW *** public void navigate(string url, int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { navigate(url, index); }); return; } RhodesWebBrowser.Navigate(new Uri(url)); }
public void DisplayMessage(string msg) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { DisplayMessage(msg); }); return; } RhodesWebBrowser.NavigateToString("<html><head><title>Message</title></head><body>" + msg + "</body></html>"); }
public void Refresh(int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { Refresh(index); }); return; } RhodesWebBrowser.Navigate(new Uri(RhodesWebBrowser.Source.AbsoluteUri, UriKind.Absolute)); // another possible implementation: RhodesWebBrowser.InvokeScript("eval", "history.go()"); }
// this method is used for updating UI controls from C++ non-UI thread public void UpdateWebView(int counter) { // perform this action on UI thread only if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { UpdateWebView(counter); }); return; } // update WebView RhodesWebBrowser.NavigateToString("<html><head><title>Loading...</title></head><body>" + counter + "<input type=\"text\" name=\"test\" size=\"25\"/></body></html>"); }
public void GoForward() { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { GoForward(); }); return; } if (RhodesWebBrowser.CanGoForward) { RhodesWebBrowser.GoForward(); } }
public string executeScriptFunc(string script, int index) { string[] codeString = { script }; if (isDefaultBrowser()) { return(RhodesWebBrowser.InvokeScript("eval", codeString).ToString()); } else { return(((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).InvokeScript("eval", codeString).ToString()); } }
public string executeScriptFunc(string script, int index) { string[] codeString = { script }; if (TabbarPivot.Items.Count == 0 || _isCallbackFired)//_tabProps[index]._isInitialized == false) { _isCallbackFired = false; return(RhodesWebBrowser.InvokeScript("eval", codeString).ToString()); } else { return(((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).InvokeScript("eval", codeString).ToString()); } }
// *** WEBVIEW *** public void navigate(string url, int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { navigate(url, index); }); return; } if (isDefaultBrowser()) { RhodesWebBrowser.Navigate(new Uri(url)); } else { ((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).Navigate(new Uri(url)); } }
public void Refresh(int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { Refresh(index); }); return; } if (isDefaultBrowser()) { RhodesWebBrowser.Navigate(new Uri(RhodesWebBrowser.Source.AbsoluteUri, UriKind.Absolute)); } // another possible implementation: RhodesWebBrowser.InvokeScript("eval", "history.go()"); else { ((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).Navigate( new Uri(((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).Source.AbsoluteUri, UriKind.Absolute)); } }
public MainPage() { _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; InitializeComponent(); try { // create rhodes runtime object var rhoruntime = new CRhoRuntime(this); // create and start rhodes main thread _rhoruntimeThread = new Thread(rhoruntime.Execute); _rhoruntimeThread.Start(); } catch (Exception e) { RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>"); } }
// *** WEBVIEW *** public void navigate(string url, int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { navigate(url, index); }); return; } /*if(url.Contains("http://") == false) * { * String appdir = Windows.Storage.ApplicationData.Current.LocalFolder.Path; * url = "file:///" + appdir.Replace(@"\", "/") +"/" + url; * * }*/ if (_tabProps.Count == 0) { index = -1; } if (url == "") { return; } if (index == -1 && !_isBrowserInitialized) { initUri = url; return; } else if (index > -1 && _tabProps.ContainsKey(index) && _tabProps[index]._isInitialized == false) { _tabProps[index]._action = url; return; } if (TabbarPivot.Items.Count == 0) { RhodesWebBrowser.Navigate(new Uri(url, UriKind.RelativeOrAbsolute)); } else { ((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).Navigate(new Uri(url, UriKind.RelativeOrAbsolute)); } }
public void GoForward() { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { GoForward(); }); return; } if (isDefaultBrowser()) { if (RhodesWebBrowser.CanGoForward) { RhodesWebBrowser.GoForward(); } } else { if (((WebBrowser)((PivotItem)TabbarPivot.Items[TabbarPivot.SelectedIndex]).Content).CanGoForward) { ((WebBrowser)((PivotItem)TabbarPivot.Items[TabbarPivot.SelectedIndex]).Content).GoForward(); } } }
public void GoForward(int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { GoForward(index); }); return; } if ((TabbarPivot.Items.Count == 0) || (index < 0) || (index >= TabbarPivot.Items.Count)) { if (RhodesWebBrowser.CanGoForward) { RhodesWebBrowser.GoForward(); } } else { if (((WebBrowser)((PivotItem)TabbarPivot.Items[index]).Content).CanGoForward) { ((WebBrowser)((PivotItem)TabbarPivot.Items[index]).Content).GoForward(); } } }
public void GoBack(int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { GoBack(index); }); return; } if ((TabbarPivot.Items.Count == 0) /* || (index < 0) || (index >= TabbarPivot.Items.Count)*/) { if (RhodesWebBrowser.CanGoBack) { RhodesWebBrowser.GoBack(); } } else { if (((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).CanGoBack) { ((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).GoBack(); } } }
public MainPage() { _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; _screenWidth = Application.Current.Host.Content.ActualWidth; _screenHeight = Application.Current.Host.Content.ActualHeight; _screenPhysicalHeight = 4; // assuming 4 inches _screenPhysicalWidth = (_screenPhysicalHeight / _screenHeight) * _screenWidth; // assuming square pixels InitializeComponent(); try { // create rhodes runtime object var rhoruntime = new CRhoRuntime(this); // create and start rhodes main thread _rhoruntimeThread = new Thread(rhoruntime.Execute); _rhoruntimeThread.Start(); } catch (Exception e) { RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>"); } }
public MainPage() { _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; InitializeComponent(); try { // create rhodes runtime object var rhoruntime = new CRhoRuntime(); // set callback methods rhoruntime.SetWaitCallback(new WaitCallbackPointer(this.DoWait)); rhoruntime.SetUpdateWebViewCallback(new UpdateWebViewCallbackPointer(this.UpdateWebView)); rhoruntime.SetExitCallback(new ExitCallbackPointer(this.DoExit)); // create and start rhodes main thread _rhoruntimeThread = new Thread(rhoruntime.Execute); _rhoruntimeThread.Start(); } catch (Exception e) { RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>"); } }
public MainPage() { _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; updateScreenSize(); InitializeComponent(); ApplicationBar.IsVisible = false; try { // create rhodes runtime object var _rhoruntime = CRhoRuntime.getInstance(new MainPageWrapper(this)); // create and start rhodes main thread _rhoruntimeThread = new Thread(_rhoruntime.Execute); _rhoruntimeThread.Start(); //temporary solutions, to do refactoring Thread.Sleep(5000); _rhoruntime.onActivate(0); } catch (Exception e) { RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>"); } }
// *** WEBVIEW *** public void navigate(string url, int index) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { navigate(url, index); }); return; } if (_tabProps.Count == 0) { index = -1; } if (url == "") { return; } if (index == -1 && !_isBrowserInitialized) { initUri = url; return; } else if (index > -1 && _tabProps.ContainsKey(index) && _tabProps[index]._isInitialized == false) { _tabProps[index]._action = url; return; } if (TabbarPivot.Items.Count == 0) { RhodesWebBrowser.Navigate(new Uri(url, UriKind.RelativeOrAbsolute)); } else { ((WebBrowser)((PivotItem)TabbarPivot.Items[getValidTabbarIndex(index)]).Content).Navigate(new Uri(url, UriKind.RelativeOrAbsolute)); } }