Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1149
PopupMenuTool in UIExtensionSite
posted

Hi,

I'am stucking in a bad situation.
I'm developing a CAB application, using UIExtensionSite to accessing the Ribbon in distributed mode from any CAB module.
After registered a site:

MyWorkItem.UIExtensionSites.RegisterSite("SiteName", this.ultraToolbarsManager1.Ribbon.Tabs["tabKey"].Groups["groupKey"].Tools);

in a certain CAB module, I try to add toolbar tools present on another module. It is a kind of merge: when a module get displayed it need to merge its Ribbon tools on a main Ribbon.

All goes well, until I have to add a PopupMenuTool with its tools collection already filled.

I really don't know how to do it correctly.

In the specific case I have to add some ButtonTool in the PopupMenuTool, so I create this buttons, set their graphics property like images and their event handlers:

this.popupMenuTool.DropDownArrowStyle = DropDownArrowStyle.Segmented;
ButtonTool buttonTool1 = new ButtonTool("buttonTool1");
buttonTool1.SharedProps.AppearancesSmall.Appearance.Image = TilePanelWorkspaceResources.buttonTool1.ToBitmap();
buttonTool1.ToolClick +=new ToolClickEventHandler(buttonTool1_ToolClick);
ButtonTool buttonTool2 = new ButtonTool("buttonTool2");
buttonTool2.SharedProps.AppearancesSmall.Appearance.Image = TilePanelWorkspaceResources.ButtonTool2.ToBitmap();
buttonTool2.ToolClick +=new ToolClickEventHandler(buttonTool2_ToolClick);
ButtonTool buttonTool3 = new ButtonTool("buttonTool3 ");
buttonTool3.SharedProps.AppearancesSmall.Appearance.Image = TilePanelWorkspaceResources.buttonTool3.ToBitmap();
buttonTool3.ToolClick += new ToolClickEventHandler(buttonTool3_ToolClick);
ButtonTool buttonTool4 = new ButtonTool("buttonTool4");
buttonTool4.SharedProps.AppearancesSmall.Appearance.Image = TilePanelWorkspaceResources.buttonTool4.ToBitmap();
buttonTool4.ToolClick += new ToolClickEventHandler(buttonTool4_ToolClick);
this.popupMenuTool.Tools.AddRange(new ToolBase[] { buttonTool1,buttonTool2, buttonTool3, buttonTool4 } );


Then I Add this PopupMenuTool to the registered site:

this.RootWorkItem.UIExtensionSites[siteNameUIExt].Add(this.popupMenuTool);

What happen?

In the Ribbon I see correctly the PopupMenuTool with its buttons, but If I click these buttons nothing happen, events are not catched.

Please help me, any advices will be appreciated.

Thanks in advance

Gianni

Parents
No Data
Reply
  • 1149
    Verified Answer
    posted

    Hi all,

    I wasn't able to merge the PopupMenuTool with its tools, but I find a different way.
    What I have done is to create all tools that will be added to the PopupMenuTool as before, but do not add it to the PopupMenuTool.
    Then I registered the PopupMenuTool tools collection as UIExtensioneSite and added tools on that site in a public method :

    public void AddMyPopupMenuTools(string siteNameUIExt)
    {
    this.RootWorkItem.UIExtensionSites[siteNameUIExt].Add(this.myPopupMenu);
    if (!this.RootWorkItem.UIExtensionSites.Contains("ToolsCollectionSiteName"))
    this.RootWorkItem.UIExtensionSites.RegisterSite(ToolsCollectionSiteName, GetAdapter(this.RootWorkItem, this.myPopupMenuTool.Tools));
    this.RootWorkItem.UIExtensionSites["ToolsCollectionSiteName"].Add(this.buttonTool1);
    this.RootWorkItem.UIExtensionSites["ToolsCollectionSiteName"].Add(this.buttonTool2);
    this.RootWorkItem.UIExtensionSites["ToolsCollectionSiteName"].Add(this.buttonTool3);
    this.RootWorkItem.UIExtensionSites["ToolsCollectionSiteName"].Add(this.buttonTool4);
    }

    private IUIElementAdapter GetAdapter(WorkItem workItem, object item)
    {
    IUIElementAdapterFactoryCatalog adapterFactoryCatalog = workItem.Services.Get<IUIElementAdapterFactoryCatalog>();
    IUIElementAdapterFactory adapterFactory = adapterFactoryCatalog.GetFactory(item);
    IUIElementAdapter adapter = adapterFactory.GetAdapter(item);
    return adapter;
    }


    It's very hard to explain all the entire issue, but I think this problem could be very common in case you merge two ribbons using UIExtensionSites.

    Gianni

Children
No Data