Ejemplo n.º 1
0
        /// <summary>
        /// Called when [click].
        /// </summary>
        protected override void OnClick()
        {
            ArcMap.Application.CurrentTool = null;

            try
            {
                UID uid = new UIDClass();
                uid.Value = "{82B9951B-DD63-11D1-AA7F-00C04FA37860}";  // Select By Location Command

                ICommandItem commandItem = ArcMap.Application.Document.CommandBars.Find(uid, false, false);

                // open the Select By Location dialog (in case it isn't already open)
                if (commandItem != null)
                {
                    commandItem.Execute();
                }

                IntPtr selectwindow = this.FindSelectByLocationWindow();

                if (!selectwindow.Equals(IntPtr.Zero))
                {
                    WindowFunctions.BringWindowToTop(selectwindow);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.StackTrace);
                throw;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     for (int i = 0; i < m_subtype; i++)
     {
         m_xoomCommand.Execute();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the feature attribute inspector.
        /// </summary>
        public static void ShowFeatureAttributeInspector()
        {
            log.Debug("Enter");

            string progID = "esriEditor.AttributionCommand";

            log.Debug(string.Format("progID={0}", progID));
            UID uid = new UIDClass();

            uid.Value = progID;

            log.Debug(string.Format("uid={0}", uid.ToString()));

            //Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
            //object o = Activator.CreateInstance(t);

            try
            {
                //IApplication application = o as IApplication;
                ICommandBars commandBars = ArcMap.Application.Document.CommandBars;

                if (commandBars != null)
                {
                    bool norecurse = false;
                    bool nocreate  = false;

                    log.Debug(string.Format("commandBars.Find.uid={0}", uid.Value.ToString()));
                    log.Debug(string.Format("commandBars.Find.noRecurse={0}", norecurse));
                    log.Debug(string.Format("commandBars.Find.noCreate={0}", nocreate));

                    ICommandItem commandItem = commandBars.Find(uid, norecurse, nocreate);

                    if (commandItem == null)
                    {
                        log.Error("commandItem returned null.");
                    }
                    else
                    {
                        commandItem.Execute();
                    }
                }
                else
                {
                    log.Error("ArcMap.Application.Document.CommandBars is null.");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);

                throw;
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            UID pUID  = new UID();
            UID pUID2 = new UID();
            UID pUID3 = new UID();
            UID pUID4 = new UID();

            pUID.Value    = "{488CBE4F-CD34-4649-B1ED-8CD1B8149041}";
            pUID2.Value   = "{78FFF793-98B4-11D1-873B-0000F8751720}";
            pUID3.Value   = "{8841A0D9-4F49-11D2-AE2D-080009EC732A}";
            pUID4.Value   = "{8841A0DA-4F49-11D2-AE2D-080009EC732A}";
            pUID4.SubType = 2;

            ICommandItem CommandItem  = ArcMap.Application.Document.CommandBars.Find(pUID, false, true);
            ICommandItem CommandItem2 = ArcMap.Application.Document.CommandBars.Find(pUID2, false, true);
            ICommandItem CommandItem3 = ArcMap.Application.Document.CommandBars.Find(pUID3, false, true);
            ICommandItem CommandItem4 = ArcMap.Application.Document.CommandBars.Find(pUID4, false, true);

            CommandItem.Execute();
            CommandItem2.Execute();
            CommandItem3.Execute();
            CommandItem4.Execute();
        }
        public static void LoadAttributeTransfer(IApplication app, List <AttributeTransferDetails> attTransferDetails)
        {
            IEditor                  editor        = null;
            UID                      pUID          = null;
            IAttributeTransfer       pAttTrans     = null;
            IAttributeTransferType   pAttTransType = null;
            IFieldMap                pFieldMap     = null;
            AttributeTransferDetails attConfig     = null;
            IFeatureLayer            pSfl          = null;
            IFeatureLayer            pTfl          = null;
            IField                   pSourceField  = null;
            IField                   pTargetField  = null;

            ICommandItem pCmdItem = null;
            IAttributeTransferDefaultSettings pATDS = null;

            try
            {
                editor = Globals.getEditor(app);

                if (editor.EditState == esriEditState.esriStateNotEditing)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("MustBEditg") + " " + A4LGSharedFunctions.Localizer.GetString("StrtEditing"));
                    return;
                }

                if (attTransferDetails == null)
                {
                    return;
                }
                if (attTransferDetails.Count == 0)
                {
                    return;
                }


                pAttTransType = (IAttributeTransferType)editor;
                pAttTrans     = pAttTransType.AttributeTransfer;



                for (int j = 0; j < attTransferDetails.Count; j++)
                {
                    attConfig = attTransferDetails[j];

                    string aSourceName     = attConfig.SourceLayerName;
                    string aTargetName     = attConfig.TargetLayerName;
                    bool   FCorLayerSource = true;
                    bool   FCorLayerTarget = true;
                    pSfl = Globals.FindLayer(app, aSourceName, ref FCorLayerSource) as IFeatureLayer;
                    pTfl = Globals.FindLayer(app, aTargetName, ref FCorLayerTarget) as IFeatureLayer;
                    if (pSfl == null || pTfl == null)
                    {
                        //MessageBox.Show("The source or target layer is not present");
                        //return;
                    }
                    else
                    {
                        pFieldMap = pAttTrans.FindFieldMap(pSfl.FeatureClass, pTfl.FeatureClass);
                        if (pFieldMap != null)
                        {
                            pAttTrans.DeleteFieldMap(pFieldMap);
                        }
                        pFieldMap = new FieldMapClass();

                        pFieldMap.SourceClass = pSfl.FeatureClass;
                        pFieldMap.TargetClass = pTfl.FeatureClass;



                        for (int i = 0; i < attConfig.FromToFields.Length; i++)
                        {
                            if (attConfig.FromToFields[i] == null)
                            {
                                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttrTrasftLoadRError_1"));
                                return;
                            }
                            if (attConfig.FromToFields[i].SourceField == null || attConfig.FromToFields[i].TargetField == null)
                            {
                                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttrTrasftLoadRError_1"));
                                return;
                            }
                            pSourceField = Globals.GetField(pSfl.FeatureClass.Fields, attConfig.FromToFields[i].SourceField);
                            pTargetField = Globals.GetField(pTfl.FeatureClass.Fields, attConfig.FromToFields[i].TargetField);
                            if (pSourceField != null && pTargetField != null)
                            {
                                pFieldMap.SetFieldMap(pSourceField, pTargetField);
                            }
                        }


                        pAttTrans.FieldMap = pFieldMap;

                        pATDS = (IAttributeTransferDefaultSettings)pAttTrans;

                        pATDS.SourceName = aSourceName;
                        pATDS.TargetName = aTargetName;
                    }
                }


                pUID       = new UIDClass();
                pUID.Value = "esriEditorExt.FieldMappingCommand";


                app.CurrentTool = null;


                pCmdItem = app.Document.CommandBars.Find(pUID);
                pCmdItem.Execute();
            }
            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "LoadAttributeTransfer: " + ex.ToString());
            }
            finally
            {
                editor        = null;
                pUID          = null;
                pAttTrans     = null;
                pAttTransType = null;
                pFieldMap     = null;
                attConfig     = null;
                pSfl          = null;
                pTfl          = null;
                pSourceField  = null;
                pTargetField  = null;

                pCmdItem = null;
                pATDS    = null;
            }
        }
