加入SD受管理的菜单,不加命令,只加资源,这里要注意的一点是
<
MenuItem
id
= "New"
label = "新建文件"
shortcut = "Control|N"
icon = "40"
class = "cxyBase.NewFileCommand" />
label = "新建文件"
shortcut = "Control|N"
icon = "40"
class = "cxyBase.NewFileCommand" />
Label: 显示在menustrip上的文件
shortcut: 调用这个命令的快捷键
icon: 显示在menustrip上的图标
class: Handle这个命令的class
<
MenuItem
id
= "File"
type = "Menu"
label = "${res:Demo.Menu.File}" >
type = "Menu"
label = "${res:Demo.Menu.File}" >
其中的label和ICON都放在资源文件中要在程序中注意一下,在写程序时,要在程序中显式地注册资源文件
ResourceService.RegisterNeutralImages(
new
ResourceManager(
"
cxySharp.iconres
"
, exe));
注意ResourceManager中的资源文件的写法,不要写错了
第二加入对每一个菜单的命令的支持
每一个命令都派生自AbstractCommand,我们要重写基类的Run函数
public
class
NewFileCommand:AbstractCommand
... {
public override void Run()
...{
MessageBox.Show("创建一个新文件");
}
}
... {
public override void Run()
...{
MessageBox.Show("创建一个新文件");
}
}
在完成每一个菜单项的命令后,我们在配置文件中加入菜单项命令所在的DLL
<Runtime>
<Import assembly = "../cxyBase.dll"/>
</Runtime>
assebmly="../cxyBase" 这里指出DLL文件是在父级文件夹中
第三步,加入对工具栏的支持,这些和菜单栏是相同的,所以就不在这里一一赘述了