Ejemplo n.º 1
0
        private async void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                SimpleOrientation orientation = args.Orientation;
                switch (orientation)
                {
                case SimpleOrientation.NotRotated:
                    break;

                case SimpleOrientation.Rotated90DegreesCounterclockwise:
                    break;

                case SimpleOrientation.Rotated180DegreesCounterclockwise:
                    break;

                case SimpleOrientation.Rotated270DegreesCounterclockwise:
                    break;

                case SimpleOrientation.Faceup:
                    break;

                case SimpleOrientation.Facedown:
                    break;

                default:
                    break;
                }
            });
        }
Ejemplo n.º 2
0
 /// <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);
     });
 }
        public static void SensorOrientationChanged(PhoneApplicationPage page, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            LayoutHelper.InvokeFromUiThread(() =>
            {
                if (args.Orientation == SimpleOrientation.Rotated90DegreesCounterclockwise)
                {
                    page.SupportedOrientations = SupportedPageOrientation.Landscape;
                    page.Orientation           = PageOrientation.LandscapeRight;
                    return;
                }
                if (args.Orientation == SimpleOrientation.Rotated270DegreesCounterclockwise)
                {
                    page.SupportedOrientations = SupportedPageOrientation.Landscape;
                    page.Orientation           = PageOrientation.LandscapeLeft;
                    return;
                }

                if (args.Orientation != SimpleOrientation.NotRotated)
                {
                    return;
                }

                page.SupportedOrientations = SupportedPageOrientation.Portrait;
                page.Orientation           = PageOrientation.Portrait;
            });
        }
 async void MainPage_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         TextSimpleOrientation.Text = "SimpleOrientation : " + args.Orientation.ToString();
     });
 }
Ejemplo n.º 5
0
 void OnOrientationSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     // Only update orientation if the device is not parallel to the ground
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         deviceOrientation = args.Orientation;
     }
 }
 // SimpleOrientationSensor handler
 async void OnSimpleOrientationChanged(SimpleOrientationSensor sender,
                                       SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         SetSimpleOrientationText(args.Orientation);
     });
 }
Ejemplo 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;
                }
            });
        }
Ejemplo n.º 8
0
        private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            var now = DateTime.UtcNow.ToUnixTimeMilliseconds();

            var diff = now - lastTime;
            var s    = diff / 1000;
            var ms   = diff % 1000;

            timeSince.Text = $"~{s}.{ms} seconds since last orientation change.";
            lastTime       = now;
        }
Ejemplo n.º 9
0
 private void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     try
     {
         this.UpdateManipulationMode();
         this.GetCanvas().Invalidate();
     }
     catch (Exception)
     {
     }
 }
Ejemplo 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;
            }
        }
Ejemplo n.º 11
0
        void OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            if (_captureManager == null)
            {
                return;
            }

            var orientation = args.Orientation;

            if (orientation == SimpleOrientation.Rotated90DegreesCounterclockwise ||
                orientation == SimpleOrientation.Rotated270DegreesCounterclockwise)
            {
                _captureManager.SetPreviewRotation(VideoRotation.None);
            }
            else
            {
                _captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
            }
        }
Ejemplo n.º 12
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;
                }
            });
        }
Ejemplo n.º 13
0
        private void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                DataTemplate template;
                if ((args.Orientation == SimpleOrientation.Rotated90DegreesCounterclockwise) ||
                    (args.Orientation == SimpleOrientation.Rotated270DegreesCounterclockwise))
                {
                    template = resourceLandscapeTemplate;
                }
                else // otherwise use default template which is "portrait"
                {
                    template = resourcePortraitTemplate;
                }

                lvAlarms.ItemTemplate = template;
            });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Ejemplo n.º 14
0
        private void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            string orientation = string.Empty;

            if (args.Orientation == SimpleOrientation.Rotated270DegreesCounterclockwise || args.Orientation == SimpleOrientation.Rotated90DegreesCounterclockwise)
            {
                orientation = ApplicationViewState.FullScreenPortrait.ToString();
            }
            else
            {
                orientation = ApplicationViewState.FullScreenLandscape.ToString();
            }

            Control control = this._rootFrame.Content as Control;

            if (control != null)
            {
                VisualStateManager.GoToState(control, orientation, false);
            }
        }
Ejemplo n.º 15
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;
         }
     });
 }
Ejemplo n.º 16
0
 private async void Orientation_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     string orientation = GetText(args.Orientation);
     await Dispatcher.RunAsync(
         CoreDispatcherPriority.Normal,
         () => LblOrientation.Text = orientation);
 }
Ejemplo n.º 17
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());
     }
 }
Ejemplo n.º 18
0
 async private void orientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         ShowOrientationText(args.Orientation);
     });
 }
Ejemplo n.º 19
0
        private async void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
            {
                _deviceOrientation = args.Orientation;

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.UpdateButtonOrientation());
            }
        }
Ejemplo n.º 20
0
 private void SimpleOrientationSensorReadingChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     UpdateOrientation(args.Orientation);
 }
Ejemplo n.º 21
0
 private void SimpleOrientationOnOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     _sensorSettings.LatestSimpleOrientationReading = args.Orientation;
 }
Ejemplo n.º 22
0
 private void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         _deviceOrientation = args.Orientation;
     }
 }
        /// <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());
            }
        }
Ejemplo n.º 24
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;
         }
     });
 }
Ejemplo n.º 25
0
        static void orientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
        {
            Log.Write("Orientation Changed: " + args.Orientation);

            switch (args.Orientation)
            {
            //case SimpleOrientation.NotRotated:
            //case SimpleOrientation.Rotated180DegreesCounterclockwise:
            case SimpleOrientation.Rotated270DegreesCounterclockwise:
            case SimpleOrientation.Rotated90DegreesCounterclockwise:
            {
                Execution.ExecuteLandscapeRecipe();
            }
            break;
            }
        }
Ejemplo n.º 26
0
 private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs e)
 {
     this.desiredOrientation = GetCurrentDeviceOrientation();
     UpdateTrayIcon();
 }
Ejemplo n.º 27
0
 private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     RaiseConfigurationChanges();
 }
Ejemplo n.º 28
0
 private void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     VideoPageViewHelper.SensorOrientationChanged(this, args);
 }
Ejemplo n.º 29
0
 private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         HandleOrientationChanged(false);
     }
 }
 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);
     }
 }