/// <summary>
        /// Initialization of the view <see cref="ImageInputViewController"/>
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AnalyticsService.TrackEvent(AnalyticsService.Event.ImageInputPageViewed);

            // Set nav bar attributes
            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar);
            NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName);

            SetButtonTouchEvents();
            SetLabelTexts();
            SetButtonBorderShadows();

            UIButton rightButton = new UIButton(UIButtonType.InfoLight);

            rightButton.TouchUpInside += NavBarButtonInfo_TouchUpInside;
            UIBarButtonItem rightBarButton = new UIBarButtonItem(customView: rightButton);

            this.NavigationItem.SetRightBarButtonItem(rightBarButton, true);

            //set the initial focus element
            UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, ChoosePhotoButton);

            SetSmartInvertProperties();

            CheckLaunchFromShareExtension();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            UIFont aboutBold = UIFont.FromDescriptor(UIFontDescriptor.PreferredTitle1.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold), 0);

            this.About.Font = UIFontMetrics.DefaultMetrics.GetScaledFont(aboutBold);

            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar);
            NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName);

            //Programmatically add a back button and an arrow
            UIImage  backArrowImage = UIImage.FromBundle("back-arrow");
            UIButton backButton     = new UIButton(UIButtonType.Custom);

            backButton.SetImage(backArrowImage, UIControlState.Normal);
            backButton.SetTitle("Back", UIControlState.Normal);
            backButton.ImageEdgeInsets = new UIEdgeInsets(0.0f, -12.5f, 0.0f, 0.0f);
            backButton.AddTarget((sender, e) =>
            {
                this.NavigationController?.PopViewController(true);
            }, UIControlEvent.TouchUpInside);

            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(backButton);

            // Programatically set version number
            this.Version.Text = "Version " + Constants.VersionNumber;

            //set the initial focus element
            UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, About);
        }
Example #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set the navigation bar styling
            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationBar);
        }
        /// <summary>
        /// Creates and launches a new <see cref="TOCropViewController"/>
        /// </summary>
        /// <param name="image">Image to crop</param>
        void LaunchCropViewController(UIImage image, NSUrl imageUrl, UINavigationController nav)
        {
            // Instantiate new <see cref="CropViewController"/>
            TOCropViewController cropViewController = new CropViewController(TOCropViewCroppingStyle.Default, image, imageUrl);

            // Push the cropViewController
            nav.PushViewController(cropViewController, true);

            // Set the navbar styling
            NavigationControllerUtil.SetNavigationBarAttributes(nav.NavigationBar);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // Set navigation bar attributes
            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar);
            NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName);
            this.NavigationItem.HidesBackButton = true;

            this.resultsStoryboard = UIStoryboard.FromName("Results", null);

            //set the initial focus element
            UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, AnalyzingLabel);
        }
Example #6
0
        /// <summary>
        /// Initialization of the view <see cref="ImageInputViewController"/>
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib;

            this.GetStartedButton.Layer.CornerRadius = CornerRadius;
            this.GetStartedButton.ClipsToBounds      = true;

            SetUpStringAttributes();

            // Add gesture recognizer for the string tappableStringChestXRayAIModel
            this.Description.UserInteractionEnabled = true; // UserInteractionEnabled must be true for gesture recognizers to be activated
            this.Description.AddGestureRecognizer(new UITapGestureRecognizer((UITapGestureRecognizer gestureRecognizer) =>
            {
                // Launch link if tap lands within description bounds
                LaunchUrlInSafari(SharedConstants.MLModelRepository);

                // To implement tappable portions of an attributed string, uncomment the lines of code below.
                // Issues with the function: VoiceOver taps don't land within the bounds of the tappable string range.
                //UILabel label = gestureRecognizer.View as UILabel;

                //if (GestureRecognizerUtil.DidTapAttributedTextInLabel(label, rangeOfStringChestXRayAIModel, gestureRecognizer, label.TextAlignment))
                //{
                //    LaunchUrlInSafari(SharedConstants.MLModelRepository);
                //}
            }));

            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar);
            NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName);

            UIButton rightButton = new UIButton(UIButtonType.InfoLight);

            rightButton.TouchUpInside += NavBarButtonInfo_TouchUpInside;

            UIBarButtonItem rightBarButton = new UIBarButtonItem(customView: rightButton);

            this.NavigationItem.SetRightBarButtonItem(rightBarButton, true);

            // Set up touch events
            this.GetStartedButton.TouchUpInside += GetStartedButton_TouchUpInside;

            //set the initial focus element
            UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, Title);
        }
        /// <summary>
        /// Creates the UIImagePickerController picker in either camera or photo mode.
        /// Throws an ArgumentException if <see cref="sourceType"/> is neither "camera" nor "photo".
        /// </summary>
        ///
        /// <param name="mode">The source of UIImagePickerController.</param>
        private void CreateImagePicker(UIImagePickerControllerSourceType sourceType)
        {
            imagePicker          = new UIImagePickerController();
            imagePicker.Delegate = this;
            NavigationControllerUtil.SetNavigationBarAttributes(imagePicker.NavigationBar);

            if (sourceType == UIImagePickerControllerSourceType.Camera)
            {
                // set our source to the camera
                imagePicker.SourceType = sourceType;

                // open camera in photo mode only
                imagePicker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo;
            }
            else if (sourceType == UIImagePickerControllerSourceType.PhotoLibrary)
            {
                // Set our source to the photo library
                // The 'availableMediaTypes' property determines the types of media presented in the interface.
                // By default, this is set to the single value kUTTypeImage, which specifies that only
                // still images should be displayed in the media picker when browsing saved media.
                // See https://developer.apple.com/documentation/uikit/uiimagepickercontroller/1619173-mediatypes
                imagePicker.SourceType = sourceType;
            }
            else
            {
                // should never enter this
                throw new ArgumentException("Invalid UIIMagePickerControlerSourceType.");
            }

            AnalyticsService.TrackEvent(AnalyticsService.Event.ImagePickerSelected, new Dictionary <string, string> {
                { AnalyticsService.PropertyKey.Method, imagePicker.SourceType.ToString() }
            });

            // Set handlers
            imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
            imagePicker.Canceled             += Handle_Canceled;
        }
