ContextMenu - interface definition + features
OK, so I've spent a bit more time thinking about how I want the interface for my Context menu to feel and, after quite a bit of poking around to learn about how others have designed controls with a fimiliar structure I have settled on this:
class ContextMenu : Control
{
public virtual string CommandName
public virtual ContextMenuItems Items
}
public sealed class ContextMenuItem
{
public virtual string Text
public virtual string ClientNotificationFunction
public virtual string CommandArgument
}
public sealed class ContextMenuItems : BaseCollection
{
}
class ContextMenuLink : Control
{
public virtual string ContextMenu
public virtual string ImageUrl
public virtual string Text
}
In designing the public interface for the ContextMenu types I've borrowed heavily from Framework designs and, probably more so from some of Andy Smith's great controls. Some of the ideas that I've "borrowed" from Andy on this project have come from his DialogWindow assemblies. To be concise, I've used his "best practices" methods of emitting and referencing client scripts and also used his example of using a custom TypeConverter on a property (refer his DialogOpenLink type) so that I can display a custom list of available ContextMenu's control id' s in the designer for the ContextMenu property of the ContextMenuLink type.
What all this allows me to do is to create any number of ContextMenuLink items and associate each one with a ContextMenu. The part that I haven't reached as yet is how get each ContextMenuLink to "seed" a ContextMenu with some "contextual" information about who called it. This would be useful in the case where you had a column of ContextMenuLink items in a DataGrid and you needed the resulting ContextMenu to have some stateful information about a data item in the row that was clicked on.
At my current rate of progress I should have something coded and ready to work in a page by the weekend, so, hopefully by mid-next week I should have the project and associate .chm documentation uploaded as a GotDotNet User Sample. I've got a couple of other server controls up on GotDotNet but this will be the first time that I've written one in VB.NET. I'll have to download the VBCodeCommenter so that I can generate the Xml files to generate my .chm file.