Ejemplo n.º 6
0
        public static void BuildMap(string m_pBUILDINGSDE, string m_pCSCLSDE, string m_pDOFTAXMAPSDE, bool isCSCL, bool isCustom,
                                    bool isAddressPoint, bool isCenterline, bool isBuilding, bool isTaxLot, bool isSave)

        {
            //Point to map document
            IMxDocument pMxDoc;

            pMxDoc = (IMxDocument)ArcMap.Application.Document;

            IMap pMap;

            pMap = pMxDoc.FocusMap;

            //Zoom in so that layers don't take too long to load
            double    x      = 988217;
            double    y      = 192020;
            double    border = 200;
            IEnvelope pEnvelope;

            pEnvelope = new EnvelopeClass {
                XMin = x - border, YMin = y - border, XMax = x + border, YMax = y + border
            };

            pMxDoc.ActiveView.Extent = pEnvelope;

            //Create layer groups
            IGroupLayer pBoundaryLayerGroup = new GroupLayerClass();

            pBoundaryLayerGroup.Name     = "Boundary";
            pBoundaryLayerGroup.Expanded = true;
            pBoundaryLayerGroup.Visible  = true;

            IGroupLayer pTransportationLayerGroup = new GroupLayerClass();

            pTransportationLayerGroup.Name     = "Transportation";
            pTransportationLayerGroup.Expanded = true;
            pTransportationLayerGroup.Visible  = true;

            IGroupLayer pPlacesLayerGroup = new GroupLayerClass();

            pPlacesLayerGroup.Name     = "Places";
            pPlacesLayerGroup.Expanded = true;
            pPlacesLayerGroup.Visible  = true;

            IGroupLayer pEMSLayerGroup = new GroupLayerClass();

            pEMSLayerGroup.Name     = "EMS";
            pEMSLayerGroup.Expanded = true;
            pEMSLayerGroup.Visible  = true;

            IGroupLayer pReferenceLayerGroup = new GroupLayerClass();

            pReferenceLayerGroup.Name     = "Reference";
            pReferenceLayerGroup.Expanded = true;
            pReferenceLayerGroup.Visible  = true;

            IGroupLayer pLayerGroup = new GroupLayerClass();

            pLayerGroup.Name     = "Featured Layers";
            pLayerGroup.Expanded = true;
            pLayerGroup.Visible  = true;

            //Load Layers into layer groups using input SDE connection using LoadCSCLFeatureClass method
            if (isCSCL)
            {
                LoadCSCLFeatureClass(isCSCL, "CityLimit", pBoundaryLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "ZipCode", pBoundaryLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "AssemblyDistrict", pBoundaryLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "CensusBlock2010", pReferenceLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "CensusTract2010", pReferenceLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "Elevation", pReferenceLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "FireBattalion", pEMSLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "FireCompany", pEMSLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "FireDivision", pEMSLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "Rail", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "Subway", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "SubwayStation", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "TransitEntrance", pTransportationLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "PointOfInterest", pPlacesLayerGroup, m_pCSCLSDE);
            }

            //Load Featured Layers if CSCL map or feature selected for custom map
            if (isCSCL || isTaxLot)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "Cadastral", pLayerGroup, m_pDOFTAXMAPSDE);
            }
            if (isCSCL || isCenterline)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "StreetCenterline", pLayerGroup, m_pCSCLSDE);
            }
            if (isCSCL || isBuilding)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "Building", pLayerGroup, m_pBUILDINGSDE);
            }
            if (isCSCL || isAddressPoint)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "AddressPoint", pLayerGroup, m_pCSCLSDE); //0
            }

            //If cscl, load group layers
            if (isCSCL)
            {
                pMap.AddLayer(pBoundaryLayerGroup);
                pMap.AddLayer(pReferenceLayerGroup);
                pMap.AddLayer(pTransportationLayerGroup);
                pMap.AddLayer(pPlacesLayerGroup);
                pMap.AddLayer(pEMSLayerGroup);
                pMap.AddLayer(pLayerGroup);
            }

            //Update map contents and refresh
            IActiveView pActiveView;

            pActiveView        = (IActiveView)pMap;
            pActiveView.Extent = pEnvelope;
            pActiveView.Refresh();
            pMxDoc.UpdateContents();

            //Prompt save directory if isSave checkbox selected
            if (isSave)
            {
                UID uid = new UIDClass();
                uid.Value   = "esriArcMapUI.MxFileMenuItem";
                uid.SubType = 3;
                ICommandItem item = ArcMap.Application.Document.CommandBars.Find(uid, false);
                item.Execute();
            }
        }