private void TabbarPivot_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if ((TabbarPivot.Items.Count > 0) && (TabbarPivot.SelectedIndex >= 0) && (TabbarPivot.SelectedIndex < TabbarPivot.Items.Count)) { CRhoRuntime.getInstance().onTabbarCurrentChanged(TabbarPivot.SelectedIndex, ((string)((PivotItem)TabbarPivot.Items[TabbarPivot.SelectedIndex]).Tag)); } }
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_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) { String url = getCurrentURLFunc((sender as WebBrowser).TabIndex); CRhoRuntime.getInstance().onWebViewUrlChanged(url); int index = (sender as WebBrowser).TabIndex; if (index > -1 && _tabProps.ContainsKey(index) && !_tabProps[index]._isInitialized) { _tabProps[index]._isInitialized = true; if (_tabProps[index]._action != null) { navigate(_tabProps[index]._action, index); } } else if (TabbarPivot.Items.Count == 0 && !_isBrowserInitialized) { _isBrowserInitialized = true; navigate(initUri, -1); } else { if (TabbarPivot.Items.Count > 0 && index > -1 && _tabProps.ContainsKey(index) && url.Contains("about:blank") == false) { if (_tabProps[index]._isLoaded == false) { _tabProps[index]._isLoaded = true; } } } }
private void TabbarPivot_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if ((TabbarPivot.Items.Count > 0) && (TabbarPivot.SelectedIndex >= 0) && (TabbarPivot.SelectedIndex < TabbarPivot.Items.Count)) { for (int iTab = 0; iTab < TabbarPivot.Items.Count; ++iTab) { TabHeader th = (TabHeader)((PivotItem)TabbarPivot.Items[iTab]).Header; Brush newColor = iTab == TabbarPivot.SelectedIndex ? th.SelectedBackground : th.UnselectedBackground; th.Background = newColor; } if ((_tabProps.Count > 0) && _tabProps.ContainsKey(TabbarPivot.SelectedIndex) && ((_tabProps[TabbarPivot.SelectedIndex]._isLoaded == false) || (_tabProps[TabbarPivot.SelectedIndex]._isLoaded == true && _tabProps[TabbarPivot.SelectedIndex]._isReload == true))) { string action = ((string)((PivotItem)TabbarPivot.Items[TabbarPivot.SelectedIndex]).Tag); if (action != null) { CRhoRuntime.getInstance().onTabbarCurrentChanged(TabbarPivot.SelectedIndex, action); } } } int nOldTab = _tabIndex; _tabIndex = TabbarPivot.SelectedIndex; if ((nOldTab != _tabIndex) && (_tabIndex > -1)) { raiseTabEvent("onTabFocus", nOldTab, _tabIndex); } }
/// <summary> /// This is an overloaded method,We set the type of camera type. /// </summary> /// <param name="strID"></param> /// <param name="native"></param> public override void setNativeImpl(string strID, long native) { try{ CRhoRuntime.getInstance().logEvent(" Camera class--> setNativeImpl" + strID); base.setNativeImpl(strID, native); cameraType = strID; cameraInformation = initCameraIDs()[cameraType]; } catch (Exception ex) {} try { var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraInformation.Id }; IReadOnlyList <MediaCaptureVideoProfile> profiles = MediaCapture.FindAllVideoProfiles(cameraInformation.Id); foreach (MediaCaptureVideoProfile element in profiles) { foreach (MediaCaptureVideoProfileMediaDescription description in element.SupportedRecordMediaDescription) { try{ imageResolutions.Add(new Size(description.Width, description.Height)); } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class->" + ex.Message); } } } } catch (Exception e) { } }
private void RhodesWebBrowser_JSNotify(object sender, NotifyEventArgs e) { String answer = CRhoRuntime.getInstance().onJSInvoke(e.Value); RhodesWebBrowser.IsScriptEnabled = true; RhodesWebBrowser.InvokeScript("nativeCallback", new string[] { answer }); }
public void performOnUiThread(Int64 native) { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { performOnUiThread(native); }); return; } CRhoRuntime.getInstance().executeRhoRunnable(native); }
private void RhodesWebBrowser_JSNotify(object sender, NotifyEventArgs e) { String answer = CRhoRuntime.getInstance().onJSInvoke(e.Value); WebBrowser wb = sender as WebBrowser; wb.IsScriptEnabled = true; wb.InvokeScript("__rhoNativeApiResult", new string[] { answer }); }
public String invoke(String cmd) { System.Diagnostics.Debug.WriteLine("Invoking JS code: " + cmd); String str = CRhoRuntime.getInstance().onJSInvoke(cmd); System.Diagnostics.Debug.WriteLine(cmd + " : " + str); return(str); }
private void RhodesWebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) { CRhoRuntime.getInstance().onWebViewUrlChanged(getCurrentURLFunc(-1)); if (!_isBrowserInitialized) { _isBrowserInitialized = true; } }
public void menuAddSeparator() { if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { menuAddSeparator(); }); return; } CRhoRuntime.getInstance().logEvent("Menu separator is unimplemented on WP8"); }
/// <summary> /// Sets the Height from the avaialble Resolution,if not available then sets to the nearest available Resolution. /// </summary> /// <param name="desiredWidth">Height from the Resolution </param> /// <param name="oResult"></param> public override void setDesiredHeight(int desiredHeight, IMethodResult oResult) { try{ CRhoRuntime.getInstance().logEvent("Camera class--> setDesiredHeight" + desiredHeight); resolution.Height = desiredHeight; }catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class-->setDesiredHeight--> Exception" + ex.ToString()); } }
/// <summary> /// Get the kind of Camera (front or Back) facing. /// </summary> /// <param name="oResult"></param> public override void getCameraType(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class-> getCameraType"); try{ oResult.set(cameraType); }catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class-> getMaxWidth" + ex.Message); } }
public void navigate(string url, int tabIndex, IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { mp.navigate(CRhoRuntime.getInstance().canonicalizeRhoUrl(url), tabIndex); } }
public override void setCookie(string url, string cookie, IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { mp.setCookie(CRhoRuntime.getInstance().canonicalizeRhoUrl(url), cookie); } }
public void remove(IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { mp.toolbarRemoveAllButtons(); CRhoRuntime.getInstance().logEvent("Toolbar removed"); } }
public override void removeTab(int tabIndex, IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { mp.tabbarRemove(tabIndex); CRhoRuntime.getInstance().logEvent("Tabbar #" + tabIndex + " removed"); } }
/// <summary> /// Sets the Width from the avaialble Resolution,if not available then sets to the nearest available Resolution. /// </summary> /// <param name="desiredWidth">Width to be setted </param> /// <param name="oResult"></param> public override void setDesiredWidth(int desiredWidth, IMethodResult oResult) { try{ CRhoRuntime.getInstance().logEvent("Camera class--> setDesiredWidth " + desiredWidth); resolution.Width = desiredWidth; } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class-->setDesiredWidth--> Exception" + ex.ToString()); } }
public override void navigate(string url, int tabIndex, IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { //waitForBrowserInitialized(tabIndex); mp.navigate(CRhoRuntime.getInstance().canonicalizeRhoUrl(url), tabIndex); } }
public override void switchTab(int tabIndex, IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { mp.tabbarSwitch(tabIndex); CRhoRuntime.getInstance().logEvent("Tabbar switched to tab #" + tabIndex); } }
/// <summary> /// Choose the Pictures from the shown list. /// </summary> /// <param name="propertyMap">supports only outputformat.</param> /// <param name="oResult"></param> public override void choosePicture(IReadOnlyDictionary <string, string> propertyMap, IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> choosePicture"); dispatchInvoke(delegate() { Task task = choosePictureAsync(propertyMap, oResult); }); CRhoRuntime.getInstance().logEvent("Camera class--> End choosePicture"); }
/// <summary> /// Get Maximum Height of the Resolution /// </summary> /// <param name="oResult"></param> public override void getMaxHeight(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> getMaxHeight"); try{ oResult.set(maxResolution.Height); } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class->getMaxHeight" + ex.Message); } }
public override void remove(IMethodResult oResult) { MainPage mp = getMainPage(); if (mp != null) { //mp.tabbarRemoveAllTabs(); mp.tabbarHide(); CRhoRuntime.getInstance().logEvent("Tabbar removed"); } }
/// <summary> /// Sets the File Name to be used when picture to be saved under CameraRoll. /// </summary> /// <param name="fileName"></param> /// <param name="oResult"></param> public override void setFileName(string fileName, IMethodResult oResult) { Dictionary <bool, bool> stringnullorempty = new Dictionary <bool, bool>(); stringnullorempty.Add(false, false); try{ bool filenameemptyornull = stringnullorempty[String.IsNullOrEmpty(fileName)]; CRhoRuntime.getInstance().logEvent("Camera class--> setFileName " + fileName); rhoParameters["filename"] = fileName; }catch (Exception ex) { rhoParameters["filename"] = "Img"; } }
/// <summary> /// Set the kind of flash mode (On,Off,Auto). /// </summary> /// <param name="flashMode"></param> /// <param name="oResult"></param> public override void setFlashMode(string flashMode, IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> setFlashMode"); var Rho_FlashMode = flashMode; try { Rho_FlashMode = flashMode.ToLower().Trim(); } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class->invalid setFlashMode " + ex.ToString()); } }
/// <summary> /// Get all the Supported Resolution of the specified Camera type. /// </summary> /// <param name="oResult"></param> public override void getSupportedSizeList(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> Entered getSupportedSizeList"); List <Dictionary <string, string> > RTypes = new List <Dictionary <string, string> >(); foreach (Size size in imageResolutions) { Dictionary <string, string> Store_Resolution = new Dictionary <string, string>(); Store_Resolution.Add("width", size.Width.ToString()); Store_Resolution.Add("height", size.Height.ToString()); RTypes.Add(Store_Resolution); } oResult.set(RTypes); CRhoRuntime.getInstance().logEvent("Camera class--> End getSupportedSizeList"); }
public Camera(string id) : base(id) { initCameraIDs(); cameraType = id; deb("Creating camera with ID: " + cameraType); try{ cameraInformation = initCameraIDs()[cameraType]; } catch (Exception e) { try{ cameraInformation = initCameraIDs()["back"]; }catch (Exception exception) { cameraInformation = null; } } CRhoRuntime.getInstance().logEvent("Camera class -->Constructor"); }
/// <summary> /// Set the default value for the call back parameters /// </summary> private void initializeTakePictureCallBack() { CRhoRuntime.getInstance().logEvent("Camera class-->Initialize_TakePictureCallBack"); /*m_Take_Picture_Output.Clear(); * m_Take_Picture_Output.Add("status", "cancel"); * m_Take_Picture_Output.Add("imageUri", string.Empty); * m_Take_Picture_Output.Add("imageHeight", string.Empty); * m_Take_Picture_Output.Add("imageWidth", string.Empty); * m_Take_Picture_Output.Add("imageFormat", "jpg"); * m_Take_Picture_Output.Add("message", string.Empty); * m_Take_Picture_Output.Add("image_uri", string.Empty); * m_Take_Picture_Output.Add("image_height", string.Empty); * m_Take_Picture_Output.Add("image_width", string.Empty); * m_Take_Picture_Output.Add("image_format", "jpg");*/ }
/// <summary> /// Get the list of supported Camera /// </summary> /// <param name="oResult"></param> public override void enumerate(IMethodResult oResult) { Camera.deb("Singleton enumeration"); CRhoRuntime.getInstance().logEvent("Camera class-->enumerate"); List <string> availabeCameras = null; try { availabeCameras = Camera.initCameraIDs().Keys.ToList(); }catch (Exception e) { availabeCameras = new List <string>(); } oResult.set(availabeCameras); Camera.deb("Singleton enumeration end"); }
/// <summary> /// get either dataURI or image. /// </summary> /// <param name="outputFormat">dataURI(Base64 shall be sent) or image(path of the captured jpeg file) </param> /// <param name="oResult"></param> public override void setOutputFormat(string outputFormat, IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class->setOutputFormat type"); try { /*string DataURI = Rho_OutputType[outputFormat.ToLower().Trim()]; * Rho_OutPutFormat.Clear(); * Rho_OutPutFormat.Add("outputformat", outputFormat.ToLower().Trim());*/ if (outputFormat.ToLower().Trim() == "png") { isFormatJPG = false; } else { isFormatJPG = true; } } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class->invalid setOutputFormat " + outputFormat + " Exception " + ex.ToString()); } }