Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel.Initialize();

            this.SetTranslation();

            this.bindings = new List <Binding>()
            {
                this.SetBinding(() => ViewModel.VisionSubscriptionKey, () => TextVisionSubscriptionKey.Text, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.FaceSubscriptionKey, () => TextFaceSubscriptionKey.Text, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.TranslatorSubscriptionKey, () => TextTranslatorSubscriptionKey.Text, BindingMode.TwoWay),

                this.SetBinding(() => ViewModel.IsTextToSpeechEnabled, () => SwitchTextToSpeech.On, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.ShowRecognitionConfidence, () => SwitchShowDescriptionConfidence.On, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.ShowOriginalDescriptionOnTranslation, () => SwitchShowOriginalDescription.On, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.ShowDescriptionOnFaceIdentification, () => SwitchShowDescriptionOnFaceIdentification.On, BindingMode.TwoWay),
            };

            TextVisionSubscriptionKey.DismissKeyboardOnReturn();
            TextFaceSubscriptionKey.DismissKeyboardOnReturn();
            TextTranslatorSubscriptionKey.DismissKeyboardOnReturn();

            ButtonAbout.SetCommand(this.ViewModel.GotoAboutCommand);
            ButtonPrivacy.SetCommand(this.ViewModel.GotoPrivacyPolicyCommand);

            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) =>
            {
                this.ViewModel.Save();
                NavigationController.PopViewController(true);
            })
                , true);

            //dismiss the keyboard if the user taps anywhere in the view
            var g = new UITapGestureRecognizer(() => View.EndEditing(true));

            g.CancelsTouchesInView = false;             //for iOS5
            View.AddGestureRecognizer(g);

            NavigationController.SetNavigationBarHidden(false, false);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel.Initialize();

            this.RegisterMessages();
            this.SetTranslation();
            this.bindings = new List <Binding>()
            {
                this.SetBinding(() => ViewModel.VisionSubscriptionKey, () => TextVisionSubscriptionKey.Text, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.EmotionSubscriptionKey, () => TextEmotionSubscriptionKey.Text, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.TranslatorSubscriptionKey, () => TextTranslatorSubscriptionKey.Text, BindingMode.TwoWay),

                this.SetBinding(() => ViewModel.IsTextToSpeechEnabled, () => SwitchTextToSpeech.Selected, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.ShowDescriptionConfidence, () => SwitchShowDescriptionConfidence.Selected, BindingMode.TwoWay),
                this.SetBinding(() => ViewModel.ShowOriginalDescriptionOnTranslation, () => SwitchShowOriginalDescription.Selected, BindingMode.TwoWay),
            };

            TextVisionSubscriptionKey.DismissKeyboardOnReturn();
            TextEmotionSubscriptionKey.DismissKeyboardOnReturn();
            TextTranslatorSubscriptionKey.DismissKeyboardOnReturn();

            ButtonAbout.SetCommand(this.ViewModel.GotoAboutCommand);
            ButtonPrivacy.SetCommand(this.ViewModel.GotoPrivacyPolicyCommand);

            LinkSubscribeEmotion.UserInteractionEnabled = true;
            LinkSubscribeEmotion.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                this.ViewModel.SubscribeCognitiveServicesCommand.Execute(null);
            }));
            LinkSubscribeVision.UserInteractionEnabled = true;
            LinkSubscribeVision.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                this.ViewModel.SubscribeCognitiveServicesCommand.Execute(null);
            }));
            LinkTranslatorSubscriptionKey.UserInteractionEnabled = true;
            LinkTranslatorSubscriptionKey.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                this.ViewModel.SubscribeTranslatorServiceCommand.Execute(null);
            }));


            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) =>
            {
                this.ViewModel.Save();
            })
                , true);

            ButtonAbout.Hidden   = true;
            ButtonPrivacy.Hidden = true;

            //dismiss the keyboard if the user taps anywhere in the view
            var g = new UITapGestureRecognizer(() => View.EndEditing(true));

            g.CancelsTouchesInView = false;             //for iOS5
            View.AddGestureRecognizer(g);

            NavigationController.SetNavigationBarHidden(false, false);
        }