Hello,I'm trying to create a ToolBar based on UltraToolbarsManager.I want be able to add some pre defined tools which can be displayed or not.My problem: The UltraToolbarsManager is a component and has no OnPaint method that I can override - so my question: How to do this?
public class Toolbar: UltraToolbarsManager { public PredefinedTools ToolsPredefined { get; private set; } public Toolbar2() { this.ToolsPredefined = new PredefinedTools(); }
protected override void OnPaint(PaintEventArgs e) //will not work, because of no method to override { base.OnPaint(e); if (ToolsPredefined.New) Tools.Add(new ButtonTool("New")) } } [TypeConverter(typeof(ExpandableObjectConverter))] public class PredefinedTools { public bool New { get; set; } public bool Delete { get; set; } }
Thank you for support!
If you want to use this run-time verification of making sure certain tools exist, I would not try to also get the design-time support working. It sounds like you have custom needs for your toolbars which are not supported and which conflict with the design-time support for toolbars.
That's right, thought about this before - but then the person how is designing has no designtime support for the predefined tools, this means he will not see them on the toolbar.My desire: Adding my predefined tools to the tools collection in an inherted toolbar (e.g. in ctor of MyToolbar). This works insofa that at designtime I can choose these tools and put it to any toolbar - so I can choose which predefined tools are visible or not, change order on toolbar, change image, etc. .The Problem: The form serializes this toolbar and tools to it's [form].designer.cs which means my scenario ends up in a "key already exists exception". The reason: MyToolbar is initialized by the [forms].designer.cs and my predefined tools are generated at ctor of MyToolbar. After this, the [form].designer.cs initializes the serialized tools and trys to add these tools to MyToolbar => tool exists already => exception is thrown.
Is there any solution for me with designtime support?
I would recommend going with the second approach, but having a central helper method which takes an UltraToolbar and creates and adds the tools to it. That way, if you decide to change images or add more pre-defined tools later, you just have to update that one method.
I want to use a "base toolbar" which I want to place on several forms. This toolbar should provide some pre-configurated tools, so the user (the person who designs the form) can activate these tools or not (show them on toolbar or not). One tool should e.g. "New". This means, if the person who designs is setting the property "New" to true, he will get a tool which is pre-configurated from me - this means, he get's a tool with an image, text, maybe some other appereance that I've set - and this tool will look an all forms the same.
The alternative to this is: Put a toolbarsmanager from Infragistics to each form and insert into each toolbar a new tool and set all proprties to the same value. If you want to change to image of a tool, you have to do this several times.
I'm not really sure what you are trying to accomplish here. Are you trying to enforce that a few tools are present at all times regardless of the customizations made by the user?