public void Init(NamedCommand cmd)
    {
        InitButton();

        label.text = cmd.Name;
        _button.onClick.AddListener(() => cmd.Action.Invoke());
    }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // "displayItemDetailsCommand" displays item details, but only if
            // there is exactly one selected item, and that item came from the
            // example data source.
            var displayItemDetailsCommand = new SimpleCommand
            {
                IsEnabled = CanDisplayItemDetails(),
                Action    = RunDisplayItemDetailsTabIntent
            };

            var displayItemDetailsNamedCommand = new NamedCommand(SubsettingExampleStringResources.DisplayItemDetailsCommandDisplayName, null, null, displayItemDetailsCommand, DisplayItemDetailsCommandId);

            // Register the command within the command group.
            registrar.RegisterCommands(new[] { displayItemDetailsNamedCommand }, ItemDetailsGroupingId, Enumerable.Empty <Guid>(), Enumerable.Empty <Guid>());
        }
 public TextCommandButtonNonTMP Initialized(NamedCommand cmd)
 {
     Init(cmd);
     return(this);
 }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // "displayItemDetailsCommand" displays item details, but only if
            // there is exactly one selected item, and that item came from the
            // example data source.
            var displayItemDetailsCommand = new SimpleCommand
                              {
                                  IsEnabled = CanDisplayItemDetails(),
                                  Action = RunDisplayItemDetailsTabIntent
                              };

            var displayItemDetailsNamedCommand = new NamedCommand(SubsettingExampleStringResources.DisplayItemDetailsCommandDisplayName, null, null, displayItemDetailsCommand, DisplayItemDetailsCommandId);

            // Register the command within the command group.
            registrar.RegisterCommands(new[] { displayItemDetailsNamedCommand }, ItemDetailsGroupingId, Enumerable.Empty<Guid>(), Enumerable.Empty<Guid>());
        }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // Register your custom commands here. You can specify where the
            // commands should appear in relation to other commands.

            // "command1" determines how many items are currently selected, and
            // displays a message that contains that information to the user.
            var command1 = new SimpleCommand
            {
                IsEnabled = true,
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    string.Format(CommandExtensibilityExampleStringResources.ExampleCommand1MessageFormat, mCommandsContext.SelectedModels.Count()))
            };

            var namedCommand1 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand1DisplayName,
                                                 CommandExtensibilityExampleStringResources.ExampleCommand1Tooltip,
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand1Icon.png",
                                                 command1,
                                                 ExampleCommand1Id);

            // "command2" determines whether the Intelligence Portal is
            // displaying information about a set, and reports that to the user.
            var command2 = new SimpleCommand
            {
                IsEnabled = true,
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    string.Format(CommandExtensibilityExampleStringResources.ExampleCommand2MessageFormat, mCommandsContext.SetContext != null ? CommandExtensibilityExampleStringResources.ExampleCommand2PositiveResponse : CommandExtensibilityExampleStringResources.ExampleCommand2NegativeResponse))
            };

            var namedCommand2 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand2DisplayName,
                                                 CommandExtensibilityExampleStringResources.ExampleCommand2Tooltip,
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand2Icon.png",
                                                 command2,
                                                 ExampleCommand2Id);

            // The commands added here appear in the given order, within the
            // given group. "command1" therefore appears before "command2".
            // There are no existing commands in the custom group, so there is
            // no need to specify "before" or "after" information.
            registrar.RegisterCommands(
                commands: new[] { namedCommand1, namedCommand2 },
                containingBlock: ExampleCommandGroupingId,
                insertBefore: Enumerable.Empty <Guid>(),
                insertAfter: Enumerable.Empty <Guid>());

            // "insertedcommand" just displays a message to indicate that the
            // user has selected it
            var insertedCommand = new SimpleCommand
            {
                IsEnabled = mCommandsContext.SelectedModels.Any(),
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    CommandExtensibilityExampleStringResources.ExampleInsertedCommandMessage)
            };

            var insertedNamedCommand = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleInsertedCommandDisplayName,
                                                        CommandExtensibilityExampleStringResources.ExampleInsertedCommandTooltip,
                                                        "/CommandExtensibilityExample;component/Assets/InsertedCommandIcon.png",
                                                        insertedCommand,
                                                        ExampleInsertedCommandId);

            // Add "insertedcommand" into the list of standard commands,
            // rather than into its own group. This call requests that the
            // command is displayed after the delete command and before the
            // create link command.
            registrar.RegisterCommands(
                commands: new[] { insertedNamedCommand },
                containingBlock: DefaultItemCommands.ItemCommandsCommandGroupingType,
                insertBefore: new[] { DefaultItemCommands.DeleteCommandType },
                insertAfter: new[] { DefaultItemCommands.CreateLinkCommandType });
        }
