• <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
            數(shù)據(jù)加載中……

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

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





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


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            国产激情久久久久影院小草| 人人狠狠综合久久亚洲高清| 色综合久久无码中文字幕| 亚洲国产欧洲综合997久久| 久久久久高潮毛片免费全部播放| 精品久久久久久无码专区| 伊人久久大香线蕉精品| 狠狠色丁香久久婷婷综合蜜芽五月 | 人妻久久久一区二区三区| 久久精品国产精品亚洲精品 | 久久亚洲AV无码精品色午夜| 狼狼综合久久久久综合网| 精品久久久无码中文字幕| 久久久久亚洲精品日久生情 | 久久成人国产精品免费软件| 无码人妻久久一区二区三区免费| 亚洲精品国产成人99久久| 亚洲国产日韩欧美综合久久| 久久综合香蕉国产蜜臀AV| 久久久久久亚洲精品不卡| 久久久噜噜噜久久熟女AA片| 久久国产影院| 亚洲乱亚洲乱淫久久| 一本色道久久88精品综合| 欧美久久亚洲精品| 99久久综合国产精品二区| 久久久久久人妻无码| 热久久视久久精品18| 久久精品成人| 国内精品伊人久久久久影院对白| 996久久国产精品线观看| 国产成人久久精品一区二区三区| 污污内射久久一区二区欧美日韩 | 久久精品成人免费网站| 亚洲欧美成人综合久久久| 亚洲国产视频久久| 伊人久久大香线蕉成人| 亚洲伊人久久成综合人影院 | 久久91精品国产91久久小草| 香蕉久久夜色精品升级完成| 国产成人综合久久精品红 |