设为首页收藏本站

晓东CAD家园-论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 52|回复: 0

Define a localized command name in the .NET API

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-12 18:01:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

问题:
In ARX I can define both globalized and localized command name. Is there a similar way to define localized command name in the .Net API? Or should I simply define two command methods which call the same function?

解答:

There are a few signatures of CommandMethodAttribute that have a parameter of local command name id. For example:

CommandMethodAttribute(
System.String groupName,
System.String globalName,
System.String localizedNameId,
Autodesk.AutoCAD.Runtime.CommandFlags flags)

CommandMethodAttribute(
System.String groupName,
System.String globalName,
System.String localizedNameId,
Autodesk.AutoCAD.Runtime.CommandFlags flags,
System.String helpTopic)

CommandMethodAttribute(
System.String groupName,
System.String globalName,
System.String localizedNameId,
Autodesk.AutoCAD.Runtime.CommandFlags flags,
System.Type contextMenuExtensionType)

CommandMethodAttribute(
System.String groupName,
System.String globalName,
System.String localizedNameId,
Autodesk.AutoCAD.Runtime.CommandFlags flags,
System.Type contextMenuExtensionType,
System.String helpFileName,
System.String helpTopic)

This example uses the first signature to demonstrate how to use the parameter of localizedNameId:

    public class BzhCommands
    {
        [CommandMethod("CmdGroup", "TestCommand", "LocalNameID", CommandFlags.Transparent)]
        static public void testLocalCommandName()
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("\nTest command.");
        }
    }

The third parameter is a String ID pointing to a localized command name in a resource file embedded into the assembly dll. Please note that the key point is that the name of the resource file must be named after the command class.(BzhCommands in this example) Therefore the name of the resource file must be BzhCommands.resx. If the name of the resource file is incorrect, AutoCAD will reject to load the assembly dll though it can be compiled without errors.

The attached C# project defines a localized command name. (BzhTestCommand)

附件是完整工程:

CsTestLocalCmdName.zip (9.17 KB, 下载次数: 0, 售价: 30 D豆)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )  

GMT+8, 2021-1-22 08:20 , Processed in 0.057064 second(s), 15 queries , Gzip On, WinCache On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表