Пример #1
0
 private void ShowOrientationText(SimpleOrientation simpleOrientation)
 {
     switch (simpleOrientation)
     {
         case SimpleOrientation.NotRotated:
             AlertBox.Text = "Not Rotated";
             break;
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             AlertBox.Text = "90 Degrees CounterClockwise";
             break;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             AlertBox.Text = "180 Degrees Rotated";
             break;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             AlertBox.Text = "270 Degrees Rotated CounterClockwise";
             break;
         case SimpleOrientation.Facedown:
             AlertBox.Text = "Face Down";
             break;
         case SimpleOrientation.Faceup:
             AlertBox.Text = "Face Up";
             break;
         default:
             AlertBox.Text = "Unknown";
             break;
     }
 }
Пример #2
0
 /// <summary>
 /// Helper method to display the device orientation in the specified text box.
 /// </summary>
 /// <param name="tb">
 /// The text box receiving the orientation value.
 /// </param>
 /// <param name="orientation">
 /// The orientation value.
 /// </param>
 private void DisplayOrientation(TextBlock tb, SimpleOrientation orientation)
 {
     switch (orientation)
     {
         case SimpleOrientation.NotRotated:
             tb.Text = "Not Rotated";
             break;
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             tb.Text = "Rotated 90 Degrees Counterclockwise";
             break;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             tb.Text = "Rotated 180 Degrees Counterclockwise";
             break;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             tb.Text = "Rotated 270 Degrees Counterclockwise";
             break;
         case SimpleOrientation.Faceup:
             tb.Text = "Faceup";
             break;
         case SimpleOrientation.Facedown:
             tb.Text = "Facedown";
             break;
         default:
             tb.Text = "Unknown orientation";
             break;
     }
 }
Пример #3
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     if (orientationSensor != null)
     {
         deviceOrientation = orientationSensor.GetCurrentOrientation();
     }
     await InitializeCameraAsync();
     RegisterEventHandlers();
 }
Пример #4
0
 private VideoRotation GetVideoRotation(SimpleOrientation orientation)
 {
     switch (orientation)
     {
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             return VideoRotation.Clockwise270Degrees;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             return VideoRotation.Clockwise180Degrees;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             return VideoRotation.Clockwise90Degrees;
         default:
             return VideoRotation.None;
     }
 }
        /// <summary>
        /// Converts the given orientation of the device in space to the corresponding rotation in degrees
        /// </summary>
        /// <param name="orientation">The orientation of the device in space</param>
        /// <returns>An orientation in degrees</returns>
        private static int ConvertDeviceOrientationToDegrees(SimpleOrientation orientation)
        {
            switch (orientation)
            {
            case SimpleOrientation.Rotated90DegreesCounterclockwise:
                return(90);

            case SimpleOrientation.Rotated180DegreesCounterclockwise:
                return(180);

            case SimpleOrientation.Rotated270DegreesCounterclockwise:
                return(270);

            case SimpleOrientation.NotRotated:
            default:
                return(0);
            }
        }
        private static VideoRotation ConvertSimpleOrientationToVideoRotation(SimpleOrientation orientation)
        {
            switch (orientation)
            {
            case SimpleOrientation.Rotated90DegreesCounterclockwise:
                return(VideoRotation.Clockwise270Degrees);

            case SimpleOrientation.Rotated180DegreesCounterclockwise:
                return(VideoRotation.Clockwise180Degrees);

            case SimpleOrientation.Rotated270DegreesCounterclockwise:
                return(VideoRotation.Clockwise90Degrees);

            case SimpleOrientation.NotRotated:
            default:
                return(VideoRotation.None);
            }
        }
        /// <summary>
        /// Converts the given orientation of the device in space to the metadata that can be added to captured photos
        /// </summary>
        /// <param name="orientation">The orientation of the device in space</param>
        /// <returns></returns>
        private static PhotoOrientation ConvertOrientationToPhotoOrientation(SimpleOrientation orientation)
        {
            switch (orientation)
            {
            case SimpleOrientation.Rotated90DegreesCounterclockwise:
                return(PhotoOrientation.Rotate90);

            case SimpleOrientation.Rotated180DegreesCounterclockwise:
                return(PhotoOrientation.Rotate180);

            case SimpleOrientation.Rotated270DegreesCounterclockwise:
                return(PhotoOrientation.Rotate270);

            case SimpleOrientation.NotRotated:
            default:
                return(PhotoOrientation.Normal);
            }
        }
Пример #8
0
        public InCall()
        {
            this.InitializeComponent();
            this.DataContext = new InCallModel();
            askingVideo      = false;

            if (LinphoneManager.Instance.IsVideoAvailable)
            {
                StartVideoStream();
                VideoGrid.Visibility = Visibility.Collapsed;
            }

            if (LinphoneManager.Instance.Core.CurrentCall.State == CallState.StreamsRunning)
            {
                Status.Text = "00:00:00";
            }

            displayOrientation = ApplicationView.GetForCurrentView().Orientation;
            displayInformation = DisplayInformation.GetForCurrentView();
            deviceOrientation  = SimpleOrientation.NotRotated;
            orientationSensor  = SimpleOrientationSensor.GetDefault();
            if (orientationSensor != null)
            {
                deviceOrientation = orientationSensor.GetCurrentOrientation();
                SetVideoOrientation();
                orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged;
            }

            buttons.HangUpClick    += buttons_HangUpClick;
            buttons.StatsClick     += buttons_StatsClick;
            buttons.CameraClick    += buttons_CameraClick;
            buttons.PauseClick     += buttons_PauseClick;
            buttons.SpeakerClick   += buttons_SpeakerClick;
            buttons.MuteClick      += buttons_MuteClick;
            buttons.VideoClick     += buttons_VideoClick;
            buttons.BluetoothClick += buttons_BluetoothClick;
            buttons.DialpadClick   += buttons_DialpadClick;

            // Handling event when app will be suspended
            Application.Current.Suspending += new SuspendingEventHandler(App_Suspended);
            Application.Current.Resuming   += new EventHandler <object>(App_Resumed);
            pausedCall = null;
        }
