Пример #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);
        }
Пример #2
0
        public fmTLSearch()
        {
            InitializeComponent();
            this.App = (IApplication)ArcMap.ThisApplication;

            if ((SConst.LayerLocation == null) || (SConst.LayerLocation.Length < 1))
            {
                CMedToolsSubs.setConstVals();
            }
        }
Пример #3
0
        // ArcGIS Snippet Title:
        // Get MxDocument from ArcMap
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.ArcMapUI
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop
        //
        // 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.
        //
        // Use the following XML documentation comments to use this snippet:
        /// <summary>Get MxDocument from ArcMap.</summary>
        ///
        /// <param name="application">An IApplication interface that is the ArcMap application.</param>
        ///
        /// <returns>An IMxDocument interface.</returns>
        ///
        /// <remarks></remarks>
        public ESRI.ArcGIS.ArcMapUI.IMxDocument GetMxDocument(ESRI.ArcGIS.Framework.IApplication application)
        {
            if (application == null)
            {
                return(null);
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ((ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document)); // Explicit Cast

            return(mxDocument);
        }
Пример #4
0
        // ArcGIS Snippet Title:
        // Get ActiveView from ArcMap
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.ArcMapUI
        // ESRI.ArcGIS.Carto
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop
        //
        // 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.
        //
        // Use the following XML documentation comments to use this snippet:
        /// <summary>Get ActiveView from ArcMap.</summary>
        ///
        /// <param name="application">An IApplication interface that is the ArcMap application.</param>
        ///
        /// <returns>An IActiveView interface.</returns>
        ///
        /// <remarks></remarks>
        public static ESRI.ArcGIS.Carto.IActiveView GetActiveView(ESRI.ArcGIS.Framework.IApplication application)
        {
            if (application == null)
            {
                return(null);
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument; // Dynamic Cast
            ESRI.ArcGIS.Carto.IActiveView    activeView = mxDocument.ActiveView;

            return(activeView);
        }
Пример #5
0
        // ArcGIS Snippet Title:
        // Get Contents View from ArcMap
        //
        // Long Description:
        // Get the Contents View (TOC) for ArcMap.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.ArcMapUI
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        //
        // 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 GetIntersection.
        //

        ///<summary>Get the Contents View (TOC) for ArcMap.</summary>
        ///
        ///<param name="application">An IApplication interface that is the ArcMap application.</param>
        ///<param name="index">A System.Int32 that is the tab number of the TOC. When specifying the index number: 0 = usually the Display tab, 1 = usually the Source tab.</param>
        ///
        ///<returns>An IContentsView interface.</returns>
        ///
        ///<remarks></remarks>
        public ESRI.ArcGIS.ArcMapUI.IContentsView GetContentsViewFromArcMap(ESRI.ArcGIS.Framework.IApplication application, System.Int32 index)
        {
            if (application == null || index < 0 || index > 1)
            {
                return(null);
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument   mxDocument   = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document); // Explicit Cast
            ESRI.ArcGIS.ArcMapUI.IContentsView contentsView = mxDocument.get_ContentsView(index);                       // 0 = usually the Display tab, 1 = usually the Source tab

            return(contentsView);
        }
Пример #6
0
        // ArcGIS Snippet Title:
        // Get Map from ArcMap
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.ArcMapUI
        // ESRI.ArcGIS.Carto
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop
        //
        // 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.
        //
        // Use the following XML documentation comments to use this snippet:
        /// <summary>Get Map from ArcMap.</summary>
        ///
        /// <param name="application">An IApplication interface that is the ArcMap application.</param>
        ///
        /// <returns>An IMap interface.</returns>
        ///
        /// <remarks></remarks>
        public static ESRI.ArcGIS.Carto.IMap GetMap(ESRI.ArcGIS.Framework.IApplication application)
        {
            if (application == null)
            {
                return(null);
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ((ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document)); // Explicit Cast
            ESRI.ArcGIS.Carto.IActiveView    activeView = mxDocument.ActiveView;
            ESRI.ArcGIS.Carto.IMap           map        = activeView.FocusMap;

            return(map);
        }
Пример #7
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;
            }
        }
Пример #8
0
        private IEditor3 GetEditorFromArcMap(IMxApplication mxApplication)
        {
            if (mxApplication == null)
            {
                return(null);
            }
            ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
            uid.Value = "{F8842F20-BB23-11D0-802B-0000F8037368}";
            ESRI.ArcGIS.Framework.IApplication application = mxApplication as ESRI.ArcGIS.Framework.IApplication; // Dynamic Cast
            ESRI.ArcGIS.esriSystem.IExtension  extension   = application.FindExtensionByCLSID(uid);
            ESRI.ArcGIS.Editor.IEditor3        editor3     = extension as ESRI.ArcGIS.Editor.IEditor3;            // Dynamic Cast

            return(editor3);
        }
Пример #9
0
        public static IMMPxApplication GetPxApplication()
        {
            ESRI.ArcGIS.Framework.IApplication App = GetApplication();
            if (App == null)
            {
                throw new Exception("Could not load Application Extension");
            }

            IExtension            mxExt            = App.FindExtensionByName("Workflow Manager Integration");
            IMMPxIntegrationCache pxIntegrationExt = (Miner.Interop.Process.IMMPxIntegrationCache)mxExt;
            IMMPxApplication      PxApp            = pxIntegrationExt.Application;

            if (PxApp == null)
            {
                throw new Exception("Could not load Px Application Extension");
            }

            return(PxApp);
        }
        ///<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));
            }
        }
