本文介绍了动作定义列表,在VS中也可以直接从开发环境中获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在VB.NET中为Windowed Forms UI准备Actions框架,每个操作都应连接到按钮/快捷键/控件等.通常的应用实践.

我需要的是对动作进行预定义,例如我将实现此解决方案的列表:

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


将出现动作类别,例如:"


我正在使用界面来配置GUI中的动作(窗体,按钮,快捷方式),所以我可以这样写:


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)



您还有其他想法如何表示动作定义列表吗?使用共享成员是一个好的解决方案吗?我也在想:
ENUMS +属性,ENUMS用于动作名称+,以及一些类来获取数据,例如egtActionDefinition(actionEnum.printAction),Dictionary等,但是这种带有类的解决方案看起来是最好的.

因为
+我可以使用继承,所以我可以定义Class CommonActionsDefinitions并从中继承确实得到一些通常使用的动作
+我可以在开发环境中使用虚线语法,因此我不必执行诸如使用列表myfrm.addaction(actionsDefList("PrintAction"))之类的操作-因此,如果操作存在,则由编译器检查.很好.
+另一位协同程序员应该轻松定义自己的自定义动作,并使用它们-他们只是创建ActionDefinition的新实例.

-在我看来,在DB中定义动作似乎是不可能的,唯一的方法是使用定义来EMIT类.我认为这不是很好的做法.
-如果使用表单继承,则很难维护信息,对于某些Form类已经定义了哪些操作.
-我无法使用For Each来为所有操作创建操作-因为每个操作的定义都像属性一样,并且很难通过枚举来枚举!



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!

推荐答案


这篇关于动作定义列表,在VS中也可以直接从开发环境中获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 16:28