Пример #9
0
        async Task SetupUIAsync()
        {
            // Lock page to landscape to prevent the capture element from rotating
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            displayOrientation = displayInformation.CurrentOrientation;
            if (orientationSensor != null)
            {
                deviceOrientation = orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();
        }
Пример #10
0
        }//end onNavigatedTo()

        //This event handler is triggered when the orientation of the phone changes, because the method uses the
        //async keyword it will happen asynchronously. Hence allowing the application to continue with other tasks while this
        //method is being executed in a seperate thread.
        //On this page we want the orientation to remain in portrait no matter what direction the phone has been flipped in
        private async void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                SimpleOrientation orientation = e.Orientation;      //Here we retrieve the current orientation of the sensor
                switch (orientation)
                {
                case SimpleOrientation.NotRotated:                                             //If the phone isnt being rotated (portrait)
                    //Portrait
                    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait; //Set orientation to portrait
                    break;

                case SimpleOrientation.Rotated90DegreesCounterclockwise:                       //if rotated 90degrees to the left
                    //Landscape
                    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait; //set orientation to portrait
                    break;
                }
            });
        }
Пример #11
0
        private string GetText(SimpleOrientation orientation)
        {
            switch (orientation)
            {
            case SimpleOrientation.Faceup: return("Face-up");

            case SimpleOrientation.Facedown: return("Face-down");

            case SimpleOrientation.NotRotated: return("Not rotated");

            case SimpleOrientation.Rotated90DegreesCounterclockwise: return("Rotated 90° counter-clockwise");

            case SimpleOrientation.Rotated180DegreesCounterclockwise: return("Rotated 180° counter-clockwise");

            case SimpleOrientation.Rotated270DegreesCounterclockwise: return("Rotated 270° counter-clockwise");

            default: return("Unknown");
            }
        }
Пример #12
0
            public override void readData(IMethodResult oResult)
            {
                Dictionary <string, string> result = new Dictionary <string, string>();

                try
                {
                    _screenOrientation = SimpleOrientationSensor.GetDefault().GetCurrentOrientation();
                    result.Add("status", SENSOR_STATUS_OK);
                    switch (_screenOrientation)
                    {
                    case SimpleOrientation.Faceup:
                        result.Add("deviceorientation_value", NORMAL);
                        break;

                    case SimpleOrientation.Rotated180DegreesCounterclockwise:
                        result.Add("deviceorientation_value", UPSIDE_DOWN);
                        break;

                    case SimpleOrientation.Rotated90DegreesCounterclockwise:
                        result.Add("deviceorientation_value", LANDSCAPE_RIGHT);
                        break;

                    case SimpleOrientation.Rotated270DegreesCounterclockwise:
                        result.Add("deviceorientation_value", LANDSCAPE_LEFT);
                        break;

                    default:
                        result.Add("deviceorientation_value", NORMAL);
                        break;
                    }

                    result.Add("type", type);
                }
                catch (Exception e) {
                    _screenOrientation = SimpleOrientation.Faceup;
                    result.Add("status", SENSOR_STATUS_ERROR);
                    result.Add("message", e.Message);
                }


                oResult.set(result);
            }
        private void LaunchTimer_Click(object sender, RoutedEventArgs e)
        {
            var timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };

            timer.Tick += (s, a) =>
            {
                var currentOrientation = SimpleOrientationSensor.GetDefault().GetCurrentOrientation();
                if (currentOrientation == _orientation)
                {
                    return;
                }

                _orientation    = currentOrientation;
                textBlock.Text += PrintOrientation("timer", currentOrientation);
            };
            timer.Start();
        }
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Attempt to lock page to landscape orientation to prevent the CaptureElement from rotating, as this gives a better experience
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();
        }
Пример #15
0
        void Broadcast(IObserver <DeviceOrientation> ob, SimpleOrientation orientation)
        {
            switch (orientation)
            {
            case SimpleOrientation.NotRotated:
                ob.OnNext(DeviceOrientation.LandscapeLeft);
                break;

            case SimpleOrientation.Rotated90DegreesCounterclockwise:
                ob.OnNext(DeviceOrientation.Portrait);
                break;

            case SimpleOrientation.Rotated180DegreesCounterclockwise:
                ob.OnNext(DeviceOrientation.LandscapeRight);
                break;

            case SimpleOrientation.Rotated270DegreesCounterclockwise:
                ob.OnNext(DeviceOrientation.PortraitUpsideDown);
                break;
            }
        }
Пример #16
0
 private async void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     SimpleOrientation orientation = args.Orientation;
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         // Switch the placement of the buttons based on an orientation change.
         if (SimpleOrientation.NotRotated == orientation)
         {
             Panel1.Visibility = Visibility.Collapsed;
             Panel2.Visibility = Visibility.Collapsed;
             Panel3.Visibility = Visibility.Collapsed;
         }
         // If not in portrait, move buttonList content to visible row and column.
         else
         {
             Panel1.Visibility = Visibility.Visible;
             Panel2.Visibility = Visibility.Visible;
             Panel3.Visibility = Visibility.Visible;
         }
     });
 }
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();

            var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

            // Fall back to the local app storage if the Pictures Library is not available
            _captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
        }
