Пример #1
0
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     // TODO: Add Command2.OnClick implementation
     ISpatialReferenceDialog dlg = new SpatialReferenceDialogClass();
     ISpatialReference       iSR = dlg.DoModalEdit(
         m_hookHelper.FocusMap.SpatialReference,
         true, false, false, false, false, 0);
 }
Пример #2
0
        private void btnChooseCoordination_Click(object sender, EventArgs e)
        {
            ISpatialReferenceDialog2 pSRDialog = new SpatialReferenceDialogClass();

            outSpatialReference = pSRDialog.DoModalCreate(true, false, false, 0);
            string strSRName = outSpatialReference.Name;

            txbxOutputCoordination.Text = strSRName;
        }
Пример #3
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            ISpatialReferenceDialog2 pSpatialReferenceDialog2 = new SpatialReferenceDialogClass();

            _spatialReference = pSpatialReferenceDialog2.DoModalCreate(true, true, true, 0);
            if (_spatialReference == null)
            {
                return;
            }
            IWorkspaceEdit pWorkspaceEdit = _targetWorkspace as IWorkspaceEdit;

            if (pWorkspaceEdit == null)
            {
                return;
            }
            pWorkspaceEdit.StartEditing(true);
            pWorkspaceEdit.StartEditOperation();
            try
            {
                _pointList             = new List <CustomPoint>();
                _pointFeatureClassList = new List <CustomFeatureClass>();
                _lineFeatureClassList  = new List <CustomFeatureClass>();
                if (chkHasCoordInfo.Checked == false)
                {
                    GetSurveyPointList();
                }
                ExcelToPointFeatureClass();
                ExcelToLineFeatureClass();
                foreach (CustomFeatureClass customFeatureClass in _pointFeatureClassList)
                {
                    WorkspaceHelper.LoadFeatureClass(_map, customFeatureClass.FeatureClass);
                }
                foreach (CustomFeatureClass customFeatureClass in _lineFeatureClassList)
                {
                    WorkspaceHelper.LoadFeatureClass(_map, customFeatureClass.FeatureClass);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);

                foreach (Process p in Process.GetProcessesByName("Excel"))
                {
                    if (string.IsNullOrEmpty(p.MainWindowTitle))
                    {
                        p.Kill();
                    }
                }
            }
        }
Пример #4
0
        //选择坐标系
        private void button2_Click(object sender, EventArgs e)
        {
            ISpatialReferenceDialog2 spatialReferenceDialog2 = new SpatialReferenceDialogClass();

            pSpatialReference = spatialReferenceDialog2.DoModalCreate(true, false, false, 0);
            if (pSpatialReference == null)
            {
                return;
            }
            textBox2.Text = pSpatialReference.Name;
        }
Пример #5
0
        private void SpatialRSelect_Click(object sender, EventArgs e)
        {
            ISpatialReferenceDialog2 pSRDialog         = new SpatialReferenceDialogClass();
            ISpatialReference        iSpatialReference = pSRDialog.DoModalCreate(true, false, false, 0);

            if (iSpatialReference != null)
            {
                this.textBox1.Text = iSpatialReference.Name;
                CommonClass common = new CommonClass();
                common.SetConfigValue("SpatialReferenceName", iSpatialReference.Name);
            }
        }
Пример #6
0
        private void btnSpatialRef_Click(object sender, EventArgs e)
        {
            if (m_pGXObj == null)
            {
                MessageBox.Show("Please select a FeatureLayer first");
                return;
            }
            ISpatialReferenceDialog pSpatRefDialog = new SpatialReferenceDialogClass();

            m_pSpatRef = pSpatRefDialog.DoModalCreate(false, false, false, 0);

            txtSpatialRef.Text = m_pSpatRef.Name.ToString();
            this.Focus();
        }
        /// <summary>
        /// Allows the user to choose a custom output projection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSR_Click(object sender, EventArgs e)
        {
            ISpatialReferenceDialog2 dlg = new SpatialReferenceDialogClass();
            ISpatialReference        sr  = dlg.DoModalCreate(false, false, false, 0);

            labelSR.Text = sr.Name;
            _transform.SetSpatialReference(sr);
            if (sr != null)
            {
                _map.SpatialReference = sr;
                ArcMap.Document.ActiveView.Refresh();
            }
            FillDatumTransform();
            EnableSelectInputs();
        }
