• <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)  編輯 收藏 引用

            久久Av无码精品人妻系列| 久久免费高清视频| 久久免费视频网站| 亚洲综合精品香蕉久久网| 中文成人久久久久影院免费观看| 国产精品永久久久久久久久久| 久久综合中文字幕| 久久国产精品一区二区| 久久精品国产一区| 久久精品无码免费不卡| 亚洲а∨天堂久久精品9966| 亚洲一区精品伊人久久伊人| 午夜精品久久久久| 久久久无码精品亚洲日韩蜜臀浪潮| 色婷婷综合久久久久中文一区二区 | 国产精品成人精品久久久| 久久综合综合久久狠狠狠97色88| 国产福利电影一区二区三区久久久久成人精品综合 | 国产精品九九久久免费视频| 久久激情五月丁香伊人| 久久这里只精品99re66| 久久久噜噜噜www成人网| 久久97精品久久久久久久不卡| 成人国内精品久久久久影院VR| 欧美伊人久久大香线蕉综合69| 噜噜噜色噜噜噜久久| 久久精品国产清高在天天线| 九九久久精品无码专区| 亚洲中文字幕无码久久精品1| 国产精品久久久久久影院 | 久久久精品国产亚洲成人满18免费网站| 精品乱码久久久久久夜夜嗨| 久久久久国产精品嫩草影院| 久久电影网一区| 久久精品国产AV一区二区三区| 国产精品久久久久久福利69堂| 久久久久亚洲av成人无码电影 | 亚洲精品国产第一综合99久久| 国产成人精品久久二区二区| 一级做a爰片久久毛片毛片| 91精品婷婷国产综合久久|