Пример #18
0
        /// <summary>
        /// Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI
        /// </summary>
        /// <returns></returns>
        public async Task Initialize(string faceKey, string emotionKey)
        {
            Debug.WriteLine("Initialize-Facedetector");

            _faceKey    = faceKey;
            _emotionKey = emotionKey;

            _faceMetaData = new FaceMetaData(_faceKey, _emotionKey);
            _faceMetaData.DetectedFaces += FaceMetaData_DetectedFaces;

            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            // Clear any rectangles that may have been left over from a previous instance of the effect
            FacesCanvas.Children.Clear();

            DeviceInformationCollection allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            CameraListBox.ItemsSource = allVideoDevices;
        }
Пример #19
0
        async Task SetupUIAsync()
        {
            // Lock page to landscape to prevent the capture element from rotating
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            displayOrientation = displayInformation.CurrentOrientation;
            if (orientationSensor != null)
            {
                deviceOrientation = orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();

            var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

            // Fallback to local app storage if no pictures library
            captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
        }
        async Task SetupUIAsync()
        {
            // Lock page to landscape to prevent the capture element from rotating
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            displayOrientation = displayInformation.CurrentOrientation;
            if (orientationSensor != null)
            {
                deviceOrientation = orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();

            var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
            // Fallback to local app storage if no pictures library
            captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
        }
        public static SimpleOrientation ToSimpleOrientation(this DisplayInformation displayInformation, SimpleOrientation deviceOrientation, bool isFlipped)
        {
            var result = deviceOrientation;

            if (displayInformation.NativeOrientation == DisplayOrientations.Portrait)
            {
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    result = SimpleOrientation.NotRotated;
                    break;

                case SimpleOrientation.Rotated180DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated90DegreesCounterclockwise;
                    break;

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated180DegreesCounterclockwise;
                    break;

                case SimpleOrientation.NotRotated:
                    result = SimpleOrientation.Rotated270DegreesCounterclockwise;
                    break;
                }
            }

            if (isFlipped)
            {
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated270DegreesCounterclockwise);

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated90DegreesCounterclockwise);
                }
            }

            return(result);
        }
        private static SimpleOrientation ToSimpleOrientationRelativeToPortrait(int orientation, SimpleOrientation previousOrientation)
        {
            // https://developer.android.com/reference/android/view/OrientationEventListener.html
            // orientation parameter is in degrees, ranging from 0 to 359.
            // orientation is:
            // - 0 degrees when the device is oriented in its natural position
            // - 90 degrees when its left side is at the top
            // - 180 degrees when it is upside down
            // - 270 degrees when its right side is to the top
            // - ORIENTATION_UNKNOWN when the device is close to flat and the orientation cannot be determined.

            if (orientation == OrientationEventListener.OrientationUnknown)
            {
                // device is close to flat then we push a face-up by default.
                return(SimpleOrientation.Faceup);
            }

            if (DefaultDeviceOrientation == Orientation.Landscape)
            {
                // we offset the rotation by 270 degrees because
                // we want an orientation relative to Portrait
                orientation = (orientation + 270) % 360;
            }

            // Ensures orientation only changes when within close range to new orientation.
            // Empirical testing on an Android 6.0 device indicates that orientation changes
            // when within about 22.5° (90° / 4) of a new orientation (0°, 90°, 180°, 270°).
            var threshold = 22.5;

            if (Math.Abs(orientation - 0) < threshold || Math.Abs(orientation - 360) < threshold)
            {
                // natural position
                return(SimpleOrientation.NotRotated);
            }
            else if (Math.Abs(orientation - 90) < threshold)
            {
                // left side is at the top
                return(SimpleOrientation.Rotated270DegreesCounterclockwise);
            }
            else if (Math.Abs(orientation - 180) < threshold)
            {
                // upside down
                return(SimpleOrientation.Rotated180DegreesCounterclockwise);
            }
            else if (Math.Abs(orientation - 270) < threshold)
            {
                // right side is to the top
                return(SimpleOrientation.Rotated90DegreesCounterclockwise);
            }
            else
            {
                return(previousOrientation);
            }
        }
Пример #23
0
 private void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         // Only update the current orientation if the device is not parallel to the ground. This allows users to take pictures of documents (FaceUp)    
         deviceOrientation = args.Orientation;
     }
 }
Пример #24
0
        private async void ajustes()
        {
            var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;
            deviceFamily = qualifiers["DeviceFamily"];

            double Width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;
            double Height = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Height;

            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            if (deviceFamily == "Mobile")
            {
                //Content.Visibility = Visibility.Collapsed;

                MainGrid.ColumnDefinitions[0].Width = new GridLength(1577 + 723);
                MainGrid.ColumnDefinitions[1].Width = new GridLength(0);
                MainGrid.RowDefinitions[0].Height = new GridLength(1106);
                MainGrid.RowDefinitions[1].Height = new GridLength(2990);

                Page.SetValue(Grid.ColumnProperty, 0);
                Page.SetValue(Grid.RowProperty, 1);
                Page.Margin = new Thickness(Width * 0.026);

                age_genre.FontSize = 80;
                age_genre.Foreground = new SolidColorBrush(Colors.White);
            }
            else
            {
                //MainGrid.ColumnDefinitions[0].Width = new GridLength(Width * 0.27);
                //MainGrid.ColumnDefinitions[1].Width = new GridLength(Width * 0.72);
                //MainGrid.RowDefinitions[0].Height = new GridLength(Height * 0.27);
                //MainGrid.RowDefinitions[1].Height = new GridLength(Height * 0.72);

                //GridLength minWidth = new GridLength(300);
                //GridLength mg = MainGrid.ColumnDefinitions[0].Width;

                //if (mg.Value < minWidth.Value)
                //{
                //    MainGrid.ColumnDefinitions[0].Width = minWidth;
                //    HoldCamera.Margin = new Thickness(300 * 0.026);
                //    LeftPanel.Margin = new Thickness(300 * 0.026);
                //}

                //HoldCamera.Margin = new Thickness(Width * 0.026);
                //LeftPanel.Margin = new Thickness(Width * 0.026);
                //ProductImage.Margin = new Thickness(Width * 0.026);
                //Content.Margin = new Thickness(Width * 0.026);
                //ProductName.Margin = new Thickness(Width * 0.015625, Height * 0.027777, Width * 0.15625, Height * 0.925925);
                //Price.Margin = new Thickness(Width * 0.3125, Height * 0.027777, Width * 0.015625, Height * 0.185185);
                //logoStore.Margin = new Thickness(Width * 0.3125, Height * 0.185185, Width * 0.015625, Height * 0.027777);
            }

            RegisterEventHandlers();
            await InitContiniousRecognition();
        }
