public static DeviceOrientationDifference ComputeOrientationDifference(DeviceOrientations referenceDeviceOrientation, DeviceOrientations targetDeviceOrientation) { Int32 orientationCount = Enum.GetNames(typeof(DeviceOrientations)).Length; byte difference = ( byte )((( int )targetDeviceOrientation + orientationCount - ( int )referenceDeviceOrientation) % orientationCount); DeviceOrientationDifference result = ( DeviceOrientationDifference )difference; return(result); }
private void SetDeviceOrientation(DeviceOrientations orientation) { DispatchQueue.MainQueue.DispatchAsync(() => { UIDevice.CurrentDevice.SetValueForKey( NSObject.FromObject(Convert(orientation)), new NSString("orientation")); UIViewController.AttemptRotationToDeviceOrientation(); }); }
private void CreateGrid(DeviceOrientations orientation) { if (orientation == DeviceOrientations.Portrait) { CreatePortraitOrientation(); } else { CreateLandscapeOrientation(); } }
private DeviceOrientations GetOrientationByAngle(int angle, DeviceOrientations currentDeviceOrientations) { var axe1 = _axes[0]; var axe2 = _axes[1]; var axe3 = _axes[2]; var axe4 = _axes[3]; switch (currentDeviceOrientations) { case DeviceOrientations.Up: axe1 += Deviation; axe4 -= Deviation; break; case DeviceOrientations.Down: axe2 -= Deviation; axe3 += Deviation; break; case DeviceOrientations.Right: axe1 -= Deviation; axe2 += Deviation; break; case DeviceOrientations.Left: axe3 -= Deviation; axe4 += Deviation; break; } if (angle >= axe4 && angle <= axe1) { return(DeviceOrientations.Up); } if (angle > axe1 && angle <= axe2) { return(DeviceOrientations.Right); } if (angle > axe2 && angle < axe3) { return(DeviceOrientations.Down); } if (angle >= axe3 && angle < axe4) { return(DeviceOrientations.Left); } return(DeviceOrientations.Up); }
public override void LockOrientation(DeviceOrientations orientation, DeviceOrientations startingOrientation = default(DeviceOrientations)) { _lockedOrientation = orientation; if (startingOrientation != default(DeviceOrientations) && startingOrientation != orientation) { SetDeviceOrientation(startingOrientation); } else { SetDeviceOrientation(orientation); } }
public override void OnOrientationChanged(int rotationDegrees) { var currentOrientation = CrossDeviceOrientation.Current.CurrentOrientation; if (currentOrientation != _cachedOrientation) { _cachedOrientation = currentOrientation; _onOrientationChanged(new OrientationChangedEventArgs { Orientation = currentOrientation }); } }
public override void SetCameraScreenPosition(CameraScreen screen, DeviceOrientations orientation) { float heightOffset; if (orientation == DeviceOrientations.Landscape) { Columns = 3; heightOffset = 0; } else { Columns = 2; heightOffset = 1.25f; } min = 0; // Prevent the camera from being zoomed when in grid view if (Camera.Zoom > 1) { Camera.Zoom = 1; } if (Camera.Node.Position.X != 0 || Camera.Node.Position.Y > 0) { Camera.Node.SetPosition2D(new Vector2(0, 0)); } float margin = 5; // Calculate the distance where the camera screen width is half the width of the frustrum float distance = (float)DataOperations.GetDistanceForFrustrumWidth(screen.Width * Columns + margin, Camera.AspectRatio, Camera.Fov); float halfHeight = distance * Camera.HalfViewSize; float halfWidth = halfHeight * Camera.AspectRatio; cellHeight = screen.Height > cellHeight ? screen.Height : cellHeight; float screenPosition = Math.Abs(((screen.position - 1) % Columns) - (Columns - 1)); float x = -halfWidth + (((Columns - 1) - screenPosition)) * halfWidth * 2 / Columns + halfWidth / Columns; float y = halfHeight - screen.Height / 2 - (float)Math.Floor((double)(screen.position - 1) / (float)Columns) * (cellHeight + margin / 2) - margin / 2; newMin = y + screen.Height * heightOffset; min = newMin < min ? newMin : min; // We need a small offset or the will not be seen by the camera screen.Node.SetWorldPosition(new Vector3(x, y, distance)); }
private void SystemEvents_DisplaySettingsChanged(Object sender, EventArgs e) { if (IsMonitoring) { DeviceOrientations previousDeviceOrientation = CurrentDeviceOrientation; DeviceOrientations currentDeviceOrientation = GetDeviceOrientation(DisplayProperties.CurrentOrientation); CurrentDeviceOrientation = currentDeviceOrientation; if (previousDeviceOrientation != currentDeviceOrientation && DeviceOrientationChanged != null) { DeviceOrientationChanged.Invoke(this, new DeviceOrientationChangedEventArgs(previousDeviceOrientation, currentDeviceOrientation)); } } }
public static ScreenOrientations GetScreenOrientation(DeviceOrientations orientation) { ScreenOrientations result; if (orientation == DeviceOrientations.Landscape_Reversed || orientation == DeviceOrientations.Landscape_Upright) { result = ScreenOrientations.Landscape; } else // if( orientation == DeviceOrientations.Portrait_Reversed || orientation == DeviceOrientations.Portrait_Upright ) { result = ScreenOrientations.Portrait; } return(result); }
private void CambiaOrientacion() { IDeviceOrientation _deviceOrientationSvc = DependencyService.Get <IDeviceOrientation>(); DeviceOrientations dvcor = _deviceOrientationSvc.GetOrientation(); if (dvcor == DeviceOrientations.Landscape) //apaisado { wv.HeightRequest = 300; wv.WidthRequest = 300; } else //portrait { wv.HeightRequest = 400; wv.WidthRequest = 300; } }
private void IntializeSettings() { this.BindingContext = App.ViewModel; //displayNameEntry.Text = "Mahdi"; //bioEditor.Text = "Scott has been developing Microsoft Enterprise solutions for organizations around the world for the last 28 years, and the Senior Architect & Developer behind Liquid Daffodil"; //profileImage.Source = "https://wintellectnow.blob.core.windows.net/public/Scott_Peterson.jpg"; articleCountSlider.Value = 15; categoryPicker.SelectedIndex = 1; string label = GeneralHelper.GetLabel(); string extendedLablel = GeneralHelper.GetLabel("Running on: ", true); DeviceOrientations orientation = GeneralHelper.GetOrientation(); App.ViewModel.PlatformLabel = label; App.ViewModel.ExtendedPlatformLabel = extendedLablel; App.ViewModel.CurrentOrientation = orientation; }
private DeviceOrientations Reverse(DeviceOrientations orientation) { switch (orientation) { case DeviceOrientations.Portrait: case DeviceOrientations.PortraitFlipped: return(DeviceOrientations.Portrait); case DeviceOrientations.Landscape: return(DeviceOrientations.LandscapeFlipped); case DeviceOrientations.LandscapeFlipped: return(DeviceOrientations.Landscape); default: return(DeviceOrientations.Undefined); } }
private UIInterfaceOrientation Convert(DeviceOrientations orientation) { switch (orientation) { case DeviceOrientations.Portrait: return(UIInterfaceOrientation.Portrait); case DeviceOrientations.PortraitFlipped: return(UIInterfaceOrientation.PortraitUpsideDown); case DeviceOrientations.LandscapeFlipped: return(UIInterfaceOrientation.LandscapeRight); case DeviceOrientations.Landscape: return(UIInterfaceOrientation.LandscapeLeft); default: return(UIInterfaceOrientation.Unknown); } }
private ScreenOrientation Convert(DeviceOrientations orientation) { switch (orientation) { case DeviceOrientations.Portrait: return(ScreenOrientation.Portrait); case DeviceOrientations.PortraitFlipped: return(ScreenOrientation.ReversePortrait); case DeviceOrientations.Landscape: return(ScreenOrientation.Landscape); case DeviceOrientations.LandscapeFlipped: return(ScreenOrientation.ReverseLandscape); default: return(ScreenOrientation.Unspecified); } }
private static UIInterfaceOrientationMask ConvertToMask(DeviceOrientations orientation) { switch (orientation) { case DeviceOrientations.Portrait: return(UIInterfaceOrientationMask.Portrait); case DeviceOrientations.PortraitFlipped: return(UIInterfaceOrientationMask.PortraitUpsideDown); case DeviceOrientations.LandscapeFlipped: return(UIInterfaceOrientationMask.LandscapeRight); case DeviceOrientations.Landscape: return(UIInterfaceOrientationMask.LandscapeLeft); default: return(UIInterfaceOrientationMask.AllButUpsideDown); } }
private void CambiaOrientacion() { IDeviceOrientation _deviceOrientationSvc = DependencyService.Get <IDeviceOrientation>(); DeviceOrientations dvcor = _deviceOrientationSvc.GetOrientation(); if (dvcor == DeviceOrientations.Landscape) //if (width > height) //apaisado { grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) }); grdMain.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Star) }); grdMain.Children.Add(_calendarView, 0, 0); grdMain.Children.Add(lvFechas, 1, 0); } else //portrait { grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); grdMain.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) } ); Enumerable.Range(1, 2).ToList().ForEach(x => grdMain.RowDefinitions.Add( new RowDefinition { Height = new GridLength(40, GridUnitType.Star) } )); grdMain.Children.Add(_calendarView, 0, 0); grdMain.Children.Add(lvFechas, 0, 1); } }
/// <summary> /// Updates the Urho application in case there is an orientation change /// </summary> /// <param name="width">width of the screen</param> /// <param name="height">height of the screen</param> protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); // If the width is greater than the height the device is in landscape mode, // otherwise it is in portrait if (width > height) { orientation = DeviceOrientations.Landscape; } else { orientation = DeviceOrientations.Portrait; } // Only update the application if it has been created if (application != null) { application.Orientation = orientation; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(CarouselView.FormsPlugin.Abstractions.CarouselViewOrientation.Horizontal); } DeviceOrientations screenOrientation = (DeviceOrientations)value; switch (screenOrientation) { case DeviceOrientations.Undefined: return(CarouselView.FormsPlugin.Abstractions.CarouselViewOrientation.Horizontal); case DeviceOrientations.Landscape: return(CarouselView.FormsPlugin.Abstractions.CarouselViewOrientation.Vertical); case DeviceOrientations.Portrait: return(CarouselView.FormsPlugin.Abstractions.CarouselViewOrientation.Horizontal); } return(CarouselView.FormsPlugin.Abstractions.CarouselViewOrientation.Horizontal); }
protected override void OnOrientationChanged(DeviceOrientations orientation) { base.OnOrientationChanged(orientation); this.ChangeLayout(); }
public abstract void SetCameraScreenPosition(CameraScreen screen, DeviceOrientations orientation);
protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); if (width != this.width || height != this.height) { this.width = width; this.height = height; IDeviceOrientation _deviceOrientationSvc = DependencyService.Get <IDeviceOrientation>(); DeviceOrientations dvcor = _deviceOrientationSvc.GetOrientation(); if (dvcor == DeviceOrientations.Landscape) //if (width > height) //apaisado { grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); Enumerable.Range(1, 3).ToList().ForEach(x => grdMain.RowDefinitions.Add( new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } )); Enumerable.Range(1, 4).ToList().ForEach(x => grdMain.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(25, GridUnitType.Star) } )); //grdMain.Children.Clear(); grdMain.Children.Add(srcBuscar, 0, 0 + 4, 0, 0 + 1); grdMain.Children.Add(btnNombre, 0, 0 + 3, 1, 1 + 1); grdMain.Children.Add(txtNum, 3, 3 + 1, 1, 1 + 1); grdMain.Children.Add(btnPais, 0, 2); grdMain.Children.Add(btnOper, 1, 2); grdMain.Children.Add(btnMonto, 2, 2); grdMain.Children.Add(btnPago, 3, 2); grdSecondary.ColumnDefinitions.Clear(); grdSecondary.RowDefinitions.Clear(); grdSecondary.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(55, GridUnitType.Star) }); Enumerable.Range(1, 3).ToList().ForEach(x => grdSecondary.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(55, GridUnitType.Star) } )); grdSecondary.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grdSecondary.Children.Add(btnNombreMin, 0, 0); grdSecondary.Children.Add(btnPaisMin, 1, 0); grdSecondary.Children.Add(btnOperMin, 2, 0); grdSecondary.Children.Add(btnMontoMin, 3, 0); } else //portrait { grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); Enumerable.Range(1, 7).ToList().ForEach(x => grdMain.RowDefinitions.Add( new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } )); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); //grdMain.Children.Clear(); grdMain.Children.Add(srcBuscar, 0, 0); grdMain.Children.Add(btnNombre, 0, 1); grdMain.Children.Add(txtNum, 0, 2); grdMain.Children.Add(btnPais, 0, 3); grdMain.Children.Add(btnOper, 0, 4); grdMain.Children.Add(btnMonto, 0, 5); grdMain.Children.Add(btnPago, 0, 6); grdSecondary.ColumnDefinitions.Clear(); grdSecondary.RowDefinitions.Clear(); Enumerable.Range(1, 3).ToList().ForEach(x => grdSecondary.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(33, GridUnitType.Star) } )); Enumerable.Range(1, 2).ToList().ForEach(x => grdSecondary.RowDefinitions.Add( new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } )); grdSecondary.Children.Add(btnNombreMin, 0, 0 + 3, 0, 0 + 1); grdSecondary.Children.Add(btnPaisMin, 0, 1); grdSecondary.Children.Add(btnOperMin, 1, 1); grdSecondary.Children.Add(btnMontoMin, 2, 1); } } }
private void HandleOrientationMessage(DeviceOrientations orientation) { myLabel.Text = orientation.ToString(); myLabel.TextColor = orientation.ToString() == "Landscape" ? Color.Fuchsia : Color.Green; }
public override void LockOrientation(DeviceOrientations orientation) { var activity = CrossCurrentActivity.Current.Activity; activity.RequestedOrientation = Convert(orientation); }
private void CambiaOrientacion() { IDeviceOrientation _deviceOrientationSvc = DependencyService.Get <IDeviceOrientation>(); DeviceOrientations dvcor = _deviceOrientationSvc.GetOrientation(); if (dvcor == DeviceOrientations.Landscape) //apaisado { //BackgroundImage = "backfoto2.jpg"; grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); Enumerable.Range(1, 3).ToList().ForEach(x => grdMain.RowDefinitions.Add( new RowDefinition { Height = new GridLength(40, GridUnitType.Absolute) } )); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdMain.Children.Add(btnFace, 1, 0); grdMain.Children.Add(btnGoogle, 3, 0); grdMain.Children.Add(btnReg, 1, 1); grdMain.Children.Add(btnLogin, 3, 1); grdLogin.ColumnDefinitions.Clear(); grdLogin.RowDefinitions.Clear(); Enumerable.Range(1, 3).ToList().ForEach(x => grdLogin.RowDefinitions.Add( new RowDefinition { Height = new GridLength(40, GridUnitType.Absolute) } )); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdLogin.Children.Add(edtCorreo, 1, 0); grdLogin.Children.Add(nipCapture, 3, 0); grdLogin.Children.Add(btnEntrar, 1, 1); grdLogin.Children.Add(btnCancelar, 3, 1); } else //portrait { //BackgroundImage = "backfoto1.jpg"; grdMain.ColumnDefinitions.Clear(); grdMain.RowDefinitions.Clear(); Enumerable.Range(1, 3).ToList().ForEach(x => grdMain.RowDefinitions.Add( new RowDefinition { Height = new GridLength(40, GridUnitType.Absolute) } )); grdMain.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10, GridUnitType.Absolute) }); grdMain.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40, GridUnitType.Absolute) }); grdMain.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10, GridUnitType.Absolute) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(90, GridUnitType.Star) }); grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdMain.Children.Add(btnFace, 1, 0); grdMain.Children.Add(btnGoogle, 1, 1); grdMain.Children.Add(btnReg, 1, 2); grdMain.Children.Add(btnLogin, 1, 4); grdLogin.ColumnDefinitions.Clear(); grdLogin.RowDefinitions.Clear(); Enumerable.Range(1, 4).ToList().ForEach(x => grdLogin.RowDefinitions.Add( new RowDefinition { Height = new GridLength(40, GridUnitType.Absolute) } )); grdLogin.RowDefinitions.Add(new RowDefinition { Height = new GridLength(80, GridUnitType.Absolute) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(90, GridUnitType.Star) }); grdLogin.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); grdLogin.Children.Add(edtCorreo, 1, 0); grdLogin.Children.Add(nipCapture, 1, 1); grdLogin.Children.Add(btnEntrar, 1, 2); grdLogin.Children.Add(btnCancelar, 1, 3); } }
public static Boolean OrientationIsLandscape( DeviceOrientations deviceOrientation ) { return GetScreenOrientation( deviceOrientation ) == ScreenOrientations.Landscape; }
public override void LockOrientation(DeviceOrientations orientation) { _lockedOrientation = orientation; SetDeviceOrientation(orientation); }
public DeviceOrientationChangedEventArgs( DeviceOrientations previousOrientation, DeviceOrientations currentOrientation ) { PreviousDeviceOrientation = previousOrientation; CurrentDeviceOrientation = currentOrientation; }
public static Boolean OrientationIsPortrait( DeviceOrientations deviceOrientation ) { return GetScreenOrientation( deviceOrientation ) == ScreenOrientations.Portrait; }
/// <summary> /// Lock orientation in the specified position /// </summary> /// <param name="orientation">Position for lock.</param> public abstract void LockOrientation(DeviceOrientations orientation);
public void Init(string carNumber, DeviceOrientations deviceOrientation) { IsViewVisible = true; CarNumber = carNumber; DeviceOrientation = deviceOrientation; }
public static ScreenOrientations GetScreenOrientation( DeviceOrientations orientation ) { ScreenOrientations result; if( orientation == DeviceOrientations.Landscape_Reversed || orientation == DeviceOrientations.Landscape_Upright ) result = ScreenOrientations.Landscape; else // if( orientation == DeviceOrientations.Portrait_Reversed || orientation == DeviceOrientations.Portrait_Upright ) result = ScreenOrientations.Portrait; return result; }
public override void LockOrientation(DeviceOrientations orientation, DeviceOrientations startingOrientation = default(DeviceOrientations)) { DisplayInformation.AutoRotationPreferences = (DisplayOrientations)orientation; }
public override void LockOrientation(DeviceOrientations orientation) { DisplayInformation.AutoRotationPreferences = (DisplayOrientations)orientation; }
public override void LockOrientation(DeviceOrientations orientation, DeviceOrientations startingOrientation = default(DeviceOrientations)) { var activity = CrossCurrentActivity.Current.Activity; activity.RequestedOrientation = Convert(orientation); }
public override void UnlockOrientation() { _lockedOrientation = DeviceOrientations.Undefined; SetDeviceOrientation(Reverse(Convert(CurrentDeviceOrientation))); }
public static DeviceOrientationDifference ComputeOrientationDifference( DeviceOrientations referenceDeviceOrientation, DeviceOrientations targetDeviceOrientation ) { Int32 orientationCount = Enum.GetNames( typeof( DeviceOrientations ) ).Length; byte difference = ( byte ) ( ( ( int ) targetDeviceOrientation + orientationCount - ( int ) referenceDeviceOrientation ) % orientationCount ); DeviceOrientationDifference result = ( DeviceOrientationDifference ) difference; return result; }