Example #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AnalyticsService.TrackEvent(AnalyticsService.Event.ResultsPageViewed);

            //Programmatically add a back button and an arrow
            UIImage  backArrowImage = UIImage.FromBundle("back-arrow");
            UIButton backButton     = new UIButton(UIButtonType.Custom);

            backButton.SetImage(backArrowImage, UIControlState.Normal);
            backButton.SetTitle("Back", UIControlState.Normal);
            backButton.ImageEdgeInsets = new UIEdgeInsets(0.0f, -12.5f, 0.0f, 0.0f);
            backButton.AddTarget((sender, e) =>
            {
                AnalyticsService.TrackEvent(AnalyticsService.Event.ReturnBackToCroppingPage);
                this.NavigationController?.PopViewController(true);
            }, UIControlEvent.TouchUpInside);

            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(backButton);

            UIButton newSession = new UIButton(UIButtonType.Custom);

            newSession.SetTitle("New Session", UIControlState.Normal);
            newSession.AddTarget((sender, e) =>
            {
                AnalyticsService.TrackEvent(AnalyticsService.Event.ReturnBackToImageInputPage);
                this.NavigationController?.PopToRootViewController(true);
            }, UIControlEvent.TouchUpInside);

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(newSession);

            // Set nav bar attributes
            NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar);
            NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, NavBarTitle);

            InputImage = InputImage.Scale(new CoreGraphics.CGSize(LoadImageWidth, LoadImageHeight));

            // Initialize UIImageView
            imageView       = new UIImageView();
            imageView.Frame = new CGRect(0, 0, InputImage.Size.Width, InputImage.Size.Height);
            imageView.Image = InputImage;
            imageView.UserInteractionEnabled = true;

            // Initialize original imageview
            originalImageView       = new UIImageView();
            originalImageView.Frame = new CGRect(0, 0, InputImage.Size.Width, InputImage.Size.Height);
            originalImageView.Image = InputImage;
            originalImageView.UserInteractionEnabled = true;

            // Initialize meta-data display
            string   filename;
            DateTime?time;

            try
            {
                filename = GetFileString(ImageUrl, DefaultFileStringForCamera);
                time     = GetDate(ImageUrl);
            }
            catch (NullReferenceException ex)
            {
                filename = DefaultFileStringForCamera;
                time     = DateTime.Now;
            }

            AnalyzedImageFileNameLabel.Text = filename;
            AnalyzedImageDateLabel.Text     = time.HasValue ? time.Value.ToShortDateString() : DefaultNoDateDisplay;

            OriginalImageFileNameLabel.Text = filename;
            OriginalImageDateLabel.Text     = time.HasValue ? time.Value.ToShortDateString() : DefaultNoDateDisplay;

            // Add all original labels to List<UILabel>
            originalLabels = new List <UILabel>();
            originalLabels.Add(OriginalImageDateLabel);
            originalLabels.Add(OriginalImageDateHeaderLabel);
            originalLabels.Add(OriginalImageFileNameLabel);
            originalLabels.Add(OriginalImageFileNameHeaderLabel);

            // Toggle accessibilty off for all original labels (they are initially hidden)
            EnableVoiceOverForViews(originalLabels.ToArray(), false);

            SetDisplayBorders();

            // Retrieve the shared AI Client that was loaded by the AppDelegate
            aiClient = ((AppDelegate)UIApplication.SharedApplication.Delegate).AIClient;
            System.Diagnostics.Debug.WriteLine("AI Client retrieved from AppDelegate");
        }