Beispiel #1
0
        private void Uninitialize()
        {
            if (s_extension == null)
            {
                return;
            }

            if (m_map == null)
            {
                return;
            }

            // Detach event handlers
            IActiveViewEvents_Event avEvent = m_map as IActiveViewEvents_Event;

            avEvent.ItemAdded   -= AvEvent_ItemAdded;
            avEvent.ItemDeleted -= AvEvent_ItemAdded;
            //avEvent.SelectionChanged -= UpdateSelCountDockWin;
            avEvent.ContentsChanged -= avEvent_ContentsChanged;
            avEvent = null;

            // Update UI
            LayerDropdown selCombo = LayerDropdown.GetTheComboBox();

            if (selCombo != null)
            {
                selCombo.ClearAll();
            }
        }
        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);
            }
        }