Inheritance: ISimpleOrientationSensorOrientationChangedEventArgs
Exemplo n.º 1
0
 async private void orientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         ShowOrientationText(args.Orientation);
     });
 }
Exemplo n.º 2
0
 private void OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (_isStreaming)
     {
         var rotation = GetVideoRotation(args.Orientation);
         _mediaCapture.SetPreviewRotation(rotation);
     }
 }
Exemplo n.º 3
0
 private async void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     // Keep previous orientation when the user puts its device faceup or facedown
     if ((args.Orientation != SimpleOrientation.Faceup) && (args.Orientation != SimpleOrientation.Facedown))
     {
         deviceOrientation = args.Orientation;
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => SetVideoOrientation());
     }
 }
Exemplo n.º 4
0
 private void CalculateCurrentOrientation(SimpleOrientation orientation)
 {
     if (_currentOrientation != orientation)
     {
         _currentOrientation = orientation;
         var args = new SimpleOrientationSensorOrientationChangedEventArgs()
         {
             Orientation = orientation,
             Timestamp   = DateTimeOffset.Now,
         };
         OrientationChanged?.Invoke(this, args);
     }
 }
Exemplo n.º 5
0
 private void SetCurrentOrientation(SimpleOrientation orientation)
 {
     CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, async ct =>
     {
         if (_currentOrientation != orientation)
         {
             _currentOrientation = orientation;
             var args            = new SimpleOrientationSensorOrientationChangedEventArgs()
             {
                 Orientation = orientation,
                 Timestamp   = DateTimeOffset.Now,
             };
             OrientationChanged?.Invoke(this, args);
         }
     });
 }
Exemplo n.º 6
0
 //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;
         }
     });
 }
Exemplo n.º 7
0
 // For orientation Switching
 private async void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e) {
     // Set priority to Camera in order to avoid pulling from other UI elements at its runtime
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
         SimpleOrientation orientation = e.Orientation;
         // Changes Camera Object orientation depending on Phone orientation
         switch (orientation) {
             case SimpleOrientation.NotRotated:
                 //Portrait Up 
                 cameraButton.RenderTransform = new RotateTransform() { Angle = 0 };
                 currentAngle = 0;
                 break;
             case SimpleOrientation.Rotated90DegreesCounterclockwise:
                 //LandscapeLeft 
                 cameraButton.RenderTransform = new RotateTransform() { Angle = 90 };
                 currentAngle = 90;
                 break;
             case SimpleOrientation.Rotated180DegreesCounterclockwise:
                 //PortraitDown 
                 cameraButton.RenderTransform = new RotateTransform() { Angle = 180 };
                 currentAngle = 180;
                 break;
             case SimpleOrientation.Rotated270DegreesCounterclockwise:
                 //LandscapeRight 
                 cameraButton.RenderTransform = new RotateTransform() { Angle = 270 };
                 currentAngle = 270;
                 break;
             case SimpleOrientation.Faceup:
                // txtOrientation.Text = "Faceup";
                 break;
             case SimpleOrientation.Facedown:
                 //txtOrientation.Text = "Facedown";
                 break;
             default:
                 //txtOrientation.Text = "Unknown orientation";
                 break;
         }
     });
 }
 /// <summary>
 /// This is the event handler for OrientationChanged events.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 async private void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         DisplayOrientation(ScenarioOutput_Orientation, e.Orientation);
     });
 }
 async void MainPage_OrientationChanged( SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args )
 {
     await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () =>
     {
         TextSimpleOrientation.Text = "SimpleOrientation : " +  args.Orientation.ToString();
     } );
 }
Exemplo n.º 10
0
        private void OrientationChange(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {

            Settings.orientation = this.orientationSensor.GetCurrentOrientation();
            switch (Settings.orientation)
            {
                case SimpleOrientation.NotRotated: Settings.or = 1; break;
                //case SimpleOrientation.Faceup: Settings.or = 0; break;
                case SimpleOrientation.Rotated180DegreesCounterclockwise: Settings.or = 2; break;
                case SimpleOrientation.Rotated270DegreesCounterclockwise: Settings.or = 3; break;
                case SimpleOrientation.Rotated90DegreesCounterclockwise: Settings.or = 4; break;
            } 
            
        }
Exemplo n.º 11
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;
     }
 }
 private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         // Only raise the OrientationChanged event 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.
         OrientationChanged?.Invoke(this, false);
     }
 }
 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 void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         _deviceOrientation = args.Orientation;
     }
 }
        void app_OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e) {
            displayWidth = -1; displayHeight = -1;
            getDisplayWidth(); getDisplayHeight();
            if (screen.ActualWidth != displayWidth || screen.ActualHeight != displayHeight) {
                dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {

                    switch (e.Orientation) {
                    case SimpleOrientation.NotRotated:
                        sizeChanged(displayWidth, displayHeight);
                        break;
                    case SimpleOrientation.Rotated180DegreesCounterclockwise:
                        sizeChanged(displayWidth, displayHeight);
                        break;
                    case SimpleOrientation.Rotated270DegreesCounterclockwise:
                        sizeChanged(displayWidth, displayHeight);
                        break;
                    default:
                        sizeChanged(displayWidth, displayHeight);
                        break;
                    }
                }).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
            }
        }
        /// <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());
            }
        }
Exemplo n.º 17
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();
        }