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

            狠狠狠色丁香婷婷综合久久俺| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 色狠狠久久综合网| 国产精品久久久久久久人人看| 久久久久人妻一区二区三区| 97精品伊人久久大香线蕉app| 人人狠狠综合久久亚洲婷婷| 久久天天躁狠狠躁夜夜不卡| 中文无码久久精品| 国产精品青草久久久久婷婷 | 国产福利电影一区二区三区久久久久成人精品综合 | 久久久久久久久久久精品尤物| 亚洲国产精品无码久久久蜜芽| 久久久久夜夜夜精品国产| 欧美午夜精品久久久久久浪潮| 婷婷综合久久中文字幕蜜桃三电影 | 91久久精品国产91性色也| 四虎影视久久久免费| 国产精品18久久久久久vr| 欧美亚洲日本久久精品| 国内精品久久久久久99蜜桃 | 久久免费精品一区二区| 久久精品中文字幕一区| 26uuu久久五月天| 91精品国产综合久久精品| 模特私拍国产精品久久| 超级碰久久免费公开视频| 久久久久99精品成人片试看 | 久久久久一本毛久久久| 国产精品久久久久久福利漫画 | 精品伊人久久大线蕉色首页| 精品熟女少妇aⅴ免费久久| 成人久久精品一区二区三区| 久久综合88熟人妻| 亚洲国产精品一区二区久久hs| 久久久久婷婷| 无码任你躁久久久久久老妇| 久久精品视屏| 免费一级欧美大片久久网| 久久久久久久国产免费看| 久久精品国产精品亚洲下载 |