Community
Showing results for 
Search instead for 
Do you mean 
Reply

Regarding customization:

New Member
Posts: 8
Country: United States

Regarding customization:

Hi,

  I want to create a new menu in ACT containing one menu item.I have created code,but its not reflected in ACT.However its only a sample test code..to know whether a menu has been added or not.here is my code.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Act.Framework;
using Act.UI;
using Act.UI.Core;


namespace SampMenu
{
    class CustomMenuPlugin : IPlugin
    {
       public static void Main(string[] args)
        {
            string urn = "act-ui://com.act/application/menu/tools/custom";
            string text = "Custom";
            Act.UI.CommandHandler e = null;
            CustomMenuPlugin cus = new CustomMenuPlugin();
            cus.AddMenuItem(urn, text, e);

        }
       
        private const string CONNECTED_MENUBAR = "Connected Menus";
        private const string DISCONNECTED_MENUBAR = "Disconnected Menus";

        private const string CUSTOM_MENU_URN = "act-ui://com.act/application/menu/tools/custom";
        private const string CUSTOM_MENU_TEXT = "Custom";
        Boolean hasSepartor = false;

        public ActApplication application;

 

        private void DoStuff(string command)
        {
           
        }

 


        public void AddMenuItem(string urn, string text, Act.UI.CommandHandler Handler)
        {
            try
            {
                if (MenuItemExists(urn) == true)
                {
                    RemoveMenuItem(urn);
                }
                Act.UI.Core.CommandBarControl parentMenu = this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[GetParentControlURN(urn)];
                Act.UI.Core.CommandBarButton newMenu = new Act.UI.Core.CommandBarButton(CUSTOM_MENU_TEXT, "", null, "", "",
        Act.UI.Core.CommandBarControl.ItemDisplayStyle.TextOnly, hasSepartor);


                newMenu.DisplayStyle = Act.UI.Core.CommandBarControl.ItemDisplayStyle.TextOnly;
                this.application.RegisterCommand(urn, new Act.UI.CommandHandler(Handler), Act.UI.RegisterType.Shell);
                parentMenu.AddSubItem(newMenu);
            }
            catch { }
        }

        private void RemoveMenuItem(string urn)
        {
            try
            {
                this.application.RevokeCommand(urn);
                Act.UI.Core.CommandBarControl RemoveMenu = this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[urn];
                this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[GetParentControlURN(urn)].RemoveSubItem(RemoveMenu);
            }
            catch { }
        }

        private bool MenuItemExists(string urn)
        {
            return (application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[urn] != null);
        }

        private string GetParentControlURN(string urn)
        {
            return urn.Substring(0, urn.LastIndexOf("/"));
        }

        void IPlugin.OnLoad(ActApplication application)
        {
            // hold on to the application
            this.application = application;
        }

        void IPlugin.OnUnLoad()
        {
        }
    }
}

I have added references clearly also i added the dll in the plugins folder in ACT.but its not working.help me.

 

with Thanks and regards,

S.K

Copper Contributor
Posts: 98
Country: United States

Re: Regarding customization:

[ Edited ]

It's possible that your plugin is not loading due to it being listed in the dependentdlls.xml file.

 

Try this: http://community.act.com/t5/Xavier-s-Blog/My-Add-on-No-Longer-Works-What-Now/ba-p/135#A9

 

Hope this helps,

Message Edited by Carlton_Jones on 02-23-2009 05:39 PM
Carlton Jones
Sage Software