CAD right pop-up menu (com Interface)

Users need to right pop-up menu, you need to respond to mouse events, after pressing the right button, the pop-up menu is divided into operation and run in non-command at the command, (C # Language Reference examples are detailed below: "samples \ CSharpRightKeyMenu \ CSharpRightKeyMenu.sln" ):


1, the new menu file


A new text file: mxpoptest.mnu, reads as follows (this file is run from a command menu):


// menu bar header description.
// "file type string" "resource file name" "Transparent Color" "position, which can be: top, left, bottom, right"
"MxDrawMenuBarFile" "MxDraw.dll" (214 211 206) "top" "pop-up menu 2"

// Menu Description
// "command name" "order" "icon index string" "resource file name" "Command Prompt string" "command ID" "ID type" "is a command function in front of execution."
"POPMENUS" "对象(&O)"
"确定" "" "" "" "确定" "" "ID_OK_BUTTON"
//"取消" "" "" "" "取消" "" "ID_CANCLE_BUTTON"
"关键字" "" "" "" "关键字" "" "ID_KEYWORD_BUTTON"
"SEPARATOR"
"Test(&E)" "Test" "" "" "编辑文字" "55" "" "Y"
"POPMENUE"


Keyword here is the command-line prompt command.


A new text file: MxPopMenuEnt.mnu, reads as follows (this file is in a non-entity command to run click menu):


// menu bar header description.
// "file type string" "resource file name" "Transparent Color" "position, which can be: top, left, bottom, right"
"MxDrawMenuBarFile" "MxDraw.dll" (214 211 206) "top" "pop-up menu 2"

// Menu Description
// "command name" "order" "icon index string" "resource file name" "Command Prompt string" "command ID" "ID type" 
"POPMENUS" "对象(&O)"
"删除(&E)"     "_Erase" "IDB_ERASE_BITMAP"
"复制(&Y)"     "_Copy" "IDB_COPY_BITMAP"
"移动(&V)"     "_Move" "IDB_MOVE_BITMAP"
"旋转(&R)"     "_Rotation" "IDB_ROTATION_BITMAP"
"缩放(&L)"     "_Scale" "IDB_SCALE_BITMAP"
"SEPARATOR"
"对象特性(&O)" "Mx_ShowProperties" "IDB_PROPERTY_BITMAP" "PropertyEditor.mrx"
"SEPARATOR"
"用户自加命令(&U)"     "" "" "" "" "99"
"POPMENUE"


A new text file: MxPopMenu.mnu, reads as follows (this file is run in a non-entity command no right-click menu):


// menu bar header description.
// "file type string" "resource file name" "Transparent Color" "position, which can be: top, left, bottom, right"
"MxDrawMenuBarFile" "MxDraw.dll" (214 211 206) "top" "pop-up menu 1"

// Menu Description
// "command name" "order" "icon index string" "resource file name" "Command Prompt string" "command ID" "ID type" 
"POPMENUS" "pop-up menu 1 (& V)"
"新建(&N)" "Mx_New" "IDB_NEW_BITMAP" "MxEdit.mrx" "" "" "ID_NEW_BUTTOM"
"打开(&O)" "Mx_OpenMxg" "IDB_OPENMXG_BITMAP" "" "" "" "ID_OPEN_BUTTOM"
"重画(&R)" "Re" "IDB_REGEN_BITMAP"
"SEPARATOR"
"Real-time scaling (& Z)" "ZoomR" "IDB_ZOOM_BITMAP"
"SEPARATOR"
"上一步" "ZoomP" "ID_PRVVIEW_BITMAP"
"Zoom Window (& W)" "WindowZoom" "IDB_ZOOMW_BITMAP"
"Zoom range (& E)" "ZoomE" "IDB_ZOOME_BITMAP"
"Viewport translation (& P)" "P" "IDB_PAN_BITMAP"
"视区旋转(&L)" "Mx_Plan" "IDB_PLAN_BITMAP" "MxEdit.mrx"
"SEPARATOR"
"鸟瞰(&D)" "DsViewer" "IDB_DSVIEWER_BITMAP"
"放大镜(&M)" "MagnifyingGlass" "IDB_MAGNIFYINGCLASS_BITMAP"
"SEPARATOR"
"视区背景色(&C)" "_ViewColor" "IDB_VIEWCOLOR_BITMAP"
"线重(&S)" "_ShowLineWeight" "IDB_LINEWEIGHT_BITMAP"
"绘图模式(&A)" "_DrawModle" "IDB_DRAWMODLE_BITMAP"
"全屏显示(&F)" "MxFullScreen" "IDB_FULLSCREEN_BITMAP"
"SEPARATOR"
"User Coordinate System (& U)" "Mx_Ucs" "IDB_UCS_BITMAP" "MxEdit.mrx"

"POPMENUE"


The first line is a file menu file header, each column as follows:


File type string Resource file name (the default menu icon behind the load from the dll) Transparent Color icon position Menu name
"MxDrawMenuBarFile" "MxDraw.dll" (214 211 206) "top" "Pop-up menu"


"//" are comments in the file

File after each line represents a menu item

"POPMENUS" "Object (& O)", represents the beginning of a pop-up menu

"POPMENUE" represents the end of the pop-up menu

"SEPARATOR" represents the dividing line of the pop-up menu


Behind the content of each column is as follows:


Command Name Click the command execution Icon Index string Resource file name Command prompt string "Command ID" Type ID (internal control is currently used, is generally empty)
"New (& N)" Mx_New "IDB_NEW_BITMAP" "" "" "" ""


Command name:


New (& N).


Click the command:


C ++ uses acedRegCmds-> addCommand registration command.

Other languages ​​use DMxDrawX :: RegistUserCustomCommand registration command.


Icon Index string:


IDB_NEW_BITMAP。


Resources File Name:


1. Take an empty default resource file name, the name of the need to remove the control version number such as: MxDraw52.dll written MxDraw.dll, the controls will be added to this version depending on the circumstances.

2. The resource file the case of local: the beginning, local representation is a bmp file, such as: do take mytoolbar.bmp tool button icons: local: mytoolbar.bmp

     For example: the menu icon, from a local bmp file:

     "自定义新建(&N)" "Mx_New" "IDB_NEW_BITMAP" "local:mytoolbar.bmp"

3. The resource file the case web: beginning, represents a bmp file on a network server, such as: do take mytoolbar.bmp tool button icons: web: mytoolbar.bmp

      For example: the menu icon to load a file from the server bmp, bmp files and menu files in the same directory server:

      "自定义新建(&N)" "Mx_New" "IDB_NEW_BITMAP" "web:mytoolbar.bmp"


String command prompt:


Is empty.


Command ID:


Command event id specified response click the menu, if not empty, you can click on the menu in response to events in the implementation of CAD commands control's event: ImplementCommandEvent.


ID Type:


Currently the use of CAD internal controls, usually empty.


2, right-mouse response events, pop-up menu


The main use of Function:


_DMxDrawX::TrackPopupMenu


A pop-up menu at the specified location. Details are as follows:


parameter Explanation

DOUBLE dX

Position X value pop-up menu, is a document coordinates

DOUBLE dY

Position Y value pop-up menu, is a document coordinates

sMenuFile

Menu definition files, support network path beginning with http


        private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
        {
            if (e.lType == 3)
            {
                // Right Press
                string sCmd = ""  ;
                if (axMxDrawX1.IsRuningCommand(ref sCmd))
                {
                    // run the command.
                    String sMenu = axMxDrawX1.GetOcxAppPath() + "\\mxpoptest.mnu";
                    axMxDrawX1.TrackPopupMenu (e.dX, e.dY, sMain);
                    // Set 1, the mouse events, no longer passed down.
                    axMxDrawX1.SetEventRet (1);

                }
                else
                {
                    // run under non-command
                    MxDrawXLib.MxDrawResbuf filter = new MxDrawXLib.MxDrawResbuf();
                    MxDrawXLib.MxDrawEntity ent = (MxDrawXLib.MxDrawEntity)axMxDrawX1.FindEntAtPoint(e.dX, e.dY, filter);

                    String sPopMenu;
                    if(ent != null)
                    {
                        axMxDrawX1.ClearCurrentSelect();
                        axMxDrawX1.AddCurrentSelect(ent.ObjectID,true,true);

                        sPopMenu = axMxDrawX1.GetOcxAppPath() + "\\MxPopMenuEnt.mnu";
                    }
                    else
                    {
                        sPopMenu = axMxDrawX1.GetOcxAppPath() + "\\MxPopMenu.mnu";
                    }


                    axMxDrawX1.TrackPopupMenu (e.dX, e.dY, sPopMenu);
                    // Set 1, the mouse events, no longer passed down.
                    axMxDrawX1.SetEventRet (1);
                }

            }
        }


3, incident response command, as follows:


 private void axMxDrawX1_ImplementCommandEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_ImplementCommandEventEvent e)
        {
            if(e.iCommandId == 99)
            {
                MessageBox.Show ( "user-defined command ....");
            }
            
         }

Guess you like

Origin www.cnblogs.com/yzy0224/p/11095765.html