Exemplo n.º 1
0
        private void RemoveItem(EnvDTE80.DTE2 dteObject)
        {
            int  tabIndex;
            bool tabExists = true;

            //Get the window object corresponding to the Visual Studio ToolBox
            ToolBoxWnd = (EnvDTE80.Window2)dteObject.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
            tlbTabs    = (EnvDTE80.ToolBoxTab2)((EnvDTE.ToolBox)ToolBoxWnd.Object).ToolBoxTabs;
            tlbTab     = null;

            //loop through all the tabs and match the tab name entered by the user.
            for (tabIndex = 1; tabIndex <= tlbTabs.Collection.Count; tabIndex++)
            {
                tlbTab = (EnvDTE80.ToolBoxTab2)tlbTabs.Collection.Item(tabIndex);
                if (tlbTab.Name.Equals(txtTabName.Text))
                {
                    tlbTab.Delete();
                    tabExists = false;
                    MessageBox.Show(txtTabName.Text + " successfully deleted from ToolBox.", "Remove toolbox entry", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }
            if (tabExists)
            {
                MessageBox.Show(txtTabName.Text + " does not exist in the ToolBox. Please remove entries manually.", "Remove toolbox entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        private void InstallTab(EnvDTE80.DTE2 dteObject)
        {
            ToolBox     tlBox   = null;
            ToolBoxTabs tbxTabs = null;
            ToolBoxTab2 tbxTab  = null;

            try {
                // Create an object reference to the IDE's ToolBox object and
                // its tabs.
                tlBox   = (ToolBox)(dteObject.Windows.Item(Constants.vsWindowKindToolbox).Object);
                tbxTabs = tlBox.ToolBoxTabs;

                bool tabExists = false;

                tlbTab = null;
                if (!tabExists)
                {
                    try {
                        // Add a new tab to the Toolbox and select it.
                        tbxTab = (ToolBoxTab2)tbxTabs.Add(txtTabName.Text);
                        tbxTab.Activate();
                    }
                    catch {
                        MessageBox.Show("An error occured during toolbox tab installation: Tab not created.", "Add Tab", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        btnAdd.Text = "&Finish";
                        return;
                    }


                    bool success = true;
                    assemblyName = Path.Combine(InstallPath, "Comzept.NetRix.Professional.UI.dll");
                    string error = "";
                    if (File.Exists(assemblyName))
                    {
                        tbxTabs.Item(txtTabName.Text).Activate();


                        tbxTabs.Item(txtTabName.Text).ToolBoxItems.Add(txtTabName.Text, assemblyName, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
                    }
                    else
                    {
                        success = false;
                        error  += "\nError description:\nPath (1) not found: " + assemblyName;
                    }

                    if (success)
                    {
                        MessageBox.Show(txtTabName.Text + " and selected controls successfully added to ToolBox.", "Add/Remove", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnAdd.Text = "&Next >";
                    }
                    else
                    {
                        MessageBox.Show("An error occured during installation: " + error, "Add/Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        btnAdd.Text = "&Finish";
                    }
                    Close();
                }
            } catch (System.Exception ex) {
                MessageBox.Show("An unexpected error occurred during installation:\n\n" + ex.Message, "Add/Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }