Hello,
I am preparing Actions framework in VB.NET for Windowd forms UI, each action should be connected to button/shortcut/control etc. Ussual application practice.
What I need is to have predefined definitions of actions like which I implement this solution for list:
public class BasicActionsDefinitions
Public shared CloseAction As New ActionDefinition("Close Action",Icon52)
public shared PrintAction As New ActionDefinition("Print me!",Icon52)
...
end class
There will be "categories of actions, like:"
I am implmenting interface to configure actions in GUI (form, buttons,shortcuts), so I can write smth like this:
myfrm.action(BasicActions.CloseAction).AttachComponent(Btn1)
myfrm.action(BasicActions.CloseAction).OnExecute(AdressOf MyMethod)
Do you have any other ideas how to represent lists of actionsdefinitions? Is use of shared memebers good solution? I was also thinking about:
ENUMS+attributes, ENUMS for actions names + and some class to get data like egtActionDefinition(actionEnum.printAction) , Dictionaries,etc, but this solutions with class looks like the best one.
Because
+ I can use inheritance, so I can define Class CommonActionsDefinitions and inherit from it do get some ussualy used actions
+ I can use dotted syntax in developement enviroment, so I dont have to acess actions like if I use list myfrm.addaction(actionsDefList("PrintAction")) - so the if action existance is checked by compiler. Thats nice.
+Another coprogrammer should easilly define their own custom actions, and use them-they just create new instance of ActionDefinition.
-Its seems impossible for me to define actions in DB, the only way would be to EMIT class with definitions. This is I think not very nice practice.
-Its hard to maintaing information, which actions are already defined for some Form class, if I use form inheritance.
- I cant use For Each to create operations for ALL actions - because every action is defined like property, and they are hard to enumerate without reflection!