Example #1
0
        // updates the source layer based on user changing the seleced layer
        private void cboSourceLayer_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Debug.WriteLine("cboSourceLayer_SelectedIndexChanged()");

            try
            {

                if(m_pISDUTExt.State == esriExtensionState.esriESDisabled)
                    return;

                if(m_pISDUTExt.TransactionManager.Current() == null)
                    return;

                IFeatureLayer previousLayer = m_pFeatureLayerSource;
                m_pFeatureLayerSource = (IFeatureLayer)m_arraylistFeatureLayers[m_frmSourceLayer.cboSourceLayer.SelectedIndex];

                //try
                //{
                //    m_pNotifyComplete.SetComplete();
                //}
                //catch{}

                if (m_pFeatureLayerSource != null)
                {
                    IEditLayers editLayers = (IEditLayers)m_pEditor;
                    if (editLayers.IsEditable(m_pFeatureLayerSource))
                    {
                        if (!m_pFeatureLayerSource.Equals(editLayers.CurrentLayer))
                        {
                            editLayers.SetCurrentLayer(m_pFeatureLayerSource, 0);
                        }
                    }
                    else
                    {
                        MessageBox.Show("This layer cannot be edited.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        m_pFeatureLayerSource = previousLayer;

                        int featureIndex = -1;
                        if (previousLayer != null)
                        {
                            featureIndex = m_arraylistFeatureLayers.IndexOf(previousLayer);
                        }

                        m_frmSourceLayer.cboSourceLayer.SelectedIndex = featureIndex;
                    }

                    Debug.WriteLine("Source Layer Switched to " + m_pFeatureLayerSource.Name);
                    //MessageBox.Show(m_pFeatureLayerSource.Name);
                }

            }
            catch(Exception ex)
            {
                Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
                util.Logger.Write(" Descrip  : Responding to to the combo box selection index changing on the container form.\n " +
                                  "            Updates the source layer local IFeatureLayer variable." +
                    "\n Message  : " + ex.Message +
                    "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

            }
        }