internal static void FillComboBox(IMap theMap)
        {
            LayerDropdown selCombo = LayerDropdown.GetTheComboBox();

            if (selCombo == null)
            {
                return;
            }

            //hold onto the currently selected layer name, before the combo box is cleared
            IFeatureLayer pFlyr = null;

            if (selCombo.items.Count > 1)
            {
                pFlyr = (IFeatureLayer)selCombo.GetItem(selCombo.Selected).Tag;
            }
            selCombo.ClearAll();

            IFeatureLayer   featureLayer;
            ICompositeLayer pCompLyr      = null;
            LayerManager    ext_PntLyrMan = LayerManager.GetExtension();
            bool            bUseLines     = false;

            if (ext_PntLyrMan != null)
            {
                bUseLines = ext_PntLyrMan.UseLines;
            }
            // Loop through the layers in the map and add the layer's name to the combo box.
            int lLayerCount = 0;
            int cookie      = 0;
            int resetCookie = 0;

            for (int i = 0; i < theMap.LayerCount; i++)
            {
                bool   bIsComposite = false;
                ILayer pLayer       = theMap.get_Layer(i);
                if (pLayer is ICompositeLayer)
                {
                    pCompLyr     = (ICompositeLayer)pLayer;
                    bIsComposite = true;
                }

                int iCompositeLyrCnt = 1;
                if (bIsComposite)
                {
                    iCompositeLyrCnt = pCompLyr.Count;
                }
                for (int j = 0; j <= (iCompositeLyrCnt - 1); j++)
                {
                    if (bIsComposite)
                    {
                        pLayer = pCompLyr.get_Layer(j);
                    }
                    if (pLayer is IFeatureLayer)
                    {
                        featureLayer = pLayer as IFeatureLayer;
                        if (featureLayer is ICadastralFabricSubLayer2)
                        {
                            break;
                        }

                        if (featureLayer.FeatureClass == null)
                        {
                            continue;
                        }

                        if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint && !bUseLines ||
                            featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && bUseLines)
                        {
                            cookie = selCombo.AddItem(featureLayer.Name, featureLayer);
                            if (pFlyr != null)
                            {
                                if (featureLayer.Name == pFlyr.Name)
                                {
                                    resetCookie = cookie;
                                }
                            }
                            lLayerCount++;
                        }
                    }
                }
                if (lLayerCount > 1)
                {
                    selCombo.Select(cookie);//select the last one added
                }
            }

            if (pFlyr == null)
            {
                if (lLayerCount > 1)
                {
                    selCombo.Select(cookie);//select the last one added
                }
                else if (lLayerCount == 0)
                {
                    m_fl = null;
                }
            }
            else if (lLayerCount > 1)// else set the combo box to the originally selected layer
            {
                selCombo.Select(resetCookie);
            }
        }
Exemple #2
0
        protected override void OnStartup()
        {
            try
            {
                s_extension = this;
                m_pEd       = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");
                // Named event handler
                ArcMap.Events.NewDocument  += delegate() { ArcMap_NewDocument(); };
                ArcMap.Events.OpenDocument += delegate() { ArcMap_NewDocument(); };

                Utilities Utils        = new Utilities();
                string    sDesktopVers = Utils.GetDesktopVersionFromRegistry();
                if (sDesktopVers.Trim() == "")
                {
                    sDesktopVers = "Desktop10.0";
                }
                else
                {
                    sDesktopVers = "Desktop" + sDesktopVers;
                }
                string sValues =
                    Utils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
                                           "AddIn.FabricPointMoveToFeature");
                if (sValues.Trim() == "")
                {
                    m_useLines                  = false;
                    m_PointFieldName            = "";
                    m_TestMinimumMove           = false;
                    m_SelectionIgnore           = true;
                    m_SelectedReferenceFeatures = false;
                    m_SelectedParcels           = false;
                    m_SelectPrompt              = false;
                    m_TransformationPrompt      = false;
                    m_dReportTolerance          = 0;
                    return;
                }
                try
                {
                    string[] Values = sValues.Split(',');
                    m_useLines        = (Values[0].Trim() == "1");
                    m_PointFieldName  = Values[1].Trim();
                    m_TestMinimumMove = (Values[2].Trim() == "1");

                    if (!Double.TryParse(Values[3].Trim(), out m_dMinimumMoveTolerance))
                    {
                        m_dMinimumMoveTolerance = 0;
                    }

                    m_ShowReport = (Values[4].Trim() == "1");
                    if (m_ShowReport)
                    {
                        m_dReportTolerance = 0;
                        try
                        {
                            m_dReportTolerance = Convert.ToDouble(Values[5]);
                        }
                        catch
                        { }
                    }

                    m_SelectionIgnore           = (Values[6].Trim() == "1");
                    m_SelectedReferenceFeatures = (Values[7].Trim() == "1");
                    m_SelectedParcels           = (Values[8].Trim() == "1");
                    m_SelectPrompt = (Values[9].Trim() == "1");
                    m_MergePoints  = (Values[10].Trim() == "1");

                    if (m_MergePoints)
                    {
                        m_dMergePointTolerance = 0.003;
                        try
                        {
                            m_dMergePointTolerance = Convert.ToDouble(Values[11]);
                        }
                        catch
                        { }
                    }
                    m_TransformationPrompt = (Values[12].Trim() == "1");
                }
                catch
                { }
            }

            catch (COMException ex)
            {
                MessageBox.Show(ex.Message);
            }
            Initialize();
        }