• <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 閱讀(1347) 評論(0)  編輯 收藏 引用

            久久久免费观成人影院| 久久久久久国产a免费观看黄色大片 | 国产成人精品久久亚洲| 国产精品久久久久久久久鸭 | 97久久国产综合精品女不卡| 久久免费视频1| aaa级精品久久久国产片| 久久综合视频网站| 无码人妻少妇久久中文字幕蜜桃 | 开心久久婷婷综合中文字幕| 三上悠亚久久精品| 久久久久黑人强伦姧人妻| 色综合久久无码中文字幕| 7国产欧美日韩综合天堂中文久久久久 | 97精品国产97久久久久久免费| 久久久精品午夜免费不卡| 色天使久久综合网天天| 国产精品视频久久久| 99精品国产综合久久久久五月天| 久久国产精品国语对白| 久久青青草原精品国产| 亚洲欧洲久久av| 亚洲精品无码久久久| 国产午夜精品久久久久九九| 久久久亚洲欧洲日产国码二区 | 国产精自产拍久久久久久蜜 | 久久高潮一级毛片免费| 久久精品国产色蜜蜜麻豆| 久久久受www免费人成| 丁香久久婷婷国产午夜视频| 久久99精品久久久久久hb无码 | 久久大香香蕉国产| 亚洲αv久久久噜噜噜噜噜| 久久青青色综合| 伊人久久大香线蕉精品不卡| 久久青青草原亚洲av无码| 久久精品国产一区二区| 91亚洲国产成人久久精品网址 | 人妻精品久久无码区| 色欲综合久久中文字幕网| 狠狠色丁香久久婷婷综合|