コード例 #1
0
        void ReleaseDesignerOutlets()
        {
            if (ChildTease != null)
            {
                ChildTease.Dispose();
                ChildTease = null;
            }

            if (ResultCollectionView != null)
            {
                ResultCollectionView.Dispose();
                ResultCollectionView = null;
            }

            if (StartButton != null)
            {
                StartButton.Dispose();
                StartButton = null;
            }

            if (TaskDescription != null)
            {
                TaskDescription.Dispose();
                TaskDescription = null;
            }

            if (TaskType != null)
            {
                TaskType.Dispose();
                TaskType = null;
            }

            if (TaskTypeIcon != null)
            {
                TaskTypeIcon.Dispose();
                TaskTypeIcon = null;
            }
        }
コード例 #2
0
        public void UpdateContent(AppTask data, Action <AppTask> OnButtonClicked, Action <AppTask, string, int> OnResultClicked)
        {
            taskData  = data;
            startTask = OnButtonClicked;

            TaskType.Text        = data.TaskType.DisplayName;
            TaskDescription.Text = data.Description;

            if (string.IsNullOrWhiteSpace(data.TaskType.IconUrl))
            {
                ImageService.Instance.LoadCompiledResource("AppLogo").Into(TaskTypeIcon);
            }
            else
            {
                ImageService.Instance.LoadUrl(data.TaskType.IconUrl)
                //.LoadingPlaceholder("AppLogo", ImageSource.CompiledResource)
                .Into(TaskTypeIcon);
            }


            // Show tease label if this task has children and hasn't yet been completed
            if (data.ChildTasks != null && data.ChildTasks.Count() > 0 && !data.IsCompleted)
            {
                NSLayoutConstraint.DeactivateConstraints(new NSLayoutConstraint[] { hideChildTeaseConstraint });
                NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { showChildTeaseConstraint });
                ChildTease.Text = string.Format(
                    "Complete this to view {0} locked task{1}!",
                    data.ChildTasks.Count(),
                    data.ChildTasks.Count() > 1 ? "s" : "");
            }
            else
            {
                NSLayoutConstraint.DeactivateConstraints(new NSLayoutConstraint[] { showChildTeaseConstraint });
                NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { hideChildTeaseConstraint });
            }

            // Make child tasks visually distinct
            Layer.BackgroundColor = (data.IsChild) ? UIColor.FromRGBA(140, 192, 77, 50).CGColor : UIColor.White.CGColor;


            onResultClicked = OnResultClicked;

            // default to not showing result collection
            NSLayoutConstraint.DeactivateConstraints(new NSLayoutConstraint[] { showCollectionConstraint });
            NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { hideCollectionConstraint });
            StartButton.SetTitle("Start", UIControlState.Normal);
            files = new List <string>();

            if (data.CompletionData != null && !string.IsNullOrWhiteSpace(data.CompletionData.JsonData))
            {
                files = JsonConvert.DeserializeObject <List <string> >(data.CompletionData.JsonData ?? "") ?? new List <string>();

                if (files.Count > 0)
                {
                    NSLayoutConstraint.DeactivateConstraints(new NSLayoutConstraint[] { hideCollectionConstraint });
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { showCollectionConstraint });
                    switch (data.TaskType.IdName)
                    {
                    case "MATCH_PHOTO":
                    case "TAKE_PHOTO":
                        StartButton.SetTitle("Take another", UIControlState.Normal);
                        break;

                    case "TAKE_VIDEO":
                    case "REC_AUDIO":
                        StartButton.SetTitle("Record another", UIControlState.Normal);
                        break;
                    }
                }

                ResultCollectionView.AllowsSelection = true;
            }

            ResultCollectionView.Source   = new TaskResultViewSource(files);
            ResultCollectionView.Delegate = new ClickableDelegate(ResultClicked);
            ResultCollectionView.UpdateConstraints();
            ResultCollectionView.ReloadData();
            ResultCollectionView.CollectionViewLayout.InvalidateLayout();
        }