• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Life is Good.

            Enhance Tech and English
            隨筆 - 65, 文章 - 20, 評論 - 21, 引用 - 0
            數據加載中……

            AutoCAD: 通過修改CUI 添加鼠標右鍵 (一級菜單)(.NET)

            AddDefaultContextMenuExtension 只能添加2級目錄的菜單,如果想添加一級目錄菜單像AddObjectContextMenuExtension 添加的那樣, 就必須通過修改CUI 來實現.





            using System;
            using Autodesk.AutoCAD.Runtime;
            using Autodesk.AutoCAD.ApplicationServices;
            using Autodesk.AutoCAD.EditorInput;
            using Autodesk.AutoCAD.DatabaseServices;
            using Autodesk.AutoCAD.Customization;

            [assembly: CommandClass(
            typeof(CuiTest.ADSKCommands))]

            namespace CuiTest
            {
                
            /// <summary>
                
            /// Summary description for ADSKCommands.
                
            /// </summary>
                public class ADSKCommands
                {
                    
            private string strMacroGroup = "mxMenuGroups";
                    
            private CustomizationSection cs;
                    
            private Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

                    
            public ADSKCommands()
                    {
                        
            // retrieve the location of, and open the ACAD Main CUI File
                        string mainCuiFile = (string)Application.GetSystemVariable("MENUNAME");
                        mainCuiFile 
            += ".cui";
                        cs 
            = new CustomizationSection(mainCuiFile);
                    }

                    [CommandMethod(
            "Add")]
                    
            public void Add() // This method can have any name
                    {
                        
            // First to create a MacroGroup and MenuMacro 
                        MacroGroup oMacroGroup = new MacroGroup(strMacroGroup, cs.MenuGroup);
                        MenuMacro oMenuMacro 
            = new MenuMacro(oMacroGroup, "CuiTestMacro""ABC""CuiTestMacro", MacroType.Any);

                        
            // Get the DEFAULT PopMenu
                        PopMenu defaultMenu = cs.MenuGroup.PopMenus.FindPopWithAlias("POP501");
                        PopMenuItem pmi 
            = new PopMenuItem(defaultMenu, 2); 
                        pmi.MacroID 
            = oMenuMacro.ElementID;
                        pmi.Name 
            = "ABC";

                        
            // Add a Separator
                        pmi = new PopMenuItem(defaultMenu, 3); // Separator

                        SaveCui();
                    }

                    [CommandMethod(
            "Remove")]
                    
            public void Remove() // This method can have any name
                    {

                        MacroGroupCollection macroList 
            = cs.MenuGroup.MacroGroups;
                        
            for (int index = 0; index < macroList.Count; index++ )
                        {
                            
            if (macroList[index].Name.Equals(strMacroGroup, StringComparison.CurrentCultureIgnoreCase))
                            {
                                macroList.Remove(index);
                                
            break;
                            }
                        }

                        PopMenu pm 
            = cs.MenuGroup.PopMenus.FindPopWithAlias("POP501");
                        
            if (pm != null)
                        {
                            PopMenuItemCollection pmList 
            = pm.PopMenuItems;
                            
            int index = 0;
                            
            bool bFound = false;
                            
            foreach (PopMenuItem item in pmList)
                           {
                               
            if (!item.IsSeparator && item.Name == "ABC")
                               {
                                   pmList.Remove(item);
                                   bFound 
            = true;
                               }
                               
            // Remove the follow Separator
                                if (bFound &&  ((PopMenuItem)pmList[index]).IsSeparator)
                                {
                                    pmList.RemoveAt(index);
                                    
            break;
                                }
                               
                               index 
            ++;
                           }
                        }

                        SaveCui();
                    }

                    [CommandMethod(
            "ABC")]
                    
            public void abc() // This method can have any name
                    {
                        ed.WriteMessage(
            "\n Hello");
                    }

                    [CommandMethod(
            "Savecui")]
                    
            public void SaveCui()
                    {
                        
            // Save all Changes made to the CUI file in this session. 
                        
            // If changes were made to the Main CUI file - save it
                        
            // If changes were made to teh Partial CUI files need to save them too

                        
            if (cs.IsModified)
                            cs.Save();

                        
            // Here we unload and reload the main CUI file so the changes to the CUI file could take effect immediately.
                        string flName = cs.CUIFileBaseName;
                        Application.SetSystemVariable(
            "FILEDIA"0);
                        Application.DocumentManager.MdiActiveDocument.SendStringToExecute(
            "cuiunload " + flName + " "falsefalsefalse);
                        Application.DocumentManager.MdiActiveDocument.SendStringToExecute(
            "cuiload " + flName + " filedia 1 "falsefalsefalse);
                    }

                }
            }

            posted on 2010-06-12 22:16 Mike Song 閱讀(1353) 評論(0)  編輯 收藏 引用

            亚洲va中文字幕无码久久不卡| 好属妞这里只有精品久久| 蜜臀久久99精品久久久久久| 人妻系列无码专区久久五月天| 婷婷久久五月天| 久久综合丝袜日本网| 欧美精品九九99久久在观看| 久久丫精品国产亚洲av不卡| 久久一区二区三区免费| 97热久久免费频精品99| 伊人久久大香线蕉精品不卡| 久久国产精品成人免费| 久久免费看黄a级毛片| 国产精品亚洲美女久久久| 久久夜色精品国产噜噜麻豆| 久久综合久久鬼色| 婷婷久久综合九色综合98| 国产亚洲精品久久久久秋霞| 久久亚洲欧洲国产综合| 狠狠色丁香婷综合久久| 嫩草伊人久久精品少妇AV| 亚洲人成无码www久久久| 国产精品免费久久| 国内精品久久国产大陆| 久久99国产综合精品| 久久久久久午夜成人影院| 四虎国产精品成人免费久久| 久久精品成人影院| 九九久久精品国产| 久久影院午夜理论片无码| 久久青青草原亚洲av无码| 久久996热精品xxxx| 国产精品欧美亚洲韩国日本久久| 7777久久亚洲中文字幕| 国产成人精品久久二区二区| 97久久超碰国产精品2021| 东京热TOKYO综合久久精品 | 久久―日本道色综合久久| 久久97精品久久久久久久不卡| 狠狠色婷婷综合天天久久丁香 | 国产国产成人久久精品|