Esempio n. 6
0
        public void IdShouldWriteExpectedValue()
        {
            // arrange
            var expected = "42";
            var command = new NamedCommand<object>( "Test", DefaultAction.None );

            // act
            Assert.PropertyChanged( command, "Id", () => command.Id = expected );
            var actual = command.Id;

            // assert
            Assert.Equal( expected, actual );
        }
Esempio n. 7
0
        public void DescriptionShouldNotAllowNull()
        {
            // arrange
            string value = null;
            var command = new NamedCommand<object>( "Test", DefaultAction.None );

            // act
            var ex = Assert.Throws<ArgumentNullException>( () => command.Description = value );

            // assert
            Assert.Equal( "value", ex.ParamName );
        }
Esempio n. 8
0
        public void NameShouldNotAllowNullOrEmpty( string value )
        {
            // arrange
            var command = new NamedCommand<object>( "Test", DefaultAction.None );

            // act
            var ex = Assert.Throws<ArgumentNullException>( () => command.Name = value );

            // assert
            Assert.Equal( "value", ex.ParamName );
        }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // Register your custom commands here. You can specify where the
            // commands should appear in relation to other commands.

            // "command1" determines how many items are currently selected, and
            // displays a message that contains that information to the user.
            var command1 = new SimpleCommand
                              {
                                  IsEnabled = true,
                                  Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                                               string.Format(CommandExtensibilityExampleStringResources.ExampleCommand1MessageFormat, mCommandsContext.SelectedModels.Count()))
                              };

            var namedCommand1 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand1DisplayName, 
                                                 CommandExtensibilityExampleStringResources.ExampleCommand1Tooltip, 
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand1Icon.png", 
                                                 command1, 
                                                 ExampleCommand1Id);

            // "command2" determines whether the Intelligence Portal is
            // displaying information about a set, and reports that to the user.
            var command2 = new SimpleCommand
            {
                IsEnabled = true,
                Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                             string.Format(CommandExtensibilityExampleStringResources.ExampleCommand2MessageFormat, mCommandsContext.SetContext != null ? CommandExtensibilityExampleStringResources.ExampleCommand2PositiveResponse : CommandExtensibilityExampleStringResources.ExampleCommand2NegativeResponse))
            };

            var namedCommand2 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand2DisplayName, 
                                                 CommandExtensibilityExampleStringResources.ExampleCommand2Tooltip, 
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand2Icon.png", 
                                                 command2, 
                                                 ExampleCommand2Id);

            // The commands added here appear in the given order, within the
            // given group. "command1" therefore appears before "command2".
            // There are no existing commands in the custom group, so there is
            // no need to specify "before" or "after" information.
            registrar.RegisterCommands(
                commands: new[] { namedCommand1, namedCommand2 }, 
                containingBlock: ExampleCommandGroupingId, 
                insertBefore: Enumerable.Empty<Guid>(), 
                insertAfter: Enumerable.Empty<Guid>());

            // "insertedcommand" just displays a message to indicate that the
            // user has selected it
            var insertedCommand = new SimpleCommand
            {
                IsEnabled = mCommandsContext.SelectedModels.Any(),
                Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                             CommandExtensibilityExampleStringResources.ExampleInsertedCommandMessage)
            };

            var insertedNamedCommand = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleInsertedCommandDisplayName, 
                                                        CommandExtensibilityExampleStringResources.ExampleInsertedCommandTooltip, 
                                                        "/CommandExtensibilityExample;component/Assets/InsertedCommandIcon.png", 
                                                        insertedCommand, 
                                                        ExampleInsertedCommandId);

            // Add "insertedcommand" into the list of standard commands,
            // rather than into its own group. This call requests that the
            // command is displayed after the delete command and before the
            // create link command.
            registrar.RegisterCommands(
                commands: new[] { insertedNamedCommand },
                containingBlock: DefaultItemCommands.ItemCommandsCommandGroupingType,
                insertBefore: new[] { DefaultItemCommands.DeleteCommandType },
                insertAfter: new[] { DefaultItemCommands.CreateLinkCommandType });
        }