Пример #1
0
        public void ViewDidLoad(UIViewController viewController)
        {
            SendButton.TintColor = StyleHelper.Style.ButtonTintColor;
            SendButton.SetImage(UIImage.FromBundle(StyleHelper.Style.SendBundleName), UIControlState.Normal);
            SendButton.SetCommand(new RelayCommand(OnRaiseSend));

            AttachImageButton.TintColor = StyleHelper.Style.ButtonTintColor;
            AttachImageButton.SetImage(UIImage.FromBundle(StyleHelper.Style.AddImageBundleName), UIControlState.Normal);
            AttachImageButton.SetCommand(new RelayCommand(OnAddPhotoClicked));

            TakePhotoButton.TintColor = StyleHelper.Style.ButtonTintColor;
            TakePhotoButton.SetImage(UIImage.FromBundle(StyleHelper.Style.TakePhotoBundleName), UIControlState.Normal);
            TakePhotoButton.SetCommand(new RelayCommand(OnTakePhotoClicked));

            RemoveAttachButton.SetImage(UIImage.FromBundle(StyleHelper.Style.RemoveAttachBundleName),
                                        UIControlState.Normal);
            RemoveAttachButton.SetCommand(new RelayCommand(OnRemovePhotoClicked));

            AttachedImageView.Layer.MasksToBounds = false;
            AttachedImageView.Layer.CornerRadius  = 5;
            AttachedImageView.ClipsToBounds       = true;
            AttachedImageView.ContentMode         = UIViewContentMode.ScaleAspectFill;

            EditImageContainer.Hidden = true;
            EditImageContainerHeightConstraint.Constant = 0;

            _simpleImagePicker = new SimpleImagePicker(viewController,
                                                       Dependencies.Container.Resolve <IPermissionsManager>(), false);
            _attachedImageBinding = this.SetBinding(() => _simpleImagePicker.ViewModel.ImageCacheKey).WhenSourceChanges(
                () =>
            {
                if (string.IsNullOrEmpty(_simpleImagePicker.ViewModel.ImageCacheKey))
                {
                    CloseAttachPanel();
                    return;
                }

                OpenAttachPanel();
            });
            _simpleImagePicker.SetCommand(nameof(_simpleImagePicker.PickerWillOpen),
                                          new RelayCommand(RaisePickerWillOpen));
        }
        void ReleaseDesignerOutlets()
        {
            if (DetailsText != null)
            {
                DetailsText.Dispose();
                DetailsText = null;
            }

            if (TakePhotoButton != null)
            {
                TakePhotoButton.Dispose();
                TakePhotoButton = null;
            }

            if (ThePhoto != null)
            {
                ThePhoto.Dispose();
                ThePhoto = null;
            }
        }
Пример #3
0
        private async void TakePhotoButton_Tapped(object sender, EventArgs e)
        {
            // Wait for previous call to finish
            if (TakingPhoto)
            {
                return;
            }
            TakingPhoto = true;

            try
            {
                if (CameraView.EnablePreview)
                {
                    // Take a photo
                    CameraView.Camera.TakePicture();

                    // Simple tapped effect
                    await TakePhotoButton.ScaleTo(1.2, 200, Easing.SinIn);

                    await TakePhotoButton.ScaleTo(1, 200, Easing.SinIn);
                }
                else
                {
                    await StartCamera();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", $"Unable to take photo: {ex.Message}", "OK");
            }
            finally
            {
                // Finished
                TakingPhoto = false;
            }
        }