Esempio n. 1
0
        // ArcGIS Snippet Title:
        // Create Context Menu
        //
        // Long Description:
        // Create a context or popup menu dynamically using some default command items.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        // ESRI.ArcGIS.SystemUI
        // System
        // System.Drawing
        // System.Windows.Forms
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView)
        //
        // Applicable ArcGIS Product Versions:
        // 9.2
        // 9.3
        // 9.3.1
        // 10.0
        //
        // Required ArcGIS Extensions:
        // (NONE)
        //
        // Notes:
        // This snippet is intended to be inserted at the base level of a Class.
        // It is not intended to be nested within an existing Method.
        //

        ///<summary>Create a context or popup menu dynamically using some default command items.</summary>
        ///
        ///<param name="application">An IApplication Interface.</param>
        ///
        ///<remarks>Three default command items are added to the ContextMenu. Change the CLSID or ProgID as necessary for your specific command items.</remarks>
        public void CreateContextMenu(ESRI.ArcGIS.Framework.IApplication application)
        {
            ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
            ESRI.ArcGIS.Framework.ICommandBar  commandBar  = commandBars.Create("TemporaryContextMenu", ESRI.ArcGIS.SystemUI.esriCmdBarType.esriCmdBarTypeShortcutMenu);

            System.Object optionalIndex    = System.Type.Missing;
            ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass();

            uid.Value   = "ROI.ContextMenuItems.ShowForm"; // Can use CLSID or ProgID
            uid.SubType = 0;
            commandBar.Add(uid, ref optionalIndex);

            uid.Value   = "ROI.ContextMenuItems.ClearGraphics.ClearGraphics"; // Can use CLSID or ProgID
            uid.SubType = 0;
            commandBar.Add(uid, ref optionalIndex);

            //uid.Value = "{FBF8C3FB-0480-11D2-8D21-080009EE4E51}"; // Can use CLSID or ProgID
            //uid.SubType = 1;
            //commandBar.Add(uid, ref optionalIndex);

            //uid.Value = "{FBF8C3FB-0480-11D2-8D21-080009EE4E51}"; // Can use CLSID or ProgID
            //uid.SubType = 2;
            //commandBar.Add(uid, ref optionalIndex);

            //Show the context menu at the current mouse location
            System.Drawing.Point currentLocation = System.Windows.Forms.Form.MousePosition;
            commandBar.Popup(currentLocation.X, currentLocation.Y);
        }
Esempio n. 2
0
        //Pan모드 선택처리
        public void FindCommandAndExecute(IApplication application)
        {
            ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID         uid         = new ESRI.ArcGIS.esriSystem.UID();
            uid.Value = "esriControls.ControlsMapPanTool";
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(uid, false, false);

            if (commandItem != null)
            {
                commandItem.Execute();
            }
        }
Esempio n. 3
0
        public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName)
        {
            ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID         commandID   = new ESRI.ArcGIS.esriSystem.UIDClass();
            commandID.Value = toolName; // example: "esriArcMapUI.ZoomInTool";
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false);

            if (commandItem != null)
            {
                application.CurrentTool = commandItem;
            }
        }
        ///<summary>Find a command and click it programmatically.</summary>
        ///
        ///<param name="application">An IApplication interface.</param>
        ///<param name="commandName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand" or "{D74B2F25-AC90-11D2-87F8-0000F8751720}"</param>
        ///
        ///<remarks>Refer to the EDN document http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ArcMapIds.htm for a listing of available CLSID's and ProgID's that can be used as the commandName parameter.</remarks>
        public void FindCommandAndExecute(ESRI.ArcGIS.Framework.IApplication application, System.String commandName)
        {
            try
            {
                ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
                ESRI.ArcGIS.esriSystem.UID         uid         = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = commandName;
                ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(uid, false, false);

                if (commandItem != null)
                {
                    commandItem.Execute();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Extensions manager could not be opened: {0}", ex.Message));
            }
        }