Beispiel #1
0
        public async void RetakeBusinessCard()
        {
            var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera);

            if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted)
            {
                return;
            }

            HomePage.BcReader.RecognizeQRCode = HomePage.CurrentAppData.RecognizeQRCode;
            var page = new CameraPage(CameraOperationType.Normal);

            PushCameraPage(page);
        }
        private async void CameraAddButton_Tapped(object sender, EventArgs e)
        {
            HideQuickActionControls();
            var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera);

            if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted)
            {
                return;
            }

            HomePage.Instance.ContactSavedAction = new Action <ContactModel>((contact) =>
            {
                contact.Group = _groupName;
                RefreshListView();
            });

            var page = new CameraPage(CameraOperationType.Normal);

            HomePage.Instance.PushCameraPage(page);
        }
        public PreviewBusinessCardPage(ContactModel contactItem, int indexInCollection)
        {
            InitializeComponent();
#if __IOS__
            HasSystemPadding = false;
#endif

            BindingContext = this;

            ContactItem   = contactItem;
            _contactIndex = indexInCollection;

            if (profileImageView == null)
            {
                Grid grid = (Grid)carouselView.ItemsSource.GetItem(0);

                baseFrontImageView = grid.Children[0] as Image;

                grid             = (Grid)grid.Children.Where((a) => a is Grid).GetItem(0);
                profileImageView = (SvgImage)grid.Children[0];
            }

            RoundCornersEffect.SetCornerRadius(profileImageView, (int)(profileImageView.HeightRequest / 2));

            Grid frontImageGrid = (carouselView.ItemsSource.GetItem(1) as Grid);

            frontImageView = frontImageGrid.Children[0] as Image;

            backImageContainer = (carouselView.ItemsSource.GetItem(2) as Grid);

            Grid backImageViewGrid = backImageContainer.Children[0] as Grid;

            backImageView = backImageViewGrid.Children[0] as Image;

            addBackImageContainer = backImageContainer.Children[1] as Grid;

            frontImageView.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    HideQuickActionControls();
                    ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.Picture, ImageType.FrontImage);

                    imageViewerPage.ImageModified += ImageViewerPage_ImageModified;

                    await PopupNavigation.Instance.PushAsync(imageViewerPage);
                })
            });

            backImageView.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    HideQuickActionControls();
                    ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.BackImage, ImageType.BackImage);

                    imageViewerPage.ImageModified += ImageViewerPage_ImageModified;

                    await PopupNavigation.Instance.PushAsync(imageViewerPage);
                })
            });

            profileImageView.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    if (String.IsNullOrEmpty(ContactItem.ProfileImage))
                    {
                        var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera);
                        if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted)
                        {
                            return;
                        }

                        CameraPage cameraPage    = new CameraPage(CameraOperationType.Profile);
                        cameraPage.PictureTaken += this.CameraPictureTaken;

                        HomePage.Instance.PushCameraPage(cameraPage);
                    }
                    else
                    {
                        HideQuickActionControls();
                        ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.ProfileImage, ImageType.ProfileImage);

                        imageViewerPage.ImageModified += ImageViewerPage_ImageModified;

                        await PopupNavigation.Instance.PushAsync(imageViewerPage);
                    }
                })
            });

            Image backsideImage = addBackImageContainer.Children[0] as Image;
            backsideImage.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera);
                    if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted)
                    {
                        return;
                    }

                    CameraPage cameraPage    = new CameraPage(CameraOperationType.BackImage);
                    cameraPage.PictureTaken += this.CameraPictureTaken;

                    HomePage.Instance.PushCameraPage(cameraPage);
                })
            });

            if (!String.IsNullOrEmpty(ContactItem.BackImage))
            {
                SetBackImage();
            }

            if (!String.IsNullOrEmpty(ContactItem.ProfileImage))
            {
                profileImageView.Source = ContactItem.ProfileImage;
            }

            ContactModelToFields();
            ContactListView.ItemsSource = ContactFields;
        }