Пример #25
0
        public void UpdateText(SensorData sensorData)
        {
            try
            {
                int index = sensorData._reading.Count - 1;
                if (sensorData._count == Sensor.currentId)
                {
                    UpdateProperty(sensorData._deviceId, sensorData._deviceName, sensorData._reportInterval, sensorData._minReportInterval, sensorData._reportLatency,
                                   sensorData._category, sensorData._persistentUniqueId, sensorData._manufacturer, sensorData._model, sensorData._connectionType);
                }

                if (StackPanelSensor.Visibility == Visibility.Visible)
                {
                    if (sensorData._sensorType == Sensor.ACCELEROMETER || sensorData._sensorType == Sensor.ACCELEROMETERLINEAR || sensorData._sensorType == Sensor.ACCELEROMETERGRAVITY)
                    {
                        double margin = 80;
                        double x      = Math.Min(1, sensorData._reading[index].value[0]);
                        double y      = Math.Min(1, sensorData._reading[index].value[1]);
                        double square = x * x + y * y;

                        if (square > 1)
                        {
                            x /= Math.Sqrt(square);
                            y /= Math.Sqrt(square);
                        }

                        DisplayInformation displayInformation = DisplayInformation.GetForCurrentView();
                        if (displayInformation.NativeOrientation == DisplayOrientations.Landscape)
                        {
                            switch (displayInformation.CurrentOrientation)
                            {
                            case DisplayOrientations.Landscape: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = margin * x, Bottom = margin * y
                            }; break;

                            case DisplayOrientations.Portrait: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = margin * y, Bottom = -margin * x
                            }; break;

                            case DisplayOrientations.LandscapeFlipped: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = -margin * x, Bottom = -margin * y
                            }; break;

                            case DisplayOrientations.PortraitFlipped: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = -margin * y, Bottom = margin * x
                            }; break;
                            }
                        }
                        else if (displayInformation.NativeOrientation == DisplayOrientations.Portrait)
                        {
                            switch (displayInformation.CurrentOrientation)
                            {
                            case DisplayOrientations.Landscape: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = -margin * y, Bottom = margin * x
                            }; break;

                            case DisplayOrientations.Portrait: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = margin * x, Bottom = margin * y
                            }; break;

                            case DisplayOrientations.LandscapeFlipped: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = margin * y, Bottom = -margin * x
                            }; break;

                            case DisplayOrientations.PortraitFlipped: EllipseAccelerometer.Margin = new Thickness()
                            {
                                    Left = -margin * x, Bottom = -margin * y
                            }; break;
                            }
                        }
                    }

                    for (int i = 0; i < sensorData._reading[index].value.Length; i++)
                    {
                        TextBlockProperty[i].Text = sensorData._property[i];
                        TextBlockValue[i].Text    = String.Format("        {0,5:0.00}", sensorData._reading[index].value[i]);
                        TextBlockMinValue[i].Text = String.Format("        {0,5:0.0}", sensorData._minValue[i]);
                        TextBlockMaxValue[i].Text = String.Format("        {0,5:0.0}", sensorData._maxValue[i]);
                        if (sensorData._property[i].StartsWith("MagneticNorth"))
                        {
                            RotateTransform rotateCompass = new RotateTransform();
                            ImageCompass.RenderTransform = rotateCompass;

                            rotateCompass.Angle   = (-1) * Convert.ToDouble(sensorData._reading[index].value[i]);
                            rotateCompass.CenterX = ImageCompass.ActualWidth / 2;
                            rotateCompass.CenterY = ImageCompass.ActualHeight / 2;
                        }
                        else if (sensorData._property[i].StartsWith("AngularVelocityX"))
                        {
                            RotateTransform rotateGyrometerX = new RotateTransform()
                            {
                                CenterX = ImageGyrometerX.ActualWidth / 2, CenterY = ImageGyrometerX.ActualHeight / 2
                            };
                            ImageGyrometerX.RenderTransform = rotateGyrometerX;

                            rotateGyrometerX.Angle = Math.Max(-135, Math.Min(135, Convert.ToDouble(sensorData._reading[index].value[i])));
                        }
                        else if (sensorData._property[i].StartsWith("AngularVelocityY"))
                        {
                            RotateTransform rotateGyrometerY = new RotateTransform();
                            ImageGyrometerY.RenderTransform = rotateGyrometerY;

                            rotateGyrometerY.Angle   = Math.Max(-135, Math.Min(135, Convert.ToDouble(sensorData._reading[index].value[i])));
                            rotateGyrometerY.CenterX = ImageGyrometerY.ActualWidth / 2;
                            rotateGyrometerY.CenterY = ImageGyrometerY.ActualHeight / 2;
                        }
                        else if (sensorData._property[i].StartsWith("AngularVelocityZ"))
                        {
                            RotateTransform rotateGyrometerZ = new RotateTransform();
                            ImageGyrometerZ.RenderTransform = rotateGyrometerZ;

                            rotateGyrometerZ.Angle   = Math.Max(-135, Math.Min(135, Convert.ToDouble(sensorData._reading[index].value[i])));
                            rotateGyrometerZ.CenterX = ImageGyrometerZ.ActualWidth / 2;
                            rotateGyrometerZ.CenterY = ImageGyrometerZ.ActualHeight / 2;
                        }
                        else if (sensorData._property[i].StartsWith("Pitch"))
                        {
                            RotateTransform rotate = new RotateTransform()
                            {
                                CenterX = ImageInclinometerPitch.ActualWidth / 2, CenterY = ImageInclinometerPitch.ActualHeight / 2
                            };
                            ImageInclinometerPitch.RenderTransform = rotate;

                            rotate.Angle = sensorData._reading[index].value[i];
                        }
                        else if (sensorData._property[i].StartsWith("Roll"))
                        {
                            RotateTransform rotate = new RotateTransform()
                            {
                                CenterX = ImageInclinometerRoll.ActualWidth / 2, CenterY = ImageInclinometerRoll.ActualHeight / 2
                            };
                            ImageInclinometerRoll.RenderTransform = rotate;

                            rotate.Angle = sensorData._reading[index].value[i];
                        }
                        else if (sensorData._property[i] == "Yaw (°)")
                        {
                            RotateTransform rotate = new RotateTransform()
                            {
                                CenterX = ImageInclinometerYaw.ActualWidth / 2, CenterY = ImageInclinometerYaw.ActualHeight / 2
                            };
                            ImageInclinometerYaw.RenderTransform = rotate;

                            rotate.Angle = -sensorData._reading[index].value[i];
                        }
                        else if (sensorData._property[i] == "Illuminance (lux)")
                        {
                            TextBlockSensor.Text = "💡";
                            if (sensorData._reading[index].value[i] < 1)
                            {
                                TextBlockSensor.Opacity = 0.1;
                            }
                            else
                            {
                                TextBlockSensor.Opacity = Math.Min(0.1 + Math.Log(sensorData._reading[index].value[i], 2) / 10, 1);
                            }
                        }
                        else if (sensorData._property[i] == "CumulativeSteps")
                        {
                            int value = Convert.ToInt32(sensorData._reading[index].value[i]) / 100;
                            _plotCanvas.SetRange((value + 1) * 100, value * 100);
                        }
                        else if (sensorData._property[i] == "HeadingAccuracy" || sensorData._property[i] == "YawAccuracy")
                        {
                            MagnetometerAccuracy magnetometerAccuracy = (MagnetometerAccuracy)sensorData._reading[index].value[i];
                            TextBlockValue[i].Text = String.Format("        {0}", magnetometerAccuracy);
                        }
                        else if (sensorData._property[i] == "IsDetected")
                        {
                            TextBlockSensor.Text = (sensorData._reading[index].value[i] > 0.5 ? "📲" : "📱");
                        }
                        else if (sensorData._property[i] == "StepKind")
                        {
                            PedometerStepKind pedometerStepKind = (PedometerStepKind)sensorData._reading[index].value[i];
                            TextBlockValue[i].Text = String.Format("        {0}", pedometerStepKind);

                            TextBlockSensor.Text = DictionaryStepKind[pedometerStepKind];
                        }
                        else if (sensorData._sensorType == Sensor.SIMPLEORIENTATIONSENSOR)
                        {
                            SimpleOrientation simpleOrientation = (SimpleOrientation)sensorData._reading[index].value[i];
                            TextBlockValue[i].Text    = String.Format("        {0}", simpleOrientation).Replace("DegreesCounterclockwise", "°↺");
                            TextBlockMinValue[i].Text = "";
                            TextBlockMaxValue[i].Text = "";
                        }
                        else if (sensorData._sensorType == Sensor.ACTIVITYSENSOR)
                        {
                            if (sensorData._reading[index].value[i] == Sensor.ACTIVITYNONE)
                            {
                                TextBlockValue[i].Text = "None";
                            }
                            else if (sensorData._reading[index].value[i] == Sensor.ACTIVITYNOTSUPPORTED)
                            {
                                TextBlockValue[i].Text = "Not Supported";
                            }
                            else
                            {
                                ActivitySensorReadingConfidence activitySensorReadingConfidence = (ActivitySensorReadingConfidence)sensorData._reading[index].value[i];
                                TextBlockValue[i].Text = String.Format("        {0}", activitySensorReadingConfidence);
                                TextBlockSensor.Text   = DictionaryActivity[(ActivityType)i];
                            }
                        }
                        else if (sensorData._sensorType == Sensor.LIGHTSENSOR)
                        {
                            if (sensorData._reading[index].value[i] == -1)
                            {
                                TextBlockValue[i].Text    = "N/A";
                                TextBlockMinValue[i].Text = "N/A";
                                TextBlockMaxValue[i].Text = "N/A";
                            }
                        }
                    }
                }
            }
            catch { }
        }
