Ejemplo n.º 1
0
            /// <summary>
            /// Set Basic Camera style like type of camera.
            /// </summary>
            /// <param name="strId"> Front or Back camera</param>
            public void InitializeCameraProperties(string strId)
            {
              
                    double WidthofScreen = 0;
                    double HeightofScreen = 0;

                    CRhoRuntime.getInstance().logEvent("Camera class-->Entered InitializeCameraProperties ");
                    try
                    {
                        // initialize class instance in C# here
                        ApplciationBarPresentStatus = new Dictionary<bool, bool>();
                        ApplciationBarPresentStatus.Add(true, true);
                        ApplciationBarPresentStatus.Add(false, false);

                        try
                        {
                            m_CameraTypes.Clear();
                            m_CameraTypes.Add("back", 0);
                            m_CameraTypes.Add("front", 1);
                            m_CameratypeMapping.Clear();
                            m_CameratypeMapping.Add(CameraType.Primary, "back");
                            m_CameratypeMapping.Add(CameraType.FrontFacing, "front");

                            // if strid is blank select the primary //Simha
                            Rho_Camera_selected = m_CameraTypes[strId];
                        }
                        catch (Exception ex)
                        {
                            CRhoRuntime.getInstance().logEvent("Camera class->Invalid Camera type Specified, So setting to default camera(back)");
                            Rho_Camera_selected = m_CameraTypes["back"];
                        }
                        using (PhotoCamera Temp_camera = new PhotoCamera((CameraType)Rho_Camera_selected))
                        {
                            Rho_Paramenters.Add("desired_height", Temp_camera.Resolution.Height);
                            Rho_Paramenters.Add("desired_width", Temp_camera.Resolution.Width);


                            Rho_AliasParametersName.Add("desiredheight", "desired_height");
                            Rho_AliasParametersName.Add("desiredwidth", "desired_width");
                            Rho_AliasParametersName.Add("flashmode", "flash_mode");



                            Rho_Paramenters.Add("camera_type", (int)Temp_camera.CameraType);

                            Rho_StringParameters.Add("filename", "Img");
                            Rho_StringParameters.Add("imageformat", "jpg");
                            Rho_StringParameters.Add("captureSound", string.Empty);


                            Rho_OutputType.Add("image", OUTPUT_FORMAT_IMAGE);
                            Rho_OutputType.Add("datauri", OUTPUT_FORMAT_DATAURI);
                            Rho_OutPutFormat.Add("outputformat", "image");


                            //CameraResolutionhsize  what is hsize meaning in this //Simha
                            IEnumerable<Size> CameraResolutionsize = Temp_camera.AvailableResolutions;
                            // change the variable name x,y to meaning ful name
                            Rho_Paramenters.Add("getmaxwidth", CameraResolutionsize.Max(x => x.Width));
                            Rho_Paramenters.Add("getmaxheight", CameraResolutionsize.Max(Y => Y.Height));
                            int Counter = 0;
                            foreach (Size ResolutionStyle in CameraResolutionsize)
                            {
                                Rho_Screen_Resolution_Height.Add(ResolutionStyle.Height);
                                Rho_Screen_Resolution_Width.Add(ResolutionStyle.Width);
                                Rho_Supported_Resolutions.Add(Counter, ResolutionStyle);
                                Counter++;
                            }
                            Rho_MainPage = MainPage.getInstance();

                            try
                            {

                                ApplicationBarPresentStatus = ApplciationBarPresentStatus[Rho_MainPage.ApplicationBarStatus()];

                            }
                            catch (Exception ex)
                            {
                                ApplicationBarPresentStatus = true;

                            }
                            Rho_Flash_Types.Add(FLASH_ON, 1);
                            Rho_Flash_Types.Add(FLASH_OFF, 2);
                            Rho_Flash_Types.Add(FLASH_AUTO, 3);
                            Rho_Flash_Types.Add(FLASH_RED_EYE, 4);
                            Rho_FlashMode = (FlashMode)(Rho_Flash_Types[FLASH_AUTO]);
                            Rho_Flashmodes.Add("flash_mode", FLASH_AUTO);
                           
                            LayoutGrid = MainPage.LayoutGrid();

                        }
                    }
                    catch (Exception ex)
                    {
                        CRhoRuntime.getInstance().logEvent("Camera class-> InitializeCameraProperties, Setting up Camera Related Variables-->Exception" + ex.Message);

                    }
                    CameraRotation = new Dictionary<PageOrientation, Dictionary<string, double>>();

                    try
                    {
                        WidthofScreen = Application.Current.Host.Content.ActualWidth;
                        HeightofScreen = Application.Current.Host.Content.ActualHeight;
                    }
                    catch (Exception ex)
                    {
                        MainPage.LayoutGrid().Dispatcher.BeginInvoke(delegate()
                        {
                            WidthofScreen = Application.Current.Host.Content.ActualWidth;
                            HeightofScreen = Application.Current.Host.Content.ActualHeight;
                        });
                        while (WidthofScreen == 0)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    Dictionary<string, double> LandscapeLeft = new Dictionary<string, double>();

                    LandscapeLeft.Add("rotation", -90);
                    LandscapeLeft.Add("Height", WidthofScreen);
                    LandscapeLeft.Add("Width", HeightofScreen);
                    LandscapeLeft.Add("CameraType", 0);

                    CameraRotation.Add(PageOrientation.LandscapeLeft, LandscapeLeft);



                    Dictionary<string, double> LandscapeRight = new Dictionary<string, double>();
                    LandscapeRight.Add("rotation", 90);
                    LandscapeRight.Add("Height", WidthofScreen);
                    LandscapeRight.Add("Width", HeightofScreen);

                    CameraRotation.Add(PageOrientation.LandscapeRight, LandscapeRight);



                    Dictionary<string, double> PortraitDown = new Dictionary<string, double>();
                    PortraitDown.Add("rotation", 0);
                    PortraitDown.Add("Height", HeightofScreen);
                    PortraitDown.Add("Width", WidthofScreen);
                    PortraitDown.Add("front", -180);

                    CameraRotation.Add(PageOrientation.PortraitDown, PortraitDown);

                    Dictionary<string, double> PortraitUp = new Dictionary<string, double>();
                    PortraitUp.Add("rotation", 0);
                    PortraitUp.Add("Height", HeightofScreen);
                    PortraitUp.Add("Width", WidthofScreen);
                    PortraitUp.Add("front", 180);

                    CameraRotation.Add(PageOrientation.PortraitUp, PortraitUp);
                    CRhoRuntime.getInstance().logEvent("Camera class-->End InitializeCameraProperties");



            
              
            }