Exemple #1
0
        /// <summary>
        /// Handles the camera availability.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="available">If set to <c>true</c> available.</param>
        public void HandleCameraAvailability(object sender, bool available)
        {
            _model.CanCapture = available;

            if (available)
            {
                _model.CameraLoading = false;

                // wait until camera is available before animating focus target, we have to invoke on UI thread as this is run asynchronously
                Device.BeginInvokeOnMainThread(() =>
                {
                    // set starting list opacity based on orientation
                    var orientation = (Height > Width) ? Orientation.Portrait : Orientation.LandscapeLeft;
                    // set starting orientation
                    HandleOrientationChange(null, orientation);

                    // these bindings are created after page intitalizes
                    PhotoEditLayout.SetBinding(VisualElement.IsVisibleProperty, new Binding("PhotoEditOn"));

                    // camera button layouts
                    CameraButtonContainerLandscape.SetBinding(VisualElement.OpacityProperty, new Binding("PageOrientation", converter: new OrientationToDoubleConverter(), converterParameter: "1, 1"));
                    CameraButtonContainerLandscape.SetBinding(VisualElement.IsVisibleProperty, new Binding("PageOrientation", converter: new OrientationToBoolConverter(), converterParameter: "true, false"));
                    CameraButtonContainerPortrait.SetBinding(VisualElement.OpacityProperty, new Binding("PageOrientation", converter: new OrientationToDoubleConverter(), converterParameter: "0, 1"));
                    CameraButtonContainerPortrait.SetBinding(VisualElement.IsVisibleProperty, new Binding("PageOrientation", converter: new OrientationToBoolConverter(), converterParameter: "false, true"));

                    FocusView.Reset();
                });
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the orientation change.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="arg">Argument.</param>
        public void HandleOrientationChange(object sender, Orientation arg)
        {
            FocusView.Orientation = CameraView.Orientation = OrientationPage.PageOrientation = _model.PageOrientation = arg;

            // bindings will not work with column width properties so we have to perform this manually
            switch (PageOrientation)
            {
            case Orientation.LandscapeLeft:
            case Orientation.LandscapeRight:
                MainLayout.ColumnDefinitions[5].Width = new GridLength(CAMERA_BUTTON_CONTAINER_WIDTH,
                                                                       GridUnitType.Absolute);
                break;

            case Orientation.Portrait:
                MainLayout.ColumnDefinitions[4].Width = new GridLength(CAMERA_BUTTON_CONTAINER_WIDTH,
                                                                       GridUnitType.Absolute);
                break;
            }

            if (_model.CanCapture)
            {
                FocusView.Reset();
            }

            CameraView.NotifyOrientationChange(arg);
        }