Пример #26
0
        private SimpleOrientation GetCameraOrientation(DisplayInformation displayInformation, SimpleOrientation deviceOrientation)
        {
            var result = deviceOrientation;

            // Account for the fact that, on portrait-first devices, the camera sensor is mounted at a 90 degree offset to the native orientation
            if (displayInformation.NativeOrientation == DisplayOrientations.Portrait)
            {
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    result = SimpleOrientation.NotRotated;
                    break;

                case SimpleOrientation.Rotated180DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated90DegreesCounterclockwise;
                    break;

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated180DegreesCounterclockwise;
                    break;

                case SimpleOrientation.NotRotated:
                    result = SimpleOrientation.Rotated270DegreesCounterclockwise;
                    break;
                }
            }

            // If the preview is being mirrored for a front-facing camera, then the rotation should be inverted
            if (_mirroringPreview)
            {
                // This only affects the 90 and 270 degree cases, because rotating 0 and 180 degrees is the same clockwise and counter-clockwise
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated270DegreesCounterclockwise);

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated90DegreesCounterclockwise);
                }
            }

            return(result);
        }
        /// <summary>
        /// Occurs each time the simple orientation sensor reports a new sensor reading.
        /// </summary>
        /// <param name="sender">The event source.</param>
        /// <param name="args">The event data.</param>
        private async void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
            {
                // Only update the current orientation if the device is not parallel to the ground. This allows users to take pictures of documents (FaceUp)
                // or the ceiling (FaceDown) in portrait or landscape, by first holding the device in the desired orientation, and then pointing the camera
                // either up or down, at the desired subject.
                //Note: This assumes that the camera is either facing the same way as the screen, or the opposite way. For devices with cameras mounted
                //      on other panels, this logic should be adjusted.
                _deviceOrientation = args.Orientation;

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => UpdateButtonOrientation());
            }
        }
 void OnOrientationSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     // Only update orientatino if the device is not parallel to the ground
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         deviceOrientation = args.Orientation;
     }
 }
 private static SimpleOrientation SubtractOrientations(SimpleOrientation a, SimpleOrientation b)
 {
     var aRot = ConvertSimpleOrientationToClockwiseDegrees(a);
     var bRot = ConvertSimpleOrientationToClockwiseDegrees(b);
     // Add 360 to ensure the modulus operator does not operate on a negative
     var result = (360 + (aRot - bRot)) % 360;
     return ConvertClockwiseDegreesToSimpleOrientation(result);
 }
 private static SimpleOrientation AddOrientations(SimpleOrientation a, SimpleOrientation b)
 {
     var aRot = ConvertSimpleOrientationToClockwiseDegrees(a);
     var bRot = ConvertSimpleOrientationToClockwiseDegrees(b);
     var result = (aRot + bRot) % 360;
     return ConvertClockwiseDegreesToSimpleOrientation(result);
 }
 private static SimpleOrientation MirrorOrientation(SimpleOrientation orientation)
 {
     // This only affects the 90 and 270 degree cases, because rotating 0 and 180 degrees is the same clockwise and counter-clockwise
     switch (orientation)
     {
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             return SimpleOrientation.Rotated270DegreesCounterclockwise;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             return SimpleOrientation.Rotated90DegreesCounterclockwise;
     }
     return orientation;
 }
