Example #1
0
        /// <summary>
        ///     Invoked when an image is taken or selected by the user.
        ///     The image is then dumped to a new attachment data map.
        /// </summary>
        /// <param name="imageData">The arguments returned by the UIImagePickerControllerDelegate.</param>
        /// <param name="commandArguments">The arguments of the original application command.</param>
        private async void OnImagePicked(NSDictionary imageInfo, ApplicationCommandArguments commandArguments)
        {
            // Did the user cropped the image or performed
            // any other edition on the original image? If
            // so, we'll use this version.
            var image = imageInfo[UIImagePickerController.EditedImage] as UIImage;

            // If he didn't, let's use the original image.
            if (null == image)
            {
                image = imageInfo[UIImagePickerController.OriginalImage] as UIImage;
            }

            if (null == image)
            {
                return;
            }

            var attachment = await CreateAttachment(commandArguments, image);

            // Let's instruct the controller to activate and
            // display the new attachment on the screen so the
            // user can complement it and commit the operation.
            ((DetailController)commandArguments
             .Controller)
            .ShowSegment(AttachmentApplicationName, attachment);
        }
Example #2
0
        private UITableViewCell GetCellForCommand(UITableView tableView, NSIndexPath indexPath)
        {
            var commandBinding = GetCommand(indexPath);

            var commandArguments = new ApplicationCommandArguments(
                _applicationMetadata, MetadataRepository, _dataMap, new DataRepository(), _composite, User.Current, _detailController);

            return(CellTemplate.ConstructCommandCell(tableView, commandBinding, commandArguments, _commandPreCondition));
        }
Example #3
0
        internal void Construct(IApplicationCommand command, ApplicationCommandArguments arguments, Func <Task <bool> > preCondition)
        {
            _command      = command;
            _preCondition = preCondition;
            _arguments    = arguments;

            title.Text    = command.Title;
            subtitle.Text = command.Subtitle;
            button.SetTitle(command.Label, UIControlState.Normal);

            subtitle.SizeToFit();
            button.SetBackgroundImage(Theme.CommandButton, UIControlState.Normal);
        }
        private static DataOperation CreateDataOperation(ApplicationCommandArguments arguments)
        {
            // TODO: use UTC?
            var statusDate = DataMap.ConvertType(DateTime.Now);

            var dataMap = arguments.DataMap;
            var data    = new Dictionary <string, string>
            {
                { "localid", dataMap.LocalState.LocalId.ToString() },
                { "wonum", dataMap.Value("wonum") },
                { "status", dataMap.Value("status") },
                { "statusdate", statusDate }
            };

            return(new DataOperation(arguments.ApplicationSchemaDefinition, data, typeof(Handler)));
        }
        private static async void OnLookupCompleted(ApplicationCommandArguments commandArguments)
        {
            // We'll ask the controller to save the changes
            // instead of doing ourselves because it will
            // continue active in the screen, and we don't
            // want to mess with its state.
            var success = await((DetailController)commandArguments
                                .Controller)
                          .SaveAsync();

            if (false == success)
            {
                return;
            }

            // Registers the status change
            // in our operation ledger.
            await commandArguments
            .DataRepository
            .SaveAsync(CreateDataOperation(commandArguments));
        }
Example #6
0
            /// <summary>
            ///     Constructs a cell containing a large button
            ///     that represents an UI command available to
            ///     the user.
            /// </summary>
            /// <param name="tableView">The parent <see cref="UITableView"/>.</param>
            /// <param name="commandBinding">The command binding backing the cell.</param>
            /// <param name="commandArguments">The command arguments to be dispatched when the command is invoked by the user.</param>
            /// <param name="commandPreCondition">A delegate to be evaluated before executing the command.</param>
            public static UITableViewCell ConstructCommandCell(UITableView tableView, CommandBinding commandBinding, ApplicationCommandArguments commandArguments, Func <Task <bool> > commandPreCondition)
            {
                var cell = (DetailCommandCell)tableView.DequeueReusableCell("DetailCommandCell");

                cell.Construct(commandBinding.Command, commandArguments, commandPreCondition);

                return(cell);
            }