public TextToSpeechPage()
        {
            var takePictureButton = new TakePhotoButton {
                Text = "Take A Picture Of Text"
            };

            takePictureButton.SetBinding(IsVisibleProperty, nameof(TextToSpeechViewModel.IsTakePictureButtonVisible));
            takePictureButton.SetBinding(Button.CommandProperty, nameof(TextToSpeechViewModel.TakePictureButtonCommand));

            var spokenTextLabel = new Label {
                HorizontalTextAlignment = TextAlignment.Center
            };

            spokenTextLabel.SetBinding(Label.TextProperty, nameof(TextToSpeechViewModel.SpokenTextLabelText));

            var activityIndicatorLabel = new Label {
                FontAttributes = FontAttributes.Italic
            };

            activityIndicatorLabel.SetBinding(Label.TextProperty, nameof(TextToSpeechViewModel.ActivityIndicatorLabelText));

            var activityIndicator = new ActivityIndicator {
                Color = ColorConstants.NavigationBarBackgroundColor
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(TextToSpeechViewModel.IsActivityIndicatorDisplayed));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(TextToSpeechViewModel.IsActivityIndicatorDisplayed));

            var stackLayout = new StackLayout
            {
                Margin            = new Thickness(20, 0),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    spokenTextLabel,
                    activityIndicatorLabel,
                    activityIndicator,
                    takePictureButton,
                }
            };

            ViewModel.OCRFailed                                      += HandleOCRFailed;
            ViewModel.SpellCheckFailed                               += HandleSpellCheckFailed;
            MediaService.NoCameraDetected                            += HandleNoCameraDetected;
            MediaService.PermissionsDenied                           += HandlePermissionsDenied;
            OCRServices.InvalidComputerVisionAPIKey                  += HandleInvalidComputerVisionAPIKey;
            SpellCheckServices.InvalidBingSpellCheckAPIKey           += HandleInvalidBingSpellCheckAPIKey;
            ViewModel.InternetConnectionUnavailable                  += HandleInternetConnectionUnavailable;
            SpellCheckServices.Error429_TooManySpellCheckAPIRequests += HandleError429_TooManySpellCheckAPIRequests;

            Content = new ScrollView {
                Content = stackLayout
            };

            Title = "XamSpeak";
        }
示例#2
0
        public TextToSpeechPage()
        {
            this.SetBinding(IsBusyProperty, nameof(ViewModel.IsInternetConnectionInUse));

            var takePictureButton = new TakePhotoButton {
                Text = "   Take A Picture Of Text   "
            };
            var inverseBoolConverter = new InverseBoolConverter();
            var inverseBoolBinding   = new Binding(nameof(ViewModel.IsActivityIndicatorDisplayed), BindingMode.Default, inverseBoolConverter, ViewModel.IsActivityIndicatorDisplayed);

            takePictureButton.SetBinding(IsVisibleProperty, inverseBoolBinding);
            takePictureButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePictureButtonCommand));

            var spokenTextLabel = new Label {
                HorizontalTextAlignment = TextAlignment.Center
            };

            spokenTextLabel.SetBinding(Label.TextProperty, nameof(ViewModel.SpokenTextLabelText));

            var activityIndicatorLabel = new Label {
                FontAttributes = FontAttributes.Italic
            };

            activityIndicatorLabel.SetBinding(Label.TextProperty, nameof(ViewModel.ActivityIndicatorLabelText));

            var activityIndicator = new ActivityIndicator();

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsActivityIndicatorDisplayed));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsActivityIndicatorDisplayed));

            var stackLayout = new StackLayout
            {
                Margin            = new Thickness(20, 0),
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    spokenTextLabel,
                    activityIndicatorLabel,
                    activityIndicator,
                    takePictureButton,
                }
            };

            Content = new ScrollView {
                Content = stackLayout
            };

            Title = "XamSpeak";
        }