Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
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:
VB
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!
Posted
Updated 16-Nov-11 23:53pm
v3
Comments
Sergey Alexandrovich Kryukov 16-Nov-11 13:12pm    
Yes, this is a usual and good practice, but first, specify your UI library. WPF, Forms, ASP.NET, what?
--SA
sudancer 18-Nov-11 17:12pm    
Windows forms..

1 solution

Sorry. My UI library is windows forms.
Thank you for your reply.
 
Share this answer
 
Comments
André Kraak 17-Nov-11 6:08am    
Please do not post a comment as a solution. Use the Reply button next to the comment you want to respond to. Using an solution like this will give the people the impression that your question has been answered and perhaps not look at it, causing you not to get an answer to your question.

Please move the content of this solution to the comment you want to reply to and remove the solution. Thank you.
sudancer 18-Nov-11 16:02pm    
Sorry. This was my first question, I have not seen the button.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900