- UID
- 5280
- 积分
- 9466
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题:
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豆)
|
|