Пример #32
0
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();

            var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
            // Fall back to the local app storage if the Pictures Library is not available
            _captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
        }
Пример #33
0
        private SimpleOrientation GetCameraOrientation(DisplayInformation displayInformation, SimpleOrientation deviceOrientation)
        {
            var result = deviceOrientation;

            if (displayInformation.NativeOrientation == DisplayOrientations.Portrait)
            {
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    result = SimpleOrientation.NotRotated;
                    break;

                case SimpleOrientation.Rotated180DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated90DegreesCounterclockwise;
                    break;

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    result = SimpleOrientation.Rotated180DegreesCounterclockwise;
                    break;

                case SimpleOrientation.NotRotated:
                    result = SimpleOrientation.Rotated270DegreesCounterclockwise;
                    break;
                }
            }

            if (_mirroringPreview)
            {
                switch (result)
                {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated270DegreesCounterclockwise);

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    return(SimpleOrientation.Rotated90DegreesCounterclockwise);
                }
            }

            return(result);
        }
 /// <summary>
 /// Converts the given orientation of the device in space to the corresponding rotation in degrees
 /// </summary>
 /// <param name="orientation">The orientation of the device in space</param>
 /// <returns>An orientation in degrees</returns>
 private static int ConvertDeviceOrientationToDegrees(SimpleOrientation orientation)
 {
     switch (orientation)
     {
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             return 90;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             return 180;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             return 270;
         case SimpleOrientation.NotRotated:
         default:
             return 0;
     }
 }
Пример #35
0
        private static SimpleOrientation ToSimpleOrientation(double gravityX, double gravityY, double gravityZ, SimpleOrientation previous)
        {
            // Ensures orientation only changes when within close range to new orientation.
            if (Math.Abs(gravityX) > Math.Abs(gravityY) + _threshold && Math.Abs(gravityX) > Math.Abs(gravityZ) + _threshold)
            {
                if (gravityX > 0)
                {
                    return(SimpleOrientation.Rotated270DegreesCounterclockwise);
                }

                return(SimpleOrientation.Rotated90DegreesCounterclockwise);
            }
            else if (Math.Abs(gravityY) > Math.Abs(gravityX) + _threshold && Math.Abs(gravityY) > Math.Abs(gravityZ) + _threshold)
            {
                if (gravityY >= 0)
                {
                    return(SimpleOrientation.Rotated180DegreesCounterclockwise);
                }

                return(SimpleOrientation.NotRotated);
            }
            else if (Math.Abs(gravityZ) > Math.Abs(gravityY) + _threshold && Math.Abs(gravityZ) > Math.Abs(gravityX) + _threshold)
            {
                if (gravityZ >= 0)
                {
                    return(SimpleOrientation.Facedown);
                }
                return(SimpleOrientation.Faceup);
            }
            return(previous);
        }
Пример #36
0
        /// <summary>
        /// Event handler for orientation sensor changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
            {
                _deviceOrientation = args.Orientation;
            }

            // Update the UI button orientation
            UpdateButtonOrientation();
        }
