I am looking for an event on the UltraToolbarsManager Tools (ToolsCollection) that gives information about a new tool that is added to this collection.
In my application I want to store some information from the tool that is added in a cache. But unfortunatly the ToolsCollection or the UltraToolbarsManager doesn't have an acceptable event that give some information about the tool.
Furthermore I also need an event for ToolRemoved.
I hope someone can help me,Michael
The only event that will be fired when a tool is added or removed is the PropertyChanged event. The PropId on the ChangeInfo of the event args will be PropertyIds.Tools. When you receive this event with this PorpId, you can store the current tools in the list and the next time it is fired, you can compare the old tools with the tools currently in the list to see what was added or removed.
Hi Mike,
the reason is that the PropertyChanged event is raised very often, when I add and remove Tools dynamicly. Therefore I have a performance lack when I observe the collection each time.
Unfortunatly I need this for a workaround. The user want to show and hide the description for menuitems. Therefore I always have to cache the description value for each ButtonTool in the PropertyChanged method. When the user disables the "description for menus", I set all descriptions on the cached ButtonTools to null and when the user enables the "description on menu" I restore the descriptions from cache.
Is there an other posibility to reach this goal?
First of all, you can decrease the performance lack by only syncing up your collections when the leaf prop change info has a prop id of Tools (by calling FindTrigger(null) on the passed in prop change info). When the leaf item changed was the tools collection, an item was added or removed.
However, from what you need to accomplish, it is not necessary to cache tool instances. When the user changes the preference to show descriptions on menus, you can just iterate the root tools in the UltraToolbarsManager's Tools collection and set their SharedProps.DescriptionOnMenu to null or the desired value. If I am mistaken in assuming you are useing the DescriptionOnMenu, and you are instead putting descriptions in the captions for instance tools, you can still clear the captions on all instance tools by iterating the root tools collection. For each tool in the root tools collection, iterate the tools in its SharedProps.ToolInstances collection. This will contain every tool instance on each menu and toolbar where it exists.