Execute VC 4.0 commands in Plugin (why reinvent the wheel, so to speak)

Forum Forums Visual Components 4.0 .NET Addon Programming Execute VC 4.0 commands in Plugin (why reinvent the wheel, so to speak)

Visual Components Essentials has been officially released, download link

Be sure to read the Forum Rules and Guidelines before start using the Forum.

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by Chungmin Chungmin 4 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2942
    Jay
    Jay
    Participant

    So I was asked the other day how to execute “Extract component” command found on the feature tree context menu in a VC 4.0 .NET API plugin. I said the answer is simple. Simply do this in your plugin.

    var cmd = IoC.Get<ICommandRegistry>();
    var extractCmd = cmd.FindItem(“ExtractComponentCommand”);
    extractCmd.Execute();

    Ok good but how did you know the command Id? Well I simply went through the command registry and display the UI name against the Id.

    var cmds = IoC.Get<ICommandRegistry>().Actions;
    List<string> cmdsList = new List<string>();

    foreach (IActionItem cmd in cmds)
    {
    cmdsList.Add(cmd.Content + “: ” + cmd.Id);
    }

    var sort = from s in cmdsList
    orderby s ascending
    select s;

    foreach (string cmdList in sort)
    {
    IoC.Get<IMessageService>().AppendMessage(cmdList,  MessageLevel.Warning);
    }

    Well, it’s that simple.

     

    #3195
    Chungmin
    Chungmin
    Participant

    Super useful!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.