Smart Client Software Factory:扩展工具栏,加入新视图(View)

首先在Module项目下的ModuleController.vb

这个ModuleController类在生成时有一个空方法

Private Sub ExtendToolStrip() 'TODO: add new items to the ToolStrip in the Shell. See the UIExtensionSites collection in the WorkItem. ' End Sub

从名字看就知道是扩展工具栏,因为SCSF主窗体的工具栏菜单是动态生成的,所以当我们需要有自己的工具栏时,要实现该方法.

第一步:首先在Constant文件夹下CommandNames.vb中定义几个常量

Namespace Constants ''' <summary> ''' Constants for command names. ''' </summary> Public Class CommandNames Inherits Infrastructure.Interface.Constants.CommandNames '********************************** Public Const AdminForm As String = "Administration" '********************************** Public Const EventLogForm As String = "Event Log" '********************************** End Class End Namespace

第二步:在基类WorkItemController中注册运行子窗体的函数

''' <summary> ''' Registers the launch point. ''' </summary> ''' <param name="text">The text.</param> ''' <param name="commandName">Name of the command.</param> ''' <param name="icon">The icon.</param> ''' <param name="hasAccess">if set to <c>true</c> [has access].</param> ''' <param name="siteName">Name of the site.</param> ''' <param name="toRegister">if set to <c>true</c> [to register].</param> Protected Sub RegisterLaunchPoint(ByVal text As String, ByVal commandName As String, Optional ByVal icon As Image = Nothing, Optional ByVal hasAccess As Boolean = True, Optional ByVal siteName As String = Constants.UIExtensionSiteNames.ModulesMenuItems, Optional ByVal toRegister As Boolean = False) Dim element As ToolStripMenuItem = New ToolStripMenuItem() 'ToolStripButton = New ToolStripButton() If Not icon Is Nothing Then element.Image = icon element.TextImageRelation = TextImageRelation.ImageBeforeText 'TextImageRelation.ImageAboveText element.ImageScaling = ToolStripItemImageScaling.None End If element.Text = text element.ToolTipText = text element.Enabled = hasAccess WorkItem.UIExtensionSites(siteName).Add(element) WorkItem.Commands(commandName).AddInvoker(element, "Click") End Sub

第三步:完成ModuleController类的ExtendToolStrip方法

Private Sub ExtendToolStrip() 'TODO: add new items to the ToolStrip in the Shell. See the UIExtensionSites collection in the WorkItem. 'See: ms-help://MS.VSCC.v90/MS.VSIPCC.v90/ms.practices.scsf.2008apr/SCSF/html/02-04-340-Showing_UIElements.htm 'Dim user As IUserSecurityService 'RegisterLaunchPoint(My.Resources.ModuleTitle, CommandNames.AdminForm, My.Resources.AdministrationIcon, IsAuthorize, siteName:=UIExtensionSiteNames.AdminModulesMenuItems) RegisterLaunchPoint(My.Resources.ModuleTitle, CommandNames.AdminForm, My.Resources.AdministrationIcon, True, siteName:=UIExtensionSiteNames.AdminModulesMenuItems) RegisterLaunchPoint(My.Resources.EventLogTitle, CommandNames.EventLogForm, My.Resources.i_info, IsAuthorize, siteName:=UIExtensionSiteNames.AdminModulesMenuItems) End Sub

基中UIExtensionSiteNames.AdminModulesMenuItems是定义的一个字符串常量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值