Пример #11
0
        public fmAddDataFrame()
        {
            InitializeComponent();

            this.App = ArcMap.ThisApplication as IApplication;

            if ((SConst.LayerLocation == null) || (SConst.LayerLocation.Length < 1))
            {
                CMedToolsSubs.setConstVals();
            }

            Dictionary <string, string> dctCommon = SConst.CommonLayers;

            this.m_commonLayers = new string[dctCommon.Keys.Count];
            dctCommon.Values.CopyTo(this.m_commonLayers, 0);

            //CConst.CommonLayers.Values.CopyTo(this.m_commonLayers, 0);

            this.m_EconOnLayers   = this.getOnLayers("@type='EconDev' and @state='ON'");     // this.getEconOnLayers();
            this.m_FireOnLayers   = this.getOnLayers("@type='Fire' and @state='ON'");        //this.getFireOnLayers();
            this.m_PlanOnLayers   = this.getOnLayers("@type='Planning' and @state='ON'");    //this.getPlanOnLayers();
            this.m_PWOnLayers     = this.getOnLayers("@type='PublicWorks' and @state='ON'"); //this.getPWOnLayers();
            this.m_PoliceOnLayers = this.getOnLayers("@type='Police' and @state='ON'");      //this.getPoliceOnLayers();
        }
Пример #12
0
 public CPortraitLayout(ESRI.ArcGIS.Framework.IApplication pApp, List <string> lstLegendLayers, Double dblMapScale, string sMapSize, string sTitle, string sSubTitle, string sOrientation, string sPrinterName) :
     base(pApp, lstLegendLayers, dblMapScale, sMapSize, sTitle, sSubTitle, sOrientation, sPrinterName)
 {
     // let the base class handle this
 }
Пример #13
0
 public fmMultipleResults()
 {
     InitializeComponent();
     m_sWhere = "";
     this.App = (IApplication)ArcMap.ThisApplication;
 }
Пример #14
0
 // ArcGIS Snippet Title:
 // Get Document Path
 //
 // Add the following references to the project:
 // ESRI.ArcGIS.Framework
 //
 // Intended ArcGIS Products for this snippet:
 // ArcGIS Desktop
 //
 // 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.
 //
 // Use the following XML documentation comments to use this snippet:
 /// <summary>Get the active document path for the ArcGIS application.</summary>
 ///
 /// <param name="application">An IApplication interface.</param>
 ///
 /// <returns>A System.String is returned that is the path for the document.</returns>
 ///
 /// <remarks></remarks>
 public System.String GetActiveDocumentPath(ESRI.ArcGIS.Framework.IApplication application)
 {
     ESRI.ArcGIS.Framework.ITemplates templates = application.Templates;
     return(templates.get_Item(templates.Count - 1));
 }