void DidRotate(NSNotification notice) { var device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || Popover == null) { return; } if (Orientation.HasValue && IsSameOrientationKind(Orientation.Value, device.Orientation)) { return; } if (!ShouldRotate(device.Orientation)) { return; } var orientation = Orientation; Orientation = device.Orientation; if (orientation == null) { return; } DisplayPopover(hideExisting: true); }
private void OrientationChanged(NSNotification notification) { if (_isInitialized) { switch (UIDevice.CurrentDevice.Orientation) { case UIDeviceOrientation.Portrait: case UIDeviceOrientation.LandscapeLeft: case UIDeviceOrientation.LandscapeRight: if (_previousValidOrientation != UIDevice.CurrentDevice.Orientation) { StopPreview(); SetupCamera(); switch (UIDevice.CurrentDevice.Orientation) { case UIDeviceOrientation.Portrait: _cameraModule.IsPortrait = true; _cameraModule.IsViewInverted = false; break; case UIDeviceOrientation.LandscapeLeft: _cameraModule.IsPortrait = false; _cameraModule.IsViewInverted = false; break; case UIDeviceOrientation.LandscapeRight: _cameraModule.IsPortrait = false; _cameraModule.IsViewInverted = true; break; } if (_cameraModule.IsVisible) { StartPreview(); } _previousValidOrientation = UIDevice.CurrentDevice.Orientation; } break; default: if (!_previousValidOrientation.HasValue) { StopPreview(); _cameraModule.IsPortrait = true; if (_cameraModule.IsVisible) { StartPreview(); } _previousValidOrientation = UIDeviceOrientation.Portrait; } break; } } }
/// <summary> /// Displays the popover. /// </summary> /// <param name="hideFirst"><c>true</c> to hide previous popover; <c>false</c> otherwise.</param> public void DisplayPopover(bool hideFirst = false) { // If no popover to show if (this.Popover == null) { return; } // Get the screen dimensions var screenWidth = UIScreen.MainScreen.Bounds.Width; var screenHeight = UIScreen.MainScreen.Bounds.Height; // Get the base width and height float width = 400; float height = 300; // If no orientation if (this.orientation == null) { // Get the device orientation // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (MediaPickerDelegate.IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation)) { this.orientation = UIDevice.CurrentDevice.Orientation; } else { this.orientation = MediaPickerDelegate.GetDeviceOrientation(this.viewController.InterfaceOrientation); } } // Get the screen size based on orientation float x; float y; if ((this.orientation == UIDeviceOrientation.LandscapeLeft) || (this.orientation == UIDeviceOrientation.LandscapeRight)) { y = (float)(screenWidth / 2) - (height / 2); x = (float)(screenHeight / 2) - (width / 2); } else { x = (float)(screenWidth / 2) - (width / 2); y = (float)(screenHeight / 2) - (height / 2); } // hide the previous popover if (hideFirst && this.Popover.PopoverVisible) { this.Popover.Dismiss(false); } // Show a new popover this.Popover.PresentFromRect(new CGRect(x, y, width, height), this.viewController.View, 0, true); }
public void DisplayPopover(bool hideFirst = false) { if (this.Popover == null) { return; } var swidth = UIScreen.MainScreen.Bounds.Width; var sheight = UIScreen.MainScreen.Bounds.Height; nfloat width = 400; nfloat height = 300; if (this.orientation == null) { if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation)) { this.orientation = UIDevice.CurrentDevice.Orientation; } else { this.orientation = GetDeviceOrientation(this.viewController.InterfaceOrientation); } } nfloat x, y; if (this.orientation == UIDeviceOrientation.LandscapeLeft || this.orientation == UIDeviceOrientation.LandscapeRight) { y = (swidth / 2) - (height / 2); x = (sheight / 2) - (width / 2); } else { x = (swidth / 2) - (width / 2); y = (sheight / 2) - (height / 2); } if (hideFirst && this.Popover.PopoverVisible) { this.Popover.Dismiss(animated: false); } this.Popover.PresentFromRect(new CGRect(x, y, width, height), this.View, 0, animated: true); }
/// <summary> /// Displays the popover. /// </summary> /// <param name="hideFirst">if set to <c>true</c> [hide first].</param> public void DisplayPopover(bool hideFirst = false) { if (Popover == null) { return; } var swidth = UIScreen.MainScreen.Bounds.Width; var sheight = UIScreen.MainScreen.Bounds.Height; float width = 400; float height = 300; if (_orientation == null) { if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation)) { _orientation = UIDevice.CurrentDevice.Orientation; } else { _orientation = GetDeviceOrientation(_viewController.InterfaceOrientation); } } float x, y; if (_orientation == UIDeviceOrientation.LandscapeLeft || _orientation == UIDeviceOrientation.LandscapeRight) { y = (float)(swidth / 2) - (height / 2); x = (float)(sheight / 2) - (width / 2); } else { x = (float)(swidth / 2) - (width / 2); y = (float)(sheight / 2) - (height / 2); } if (hideFirst && Popover.PopoverVisible) { Popover.Dismiss(false); } var rec = new RectangleF(x, y, width, height); Popover.PresentFromRect(rec, View, 0, true); }
internal void DisplayPopover(bool hideExisting = false) { if (Popover == null) { return; } var swidth = UIScreen.MainScreen.Bounds.Width; var sheight = UIScreen.MainScreen.Bounds.Height; nfloat width = 400; nfloat height = 300; if (Orientation == null) { if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation)) { Orientation = UIDevice.CurrentDevice.Orientation; } else { Orientation = GetDeviceOrientation(Controller.InterfaceOrientation); } } nfloat left, top; if (Orientation == UIDeviceOrientation.LandscapeLeft || Orientation == UIDeviceOrientation.LandscapeRight) { top = swidth / 2 - height / 2; left = sheight / 2 - width / 2; } else { left = swidth / 2 - width / 2; top = sheight / 2 - height / 2; } if (hideExisting && Popover.PopoverVisible) { Popover.Dismiss(animated: false); } Popover.PresentFromRect(new CGRect(left, top, width, height), Controller.View, 0, animated: true); }
/// <summary> /// Called when the current device was rotated. /// </summary> /// <param name="notification">The device rotation notification.</param> private void DidRotate(NSNotification notification) { // Get the new device orientation var device = (UIDevice)notification.Object; if (!MediaPickerDelegate.IsValidInterfaceOrientation(device.Orientation) || (this.Popover == null)) { return; } // If new orientation is of the same kind if (this.orientation.HasValue && MediaPickerDelegate.IsSameOrientationKind(this.orientation.Value, device.Orientation)) { return; } // Get whether the view should be rotated if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!this.GetShouldRotate6(device.Orientation)) { return; } } else if (!this.GetShouldRotate(device.Orientation)) { return; } // Get the current orientation var current = this.orientation; this.orientation = device.Orientation; if (current == null) { return; } // Display the new popover this.DisplayPopover(true); }
private void DidRotate(NSNotification notice) { var device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || Popover == null) { return; } if (_Orientation.HasValue && IsSameOrientationKind(_Orientation.Value, device.Orientation)) { return; } if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!GetShouldRotate6(device.Orientation)) { return; } } else if (!GetShouldRotate(device.Orientation)) { return; } var co = _Orientation; _Orientation = device.Orientation; if (co == null) { return; } DisplayPopover(true); }
private void DidRotate(NSNotification notice) { UIDevice device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || this.Popover == null) { return; } if (this.orientation.HasValue && IsSameOrientationKind(this.orientation.Value, device.Orientation)) { return; } if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!this.GetShouldRotate6(device.Orientation)) { return; } } else if (!this.GetShouldRotate(device.Orientation)) { return; } UIDeviceOrientation?co = this.orientation; this.orientation = device.Orientation; if (co == null) { return; } this.DisplayPopover(hideFirst: true); }
void DidRotate(NSNotification notice) { var device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || Popover == null) return; if (orientation.HasValue && IsSameOrientationKind(orientation.Value, device.Orientation)) return; if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!GetShouldRotate6(device.Orientation)) return; } else if (!GetShouldRotate(device.Orientation)) return; var co = orientation; orientation = device.Orientation; if (co == null) return; DisplayPopover(hideFirst: true); }
private void DidRotate(NSNotification notice) { UIDevice device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || Popover == null) return; if (this.orientation.HasValue && IsSameOrientationKind(this.orientation.Value, device.Orientation)) return; if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!GetShouldRotate6(device.Orientation)) return; } else if (!GetShouldRotate(device.Orientation)) return; UIDeviceOrientation? co = this.orientation; this.orientation = device.Orientation; if (co == null) return; DisplayPopover(hideFirst: true); }
/// <summary> /// Dids the rotate. /// </summary> /// <param name="notice">The notice.</param> private void DidRotate(NSNotification notice) { var device = (UIDevice)notice.Object; if (!IsValidInterfaceOrientation(device.Orientation) || Popover == null) { return; } if (_orientation.HasValue && IsSameOrientationKind(_orientation.Value, device.Orientation)) { return; } if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { if (!GetShouldRotate6(device.Orientation)) { return; } } else if (!GetShouldRotate(device.Orientation)) { return; } var co = _orientation; _orientation = device.Orientation; if (co == null) { return; } DisplayPopover(true); }
/// <summary> /// Displays the popover. /// </summary> /// <param name="hideFirst">if set to <c>true</c> [hide first].</param> public void DisplayPopover(bool hideFirst = false) { if (Popover == null) { return; } var swidth = UIScreen.MainScreen.Bounds.Width; var sheight = UIScreen.MainScreen.Bounds.Height; float width = 400; float height = 300; if (_orientation == null) { if (IsValidInterfaceOrientation(UIDevice.CurrentDevice.Orientation)) { _orientation = UIDevice.CurrentDevice.Orientation; } else { _orientation = GetDeviceOrientation(_viewController.InterfaceOrientation); } } float x, y; if (_orientation == UIDeviceOrientation.LandscapeLeft || _orientation == UIDeviceOrientation.LandscapeRight) { y = (float)(swidth / 2) - (height / 2); x = (float)(sheight / 2) - (width / 2); } else { x = (float)(swidth / 2) - (width / 2); y = (float)(sheight / 2) - (height / 2); } if (hideFirst && Popover.PopoverVisible) { Popover.Dismiss(false); } Popover.PresentFromRect(new CGRect(x, y, width, height), View, 0, true); }
/// <summary> /// Raises the did rotate event. /// </summary> /// <remarks> /// Had to do this, because didn't find a property where to get the actual orientation. /// Seems to be the easies method. /// </remarks> /// <param name="notice">Notice.</param> private void OnDidRotate(NSNotification notice) { UIDevice device = (UIDevice)notice.Object; if (device.Orientation != UIDeviceOrientation.FaceUp && device.Orientation != UIDeviceOrientation.FaceDown && device.Orientation != UIDeviceOrientation.Unknown) _orientation = device.Orientation; }
public void DisplayPopover(bool hideFirst = false) { if (Popover == null) return; float swidth = UIScreen.MainScreen.Bounds.Width; float sheight= UIScreen.MainScreen.Bounds.Height; float width = 400; float height = 300; if (this.orientation == null) { if (IsValidInterfaceOrientation (UIDevice.CurrentDevice.Orientation)) this.orientation = UIDevice.CurrentDevice.Orientation; else this.orientation = GetDeviceOrientation (this.viewController.InterfaceOrientation); } float x, y; if (this.orientation == UIDeviceOrientation.LandscapeLeft || this.orientation == UIDeviceOrientation.LandscapeRight) { y = (swidth / 2) - (height / 2); x = (sheight / 2) - (width / 2); } else { x = (swidth / 2) - (width / 2); y = (sheight / 2) - (height / 2); } if (hideFirst && Popover.PopoverVisible) Popover.Dismiss (animated: false); Popover.PresentFromRect (new RectangleF (x, y, width, height), View, 0, animated: true); }