Пример #37
0
 private static PhotoOrientation ConvertOrientationToPhotoOrientation(SimpleOrientation orientation)
 {
     return(PhotoOrientation.Rotate90);
 }
        private void RegisterOrientationEventHandlers()
        {
            if (_orientationSensor != null)
            {
                _orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged;
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            _displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;
            _displayOrientation = _displayInformation.CurrentOrientation;
        }
Пример #39
0
        private async void Application_Resuming(object sender, object o)
        {
            if (orientationSensor != null)
            {
                deviceOrientation = orientationSensor.GetCurrentOrientation();
            }

            if (Frame.CurrentSourcePageType == typeof(CameraView))
            {
                await InitializeCameraAsync();
            }

            RegisterEventHandlers();
        }
 private static string PrintOrientation(string text, SimpleOrientation currentOrientation)
 {
     return(string.Format("\r\n[{2}] {1} orientation: {0}", currentOrientation,
                          DateTime.Now.ToString("HH:mm:ss.ttt"),
                          text));
 }
 void SetSimpleOrientationText(SimpleOrientation simpleOrientation)
 {
     this.simpleOrientation.Text = simpleOrientation.ToString();
 }
 private void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         _deviceOrientation = args.Orientation;
     }
 }
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();
        }
Пример #44
0
 void SetOrientationSensorText(SimpleOrientation simpleOrientation)
 {
     orientationSensorTextBlock.Text = simpleOrientation.ToString();
 }
 private static VideoRotation ConvertSimpleOrientationToVideoRotation(SimpleOrientation orientation)
 {
     switch (orientation)
     {
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             return VideoRotation.Clockwise270Degrees;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             return VideoRotation.Clockwise180Degrees;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             return VideoRotation.Clockwise90Degrees;
         case SimpleOrientation.NotRotated:
         default:
             return VideoRotation.None;
     }
 }
Пример #46
0
 private async void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     SimpleOrientation orientation = args.Orientation;
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         // Switch the placement of the buttons based on an orientation change.
         if (SimpleOrientation.NotRotated == orientation)
         {
             //Grid.SetRow(buttonList, 1);
             //Grid.SetColumn(buttonList, 0);
             this._btnMC.Width     = 86;
             this._btnMR.Width     = 86;
             this._btnMMas.Width   = 86;
             this._btnMMenos.Width = 86;
             this._btnMS.Width     = 86;
             this._btnSin.Width    = 0;
             this._btnCos.Width    = 0;
             this._btnTan.Width    = 0;
             this._btnLog.Width    = 0;
             this._btnIn.Width     = 0;
             Grid.SetColumn(_btnPorc, 0);
             Grid.SetRow(_btnPorc, 0);
             this._btnPorc.Width  = 86;
             this._btnPorc.Height = 76;
             Grid.SetColumn(_btnRoot, 1);
             Grid.SetRow(_btnRoot, 0);
             Grid.SetColumn(_btnSquare, 2);
             Grid.SetRow(_btnSquare, 0);
             Grid.SetColumn(_btnByX, 3);
             Grid.SetRow(_btnByX, 0);
             Grid.SetColumn(_numSeven, 0);
             Grid.SetColumn(_numEight, 1);
             Grid.SetColumn(_numNine, 2);
             Grid.SetColumn(_numFour, 0);
             Grid.SetColumn(_numFive, 1);
             Grid.SetColumn(_numSix, 2);
             Grid.SetColumn(_numOne, 0);
             Grid.SetColumn(_numTwo, 1);
             Grid.SetColumn(_numThree, 2);
             Grid.SetColumn(_numZero, 1);
             Grid.SetRowSpan(_numZero, 1);
             Grid.SetColumn(_btnDot, 2);
             Grid.SetColumn(_btnCE, 0);
             Grid.SetRow(_btnCE, 1);
             this._btnCE.Width  = 86;
             this._btnCE.Height = 76;
             Grid.SetColumn(_btnC, 1);
             Grid.SetRow(_btnC, 1);
             Grid.SetColumn(_btnDEL, 2);
             Grid.SetRow(_btnDEL, 1);
             Grid.SetColumn(_btnNeg, 0);
             Grid.SetRow(_btnNeg, 5);
             Grid.SetColumn(_btnEquals, 3);
             Grid.SetRow(_btnEquals, 5);
             this._btnEquals.Width  = Double.NaN;
             this._btnEquals.Height = Double.NaN;
             Grid.SetColumn(_btnDiv, 3);
             Grid.SetRow(_btnDiv, 1);
             Grid.SetColumn(_btnMult, 3);
             Grid.SetRow(_btnMult, 2);
             Grid.SetColumn(_btnMinus, 3);
             Grid.SetRow(_btnMinus, 3);
             Grid.SetColumn(_btnPlus, 3);
             Grid.SetRow(_btnPlus, 4);
             this._btnPlus.Width  = Double.NaN;
             this._btnPlus.Height = Double.NaN;
         }
         // If not in portrait, move buttonList content to visible row and column.
         else
         {
             //Grid.SetRow(buttonList, 0);
             //Grid.SetColumn(buttonList, 1);
             this._btnMC.Width     = 0;
             this._btnMR.Width     = 0;
             this._btnMMas.Width   = 0;
             this._btnMMenos.Width = 0;
             this._btnMS.Width     = 0;
             this._btnSin.Width    = 86;
             this._btnCos.Width    = 86;
             this._btnTan.Width    = 86;
             this._btnLog.Width    = 86;
             this._btnIn.Width     = 86;
             Grid.SetColumn(_btnPorc, 0);
             Grid.SetRow(_btnPorc, 5);
             this._btnPorc.Width  = Double.NaN;
             this._btnPorc.Height = Double.NaN;
             Grid.SetColumn(_btnRoot, 0);
             Grid.SetRow(_btnRoot, 4);
             Grid.SetColumn(_btnSquare, 0);
             Grid.SetRow(_btnSquare, 3);
             Grid.SetColumn(_btnByX, 0);
             Grid.SetRow(_btnByX, 2);
             Grid.SetColumn(_numSeven, 1);
             Grid.SetColumn(_numEight, 2);
             Grid.SetColumn(_numNine, 3);
             Grid.SetColumn(_numFour, 1);
             Grid.SetColumn(_numFive, 2);
             Grid.SetColumn(_numSix, 3);
             Grid.SetColumn(_numOne, 1);
             Grid.SetColumn(_numTwo, 2);
             Grid.SetColumn(_numThree, 3);
             Grid.SetColumn(_numZero, 2);
             Grid.SetRowSpan(_numZero, 2);
             Grid.SetColumn(_btnDot, 3);
             Grid.SetColumn(_btnC, 5);
             Grid.SetRow(_btnC, 2);
             Grid.SetColumn(_btnCE, 5);
             Grid.SetRow(_btnCE, 3);
             this._btnCE.Width  = Double.NaN;
             this._btnCE.Height = Double.NaN;
             Grid.SetColumn(_btnDEL, 5);
             Grid.SetRow(_btnDEL, 4);
             Grid.SetColumn(_btnNeg, 1);
             Grid.SetRow(_btnNeg, 5);
             Grid.SetColumn(_btnEquals, 5);
             Grid.SetRow(_btnEquals, 5);
             this._btnEquals.Width  = Double.NaN;
             this._btnEquals.Height = Double.NaN;
             Grid.SetColumn(_btnDiv, 4);
             Grid.SetRow(_btnDiv, 2);
             Grid.SetColumn(_btnMult, 4);
             Grid.SetRow(_btnMult, 3);
             Grid.SetColumn(_btnMinus, 4);
             Grid.SetRow(_btnMinus, 4);
             Grid.SetColumn(_btnPlus, 4);
             Grid.SetRow(_btnPlus, 5);
             this._btnPlus.Width  = 95;
             this._btnPlus.Height = Double.NaN;
         }
     });
 }
