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();
            }
        }
Beispiel #2
0
 private void AvEvent_ItemAdded(object Item)
 {
     m_map = ArcMap.Document.FocusMap;
     if (m_map != null)
     {
         LayerDropdown.FillComboBox(m_map);
     }
     m_hasSelectableLayer = CheckForSelectableLayer();
 }
 public LayerDropdown()
 {
     s_comboBox = this;
     if (m_map == null)
     {
         m_map = ArcMap.Document.FocusMap;
         if (m_map == null)//if it's still null then bail
         {
             return;
         }
     }
     FillComboBox(m_map);
 }
        // Privates
        private void Initialize()
        {
            // If the extension hasn't been started yet, bail
            if (s_extension == null)
            {
                return;
            }
            //// Reset event handlers
            IActiveViewEvents_Event avEvent = ArcMap.Document.FocusMap as IActiveViewEvents_Event;

            if (avEvent == null)
            {
                return;
            }
            avEvent.ItemAdded       += AvEvent_ItemAdded;
            avEvent.ItemDeleted     += AvEvent_ItemAdded;
            avEvent.ContentsChanged += avEvent_ContentsChanged;
            // Update the UI
            m_map = ArcMap.Document.FocusMap;
            LayerDropdown.FillComboBox(m_map);
            m_hasSelectableLayer = CheckForSelectableLayer();
        }
        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);
            }
        }
Beispiel #6
0
 //event handlers
 private void avEvent_ContentsChanged()
 {
     m_hasSelectableLayer = CheckForSelectableLayer();
     LayerDropdown.FillComboBox(m_map);
 }