예제 #1
0
            /**
             * The Orientation changed event handler.
             * Currently it contains the functionality for the orientation changed event.
             * @param from Object the object that triggers the event.
             * @param args Microsoft.Phone.Controls.OrientationChangedEventArgs the event arguments.
             */
            public void OrientationChangedHandler(object from, Microsoft.Phone.Controls.OrientationChangedEventArgs args)
            {
                PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);

                // change the current page in regard to the current orientaion.
                if (args.Orientation == PageOrientation.Landscape |
                    args.Orientation == PageOrientation.LandscapeLeft |
                    args.Orientation == PageOrientation.LandscapeRight)
                {
                    currentPage.Height = Application.Current.Host.Content.ActualWidth;
                    currentPage.Width  = Application.Current.Host.Content.ActualHeight;
                }
                else if (args.Orientation == PageOrientation.Portrait |
                         args.Orientation == PageOrientation.PortraitDown |
                         args.Orientation == PageOrientation.PortraitUp)
                {
                    currentPage.Height = Application.Current.Host.Content.ActualHeight;
                    currentPage.Width  = Application.Current.Host.Content.ActualWidth;
                }

                // send the event to the mosync runtime.
                Memory    eventData = new Memory(8);
                const int MAWidgetEventData_eventType    = 0;
                const int MAWidgetEventData_widgetHandle = 4;

                eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_SCREEN_ORIENTATION_DID_CHANGE);
                eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
            }
예제 #2
0
            /**
             * The Orientation changed event handler.
             * Currently it contains the functionality for the orientation changed event.
             * @param from Object the object that triggers the event.
             * @param args Microsoft.Phone.Controls.OrientationChangedEventArgs the event arguments.
             */
            public void OrientationChangedHandler(object from, Microsoft.Phone.Controls.OrientationChangedEventArgs args)
            {
                PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);

                // change the current page in regard to the current orientation.
                if (args.Orientation == PageOrientation.Landscape |
                    args.Orientation == PageOrientation.LandscapeLeft |
                    args.Orientation == PageOrientation.LandscapeRight)
                {
                    currentPage.Height = Application.Current.Host.Content.ActualWidth;
                    currentPage.Width  = Application.Current.Host.Content.ActualHeight;
                }
                else if (args.Orientation == PageOrientation.Portrait |
                         args.Orientation == PageOrientation.PortraitDown |
                         args.Orientation == PageOrientation.PortraitUp)
                {
                    currentPage.Height = Application.Current.Host.Content.ActualHeight;
                    currentPage.Width  = Application.Current.Host.Content.ActualWidth;
                }

                int mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;

                switch (currentPage.Orientation)
                {
                case PageOrientation.Landscape:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE;
                    break;

                case PageOrientation.LandscapeLeft:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE_LEFT;
                    break;

                case PageOrientation.LandscapeRight:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE_RIGHT;
                    break;

                case PageOrientation.Portrait:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;
                    break;

                case PageOrientation.PortraitDown:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UPSIDE_DOWN;
                    break;

                case PageOrientation.PortraitUp:
                    mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;
                    break;
                }

                // Post events handled by the NativeUI library.
                postScreenOrientationEvent(mosyncScreenOrientation, mHandle);
            }
예제 #3
0
 protected override void OnOrientationChanged(Microsoft.Phone.Controls.OrientationChangedEventArgs e)
 {
     if (e.Orientation == PageOrientation.Landscape || e.Orientation == PageOrientation.LandscapeLeft || e.Orientation == PageOrientation.LandscapeRight)
     {
         LayoutRoot.RowDefinitions[0].Height = new GridLength(2.5, GridUnitType.Star);
         LayoutRoot.RowDefinitions[1].Height = new GridLength(7.5, GridUnitType.Star);
     }
     else
     {
         LayoutRoot.RowDefinitions[0].Height = new GridLength(2, GridUnitType.Star);
         LayoutRoot.RowDefinitions[1].Height = new GridLength(8, GridUnitType.Star);
     }
     base.OnOrientationChanged(e);
 }
예제 #4
0
 /**
  * The Orientation changed event handler
  * Currently it contains the functionality for the orientation changed event.
  * @param from Object the object that triggers the event
  * @param args Microsoft.Phone.Controls.OrientationChangedEventArgs the event arguments
  */
 public void OrientationChangedHandler(object from, Microsoft.Phone.Controls.OrientationChangedEventArgs args)
 {
     // We dont need to change the background canvas width/height because they're automatically
     // redimensioned when the mDialogView child changes it's shape.
     if (args.Orientation == PageOrientation.Landscape || args.Orientation == PageOrientation.LandscapeLeft ||
         args.Orientation == PageOrientation.LandscapeRight)
     {
         mDialogView.Width  = Application.Current.Host.Content.ActualHeight - 2 * marginDistance;
         mDialogView.Height = Application.Current.Host.Content.ActualWidth - marginDistance;
     }
     else
     {
         mDialogView.Width  = Application.Current.Host.Content.ActualWidth - 2 * marginDistance;
         mDialogView.Height = Application.Current.Host.Content.ActualHeight - marginDistance;
     }
 }
예제 #5
0
 protected override void OnOrientationChanged(Microsoft.Phone.Controls.OrientationChangedEventArgs e)
 {
     base.OnOrientationChanged(e);
     if (e.Orientation == PageOrientation.LandscapeLeft)
     {
         ContentLayout.Margin = new Thickness(72, 24, 24, 0);
     }
     else if (e.Orientation == PageOrientation.LandscapeRight)
     {
         ContentLayout.Margin = new Thickness(72, 24, 24, 0);
     }
     else if (e.Orientation == PageOrientation.PortraitUp)
     {
         ContentLayout.Margin = new Thickness(0, 32, 0, 0);
     }
 }
예제 #6
0
        protected override void OnOrientationChanged(Microsoft.Phone.Controls.OrientationChangedEventArgs e)
        {
            if (cam != null)
            {
                viewfinderBrush.RelativeTransform = CameraHelpers.GetCameraTransformByOrientation(cam.CameraType, Orientation);
            }
            if (Orientation == PageOrientation.LandscapeRight || Orientation == PageOrientation.LandscapeLeft)
            {
                var ratio = _cameraHeight / _cameraWidth;
                cameraGrid.Width  = ratio * _phoneHeight;
                cameraGrid.Height = _phoneWidth;
            }
            else if (Orientation == PageOrientation.PortraitUp)
            {
                var ratio = _cameraHeight / _cameraWidth;
                cameraGrid.Width  = _phoneWidth;
                cameraGrid.Height = ratio * _phoneHeight;
            }

            base.OnOrientationChanged(e);
        }