Exemplo n.º 1
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");
        }