# flatredball-glue-interfaces-imenustripplugin

### Introduction

An IMenuStripPlugin is a plugin that adds a menu strip item. ![GlueMenuStrip.png](/files/X8O5frqkXCFzCtjjkz1h) IMenuStripPlugins can create new top-level menus (such as a new menu to the right of "Glue View" in the image above) or can add items under existing menu items (such as under the "Project" menu item).

### Code Example

The following code example adds an option under the "Plugins" menu option which shows a simple message box when clicked.

```
using FlatRedBall.Glue.Plugins.Interfaces;
using System.ComponentModel.Composition;
using System.Windows.Forms;

// Make sure your plugin class inherits from IMenuStripPlugin and exports the IMenuStripPlugin interface:
[Export(typeof(IMenuStripPlugin)) ]
public class TortoiseMenuItems : IMenuStripPlugin
{
    ToolStripMenuItem mMenuItem;
    MenuStrip mMenuStrip;

    public void InitializeMenu(System.Windows.Forms.MenuStrip menuStrip)
    {
        mMenuStrip = menuStrip;

        mMenuItem = new ToolStripMenuItem("Show Popup");
        ToolStripMenuItem itemToAddTo = GetItem("Plugins");

        itemToAddTo.DropDownItems.Add(mMenuItem);
        mMenuItem.Click += new EventHandler(mMenuItem_Click);
    }

    public bool ShutDown(PluginShutDownReason shutDownReason)
    {
        ToolStripMenuItem itemToAddTo = GetItem("Plugins");
        itemToAddTo.DropDownItems.Remove(mMenuItem);
        return true;
    }

    void mMenuItem_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Popup!");
    }

    ToolStripMenuItem GetItem(string name)
    {
        foreach (ToolStripMenuItem item in mMenuStrip.Items)
        {
            if (item.Text == name)
            {
                return item;
            }
        }
        return null;
    }

    // The following methods are all required for plugins:
    public string FriendlyName
    {
        get { return "MessageBox showing plugin"; }
    }

    public Version Version
    {
        get { return new Version(); }
    }

    public void StartUp()
    {
        // do nothing
    }

    public bool ShutDown(PluginShutDownReason shutDownReason)
    {
        // This plugin needs to be responsible and remove itself from Glue when shutting down
        ToolStripMenuItem itemToRemoveFrom = GetItem("Plugins");
        itemToRemoveFrom.DropDownItems.Remove(mMenuItem);
        return true;// We are okay to shut down
    }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flatredball.com/flatredball/api/glue-plugin-api/flatredball-glue/plugins/flatredball-glue-interfaces-imenustripplugin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