Пример #8
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) {
            //
            if (context == null) { return null; }
            if (context.Instance == null) { return null; }
            if (provider == null) { return null; }

            // Cannot handle multiple objects
            if (context.Instance is object[]) { return null; }

            //
            string wkt = null;
            if (value != null) {
                wkt = value.ToString();
            }
            
            // Do ArcGIS Desktop Test
            object dialog = null;
            try {
                dialog = new SpatialReferenceDialogClass();
            }
            catch { }
            if (dialog == null) {
                MessageBox.Show(
                    "You do not have ArcGIS Desktop Installed",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return null;
            }

            // Variable to hold edited or created spatial reference
            ISpatialReference spatialReferenceOut = null;

            // Use DoModelCreate (if NULL) or DoModelEdit (if not NULL)
            if (string.IsNullOrEmpty(wkt)) {
               
                ISpatialReferenceDialog2 spatialReferenceDialog = (ISpatialReferenceDialog2)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalCreate(false, false, false, 0);
            }
            else {
                // Recreate ESRI Spatial Reference from String
                ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                ISpatialReferenceInfo spatialReferenceInfo = null;
                int size;
                spatialReferenceFactory.CreateESRISpatialReferenceInfo(wkt, out spatialReferenceInfo, out size);
                ISpatialReference spatialReference = (ISpatialReference)spatialReferenceInfo;

                // Display Spatial Reference Dialog
                ISpatialReferenceDialog3 spatialReferenceDialog = (ISpatialReferenceDialog3)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalEdit3(spatialReference, true, 0);
            }

            // Exit if Output SpatialReference is NULL
            if (spatialReferenceOut == null) { return wkt; }

            // Convert ESRI Spatial Reference to a String
            IESRISpatialReferenceGEN spatialReferenceGEN = (IESRISpatialReferenceGEN)spatialReferenceOut;
            string projection;
            int size2;
            spatialReferenceGEN.ExportToESRISpatialReference(out projection, out size2);
            if (string.IsNullOrEmpty(projection)) { return wkt; }

            // Return Result
            return projection;
        }
Пример #9
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }
            if (provider == null)
            {
                return(null);
            }

            // Cannot handle multiple objects
            if (context.Instance is object[])
            {
                return(null);
            }

            //
            string wkt = null;

            if (value != null)
            {
                wkt = value.ToString();
            }

            // Do ArcGIS Desktop Test
            object dialog = null;

            try {
                dialog = new SpatialReferenceDialogClass();
            }
            catch { }
            if (dialog == null)
            {
                MessageBox.Show(
                    "You do not have ArcGIS Desktop Installed",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return(null);
            }

            // Variable to hold edited or created spatial reference
            ISpatialReference spatialReferenceOut = null;

            // Use DoModelCreate (if NULL) or DoModelEdit (if not NULL)
            if (string.IsNullOrEmpty(wkt))
            {
                ISpatialReferenceDialog2 spatialReferenceDialog = (ISpatialReferenceDialog2)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalCreate(false, false, false, 0);
            }
            else
            {
                // Recreate ESRI Spatial Reference from String
                ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                ISpatialReferenceInfo     spatialReferenceInfo    = null;
                int size;
                spatialReferenceFactory.CreateESRISpatialReferenceInfo(wkt, out spatialReferenceInfo, out size);
                ISpatialReference spatialReference = (ISpatialReference)spatialReferenceInfo;

                // Display Spatial Reference Dialog
                ISpatialReferenceDialog3 spatialReferenceDialog = (ISpatialReferenceDialog3)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalEdit3(spatialReference, true, 0);
            }

            // Exit if Output SpatialReference is NULL
            if (spatialReferenceOut == null)
            {
                return(wkt);
            }

            // Convert ESRI Spatial Reference to a String
            IESRISpatialReferenceGEN spatialReferenceGEN = (IESRISpatialReferenceGEN)spatialReferenceOut;
            string projection;
            int    size2;

            spatialReferenceGEN.ExportToESRISpatialReference(out projection, out size2);
            if (string.IsNullOrEmpty(projection))
            {
                return(wkt);
            }

            // Return Result
            return(projection);
        }