Пример #47
0
        private object ConvertOrientationToPhotoOrientation(SimpleOrientation orientation)
        {
            //     if (_mirroringPreview == true)
            //      {
            switch (orientation)
            {
                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    return PhotoOrientation.Rotate90;
                case SimpleOrientation.Rotated180DegreesCounterclockwise:
                    return PhotoOrientation.Rotate180;
                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    return PhotoOrientation.Rotate270;
                case SimpleOrientation.NotRotated:
                default:
                    return PhotoOrientation.Normal;
            }
            //        }
            //else
            //{
            //    switch (orientation)
            //    {
            //        case SimpleOrientation.Rotated90DegreesCounterclockwise:
            //            return PhotoOrientation.Rotate90;
            //        case SimpleOrientation.Rotated180DegreesCounterclockwise:
            //            return PhotoOrientation.Rotate180;
            //        case SimpleOrientation.Rotated270DegreesCounterclockwise:
            //            return PhotoOrientation.Rotate270;
            //        case SimpleOrientation.NotRotated:
            //        default:
            //            return PhotoOrientation.Normal;
            //    }
            //}

        }
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Attempt to lock page to landscape orientation to prevent the CaptureElement from rotating, as this gives a better experience
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }
            
            RegisterEventHandlers();

            var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
            // Fall back to the local app storage if the Pictures Library is not available
            _captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
        }
        /// <summary>
        /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors
        /// </summary>
        /// <returns></returns>
        private async Task SetupUiAsync()
        {
            // Attempt to lock page to landscape orientation to prevent the CaptureElement from rotating, as this gives a better experience
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            // Hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }

            // Populate orientation variables with the current state
            _displayOrientation = _displayInformation.CurrentOrientation;
            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
            }

            RegisterEventHandlers();
        }
Пример #50
0
 internal SimpleTelemetry(int x, int y, SimpleOrientation o)
 {
     this.X           = x;
     this.Y           = y;
     this.Orientation = o;
 }
 /// <summary>
 /// Converts the given orientation of the device in space to the metadata that can be added to captured photos
 /// </summary>
 /// <param name="orientation">The orientation of the device in space</param>
 /// <returns></returns>
 private static PhotoOrientation ConvertOrientationToPhotoOrientation(SimpleOrientation orientation)
 {
     switch (orientation)
     {
         case SimpleOrientation.Rotated90DegreesCounterclockwise:
             return PhotoOrientation.Rotate90;
         case SimpleOrientation.Rotated180DegreesCounterclockwise:
             return PhotoOrientation.Rotate180;
         case SimpleOrientation.Rotated270DegreesCounterclockwise:
             return PhotoOrientation.Rotate270;
         case SimpleOrientation.NotRotated:
         default:
             return PhotoOrientation.Normal;
     }
 }
Пример #52
0
        /// <summary>
        /// Registers event handlers for orientation sensors and hardware buttons.
        /// </summary>
        private void RegisterEventHandlers()
        {
            // If there is a hardware camera button, register for that event
            if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
            }

            // If there is an orientation sensor present on the device, register for notifications
            if (_orientationSensor != null)
            {
                _orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged;
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();

                // Update the orientation of the capture button
                UpdateButtonOrientation();
            }

            // TODO: This may be removed if not needed.
            // _displayOrientation = _displayInformation.CurrentOrientation;

            _displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;
            _systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;
        }