首页 > 编程语言 >Aveva Marine VBNET 编程系列-修改程序快捷键

Aveva Marine VBNET 编程系列-修改程序快捷键

时间:2023-09-28 21:44:39浏览次数:47  
标签:Dim End ButtonToolImpl Aveva 快捷键 item cbm VBNET

修改HullDesign程序的主题以及菜单项的快捷键

 

引用的dll文件

下面的是代码和快捷键配置文件:

https://files.cnblogs.com/files/NanShengBlogs/AMShortCut.HullDesign.zip?t=1695908179&download=true

Imports Aveva.ApplicationFramework.Presentation
Imports Aveva.ApplicationFramework
Imports System.IO
Imports System.Reflection
Imports System.Windows.Forms
Imports System.Linq

Public Class 控制程序界面
    <MyAmFunctionAtt(NameOf(控制程序界面), NameOf(修改命令快捷键))>
    Sub 修改命令快捷键(wm As WindowManager)
        Dim cbm As CommandBarManager = CommandBarManager.Instance
        Dim mainMenus As CommandBar = cbm.MenuBar
        Dim btns As New List(Of ButtonToolImpl)
        cbm.AllowCustomization = True
        cbm.BeginUpdate()
        Dim item As ITool
        Try
            For Each item In mainMenus.Tools
                If TypeOf item Is MenuToolImpl Then
                    btns.AddRange(GetButtonImpls(CType(item, MenuToolImpl)))
                End If
            Next
            Dim fi As New FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                            "AMShortCut.HullDesign.csv"))
            If Not fi.Exists Then
                MsgBox("找不到快捷键配置文件:" & fi.FullName)
            Else
                Dim cmds As String() = File.ReadAllLines(fi.FullName)
                Dim i As Integer
                For i = 1 To cmds.Length - 1
                    Dim separator As String() = New String() {","}
                    Dim cmdStrs As String() = cmds(i).Split(separator, StringSplitOptions.RemoveEmptyEntries)
                    If (cmdStrs(1).ToLower = "true") Then
                        Dim curCmd As ButtonToolImpl = btns.FirstOrDefault(Function(b) b.Key = cmdStrs.First())
                        If (curCmd IsNot Nothing) Then
                            Dim shortcutStr = cmdStrs.Last().ToUpper()
                            Dim targetShortCut As Shortcut = CType([Enum].Parse(GetType(Shortcut), shortcutStr, True), Shortcut)
                            If (targetShortCut <> Shortcut.None) Then
                                curCmd.Shortcut = targetShortCut
                                curCmd.Visible = True
                            Else
                                wm.StatusBar.Text = shortcutStr
                            End If
                        End If
                    End If
                Next i
                cbm.Style = CommandBarStyle.ScenicRibbon
                cbm.SaveLayout()
                cbm.EndUpdate(True)
                MsgBox("快捷键配置完成!")
            End If
        Catch ex As Exception
            MsgBox(ex.StackTrace)
        End Try

    End Sub

    Public Shared Function GetButtonImpls(ByVal mtl As MenuToolImpl) As List(Of ButtonToolImpl)
        Dim rtns As New List(Of ButtonToolImpl)
        Dim item As ITool
        For Each item In mtl.Tools
            If TypeOf item Is MenuToolImpl Then
                Dim btns As List(Of ButtonToolImpl) = GetButtonImpls(TryCast(item, MenuToolImpl))
                If (btns.Count > 0) Then
                    rtns.AddRange(btns)
                End If
            ElseIf TypeOf item Is ButtonToolImpl Then
                rtns.Add(TryCast(item, ButtonToolImpl))
            End If
        Next
        Return rtns
    End Function

End Class

 

标签:Dim,End,ButtonToolImpl,Aveva,快捷键,item,cbm,VBNET
From: https://www.cnblogs.com/NanShengBlogs/p/17736538.html

相关文章

  • IDEA常用快捷键
    Alt+Home:查看类的结构信息;Alt+Enter:补全new对象;Alt+Insert:获取get与set方法;Alt+7:在窗口显示当前类的结构(所有方法);Ctrl +F12以弹窗列出该类所有的方法定义;Ctr|+Alt+V:接收调用方法的返回值(调用方法的时候,如果方法有明确的返回值,我们用变量接收可以手动完......
  • Aveva Marine VBNET 编程系列-搭建开发框架
    引用的DllAveva.ApplicationFramework.dllAveva.ApplicationFramework.Presentation菜单展示效果创建Attribute,用于反射来动态创建菜单,不用每次都去写commandPublicClassMyAmFunctionAttInheritsAttributePrivate_menuNameAsStringPublicPropertyM......
  • mac中wps常用快捷键
    mac中wps常用快捷键一、文字处理快捷键1、command+N  新建文档2、command+O  打开文档  3、command+S  保存文档4、command+W  关闭文档5、command+Z  撤销  6、shift+command+N  重做 二、样式格式快捷键1、command+B  ......
  • VBNET AUTOCAD 单行文字OBB有向包围盒的计算
    遇到要求单行文字包围和的需求,发现AutoCAD自带的算法仅能求出正交包围盒,如下图所示的粉色矩形我想获取下图下图所示蓝色矩形的部分及OBB计算方法图形示例:下面是完整的代码,其中求D点的坐标p1涉及到向量定比分点公式<CommandMethod(NameOf(TT_SingleTextOBB))>SubTT......
  • Idea 的 Ctrl + Shift + F 快捷键失效
    失效的原因:是因为和搜狗输入法的"简繁"切换的快捷键冲突了解决方案:设置搜狗输入法的"简繁"快捷键,把"简繁"快捷键换成其他,不要用Ctrl+Shift+F......
  • Visual Studio 2022快捷键
    向上新增一行并跳转:ctrl+Enter向下新增一行并跳转:ctrl+shift+Enter跳到行首:home跳到行尾:end按词移动:Ctrl+ →按词移动:Ctrl+←选中行首到光标之间的代码:shift+home选中行尾到光标之间的代码:shift+end折叠/展开代码:ctrl+m+m[只对函数起作用]调用智能提示:ctrl+j......
  • IDEA常用快捷键大全
    IDEA常用快捷键大全IDEA开发常用的快捷键:快捷键组合实现效果psvm+Tab键/main+Tab键publicstaticvoidmain(String[]args)sout+Tab键System.out.println()Ctrl+X删除当前行Ctrl+D复制当前行Alt+Insert(或右键Generate)生成代码(如get,se......
  • flutter常用的快捷键 mac
    备注:windows的Alt相当于mac的option 1.stless快速创建StatelessWidget、stful就快速创建StatefulWidget。2.option+Enter可以单击选中任何一个widget,然后按Alt+Enter,就可以查看对该widget进行特定的操作:2.1.替换statelessWidget为statefulWidget按下Alt+Enter,......
  • VsCode常用快捷键记录
    取消撤销Win:ctrl+yMac:shift+command+z全局搜索Win:shift+ctrl+fMac:shift+command+f向上/向下复制当前行Win:shift+alt+up/downMac:shift+option+up/down代码格式化Win:shift+alt+fMac:shift+option+f列选择(垂直选中)快捷......
  • 快捷键
    快捷键基本F1显示器设置F2重命名F12一键打开多个项目prtscr(F12右边)截图END显示当前窗口的底端Home显示当前窗口的顶端组合常用Ctrl+A全选Ctrl+C复制Ctrl+X剪切Ctrl+V粘贴Ctrl+Z撤消Ctrl+Y撤消“撤销”Ctrl+S保存Alt+F4关闭当前项目Windows+Shift+......