Exemple #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            CSpatialSubs oSpatialSubs = new CSpatialSubs();

            if (oSpatialSubs.returnCurrentProductCode() == ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcView)
            {
                string sMsg = "This action requires that you use at least an ArcEditor license\r\n\r\n";
                sMsg += "Click 'YES' below to have the application restart for you (you will NOT be prompted to save)\r\n";
                sMsg += "or\r\nclick 'No' below to restart later and then checkout an Editor license from the Desktop Administrator";
                sMsg += "\r\n\r\nDo you want to restart the application?";

                if (MessageBox.Show(sMsg, "Editor License Required", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    //if (CMedToolsSubs.isProductAvailable(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcEditor) == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable)
                    //{
                    //// shut down the app and restart
                    CMedToolsSubs.ResetAsEditor = true;
                    CloseForm();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("There is no Editor license available at the moment.", "License problem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //}
                }
            }
            else
            {
                Cursor = Cursors.WaitCursor;
                try
                {
                    ///
                    /// rev. 12/13/2007
                    /// by: David Renz
                    /// changed to just use the selected featureclass
                    ///
                    oSpatialSubs.addFeatureLayerToMap(this.App, lbEditabelLayers.SelectedItem.ToString(), true);

                    // add the layers to ArcMap
                    //foreach (object obj in lbEditabelLayers.Items)
                    //{
                    //    CMedToolsSubs.addFeatureLayerToMap(this.App, obj.ToString(), true);
                    //}
                    CloseForm();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("An error occurred while loading the layers into the application.\r\n\r\nPlease check with the GIS administrator to ensure that you have edit priviledges on the selected layers.");
                    this.lblEditMsg.Text = ex.Message.ToString(); //"An error occurred while starting an editing session.\r\n\r\nPlease check with the GIS administrator to ensure\r\nthat you have edit priviledges on the selected layers.";
                    //this.lblEditMsg.Text += "\r\n\r\n" + ex.Message;
                    return;
                }
                finally
                {
                    Cursor = Cursors.Default;
                    oSpatialSubs.Dispose();
                }
            }
        }