Пример #1
0
        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>");
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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;
                    }
                }
            }
        }
Пример #4
0
 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));
     }
 }
Пример #5
0
        private void RhodesWebBrowser_JSNotify(object sender, NotifyEventArgs e)
        {
            String answer = CRhoRuntime.getInstance().onJSInvoke(e.Value);

            RhodesWebBrowser.IsScriptEnabled = true;
            RhodesWebBrowser.InvokeScript("nativeCallback", new string[] { answer });
        }
Пример #6
0
            /// <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) { }
            }
Пример #7
0
        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 });
        }
Пример #8
0
 public void performOnUiThread(Int64 native)
 {
     if (!isUIThread)
     {
         Dispatcher.BeginInvoke(delegate() { performOnUiThread(native); }); return;
     }
     CRhoRuntime.getInstance().executeRhoRunnable(native);
 }
Пример #9
0
 public void menuAddSeparator()
 {
     if (!isUIThread)
     {
         Dispatcher.BeginInvoke(delegate() { menuAddSeparator(); }); return;
     }
     CRhoRuntime.getInstance().logEvent("Menu separator is unimplemented on WP8");
 }
Пример #10
0
        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);
        }
Пример #11
0
 private void RhodesWebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     CRhoRuntime.getInstance().onWebViewUrlChanged(getCurrentURLFunc(-1));
     if (!_isBrowserInitialized)
     {
         _isBrowserInitialized = true;
     }
 }
Пример #12
0
 /// <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());
     }
 }
Пример #13
0
 /// <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);
     }
 }
Пример #14
0
            public override void setCookie(string url, string cookie, IMethodResult oResult)
            {
                MainPage mp = getMainPage();

                if (mp != null)
                {
                    mp.setCookie(CRhoRuntime.getInstance().canonicalizeRhoUrl(url), cookie);
                }
            }
Пример #15
0
            public void navigate(string url, int tabIndex, IMethodResult oResult)
            {
                MainPage mp = getMainPage();

                if (mp != null)
                {
                    mp.navigate(CRhoRuntime.getInstance().canonicalizeRhoUrl(url), tabIndex);
                }
            }
Пример #16
0
            public void remove(IMethodResult oResult)
            {
                MainPage mp = getMainPage();

                if (mp != null)
                {
                    mp.toolbarRemoveAllButtons();
                    CRhoRuntime.getInstance().logEvent("Toolbar removed");
                }
            }
Пример #17
0
 /// <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());
     }
 }
Пример #18
0
            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);
                }
            }
Пример #19
0
            /// <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);
                }
            }
Пример #20
0
            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);
                }
            }
Пример #21
0
            public override void removeTab(int tabIndex, IMethodResult oResult)
            {
                MainPage mp = getMainPage();

                if (mp != null)
                {
                    mp.tabbarRemove(tabIndex);
                    CRhoRuntime.getInstance().logEvent("Tabbar #" + tabIndex + " removed");
                }
            }
Пример #22
0
            /// <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");
            }
Пример #23
0
            public override void remove(IMethodResult oResult)
            {
                MainPage mp = getMainPage();

                if (mp != null)
                {
                    //mp.tabbarRemoveAllTabs();
                    mp.tabbarHide();
                    CRhoRuntime.getInstance().logEvent("Tabbar removed");
                }
            }
Пример #24
0
            /// <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";
                }
            }
Пример #25
0
            /// <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());
                }
            }
Пример #26
0
            /// <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");
            }
Пример #27
0
            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");
            }
Пример #28
0
            /// <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");*/
            }
Пример #29
0
            /// <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");
            }
Пример #30
0
        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>");
            }
        }
Пример #31
0
 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>");
     }
 }
Пример #32
0
        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>");
            }
        }
Пример #33
0
 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>");
     }
 }