1. [assembly: CommandClass(typeof(test.Class1))]
    2. namespace test
    3. {
    4. public class Class1
    5. {
    6. [CommandMethod("TT", CommandFlags.Session | CommandFlags.UsePickSet)]
    7. public static void TT()
    8. {
    9. HookLib.ShowForm("Form1");
    10. }
    11. }
    12. }
    13. //str为窗体名,除了命名空间字符串外,所有的字符串。
    14. //如果窗体的全路径为:test1.test2.test3.test4.Form1,则str为:test2.test3.test4.Form1
    15. public static void ShowForm(string str)
    16. {
    17. if (Frm == null || Frm.IsDisposed)
    18. {
    19. Assembly assembly = Assembly.GetExecutingAssembly();
    20. Frm = assembly.CreateInstance($"{MethodBase.GetCurrentMethod().DeclaringType.Namespace}.{str}") as Form;
    21. size = new Size(400, 400);
    22. ZwSoft.ZwCAD.ApplicationServices.Application.ShowModelessDialog(Frm);
    23. CmdRegisterHook();
    24. }
    25. else Frm.Show();
    26. }