Пример #1
0
        private void btnExplode_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string linkFld  = cmbLinkedFld.Text;

            if (smpFtrNm == null || smpFtrNm == "" || linkFld == null || linkFld == "")
            {
                MessageBox.Show("sample location not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Dictionary <double, double> azDsDic = new Dictionary <double, double>();

            for (int i = 0; i < dgvAzDs.RowCount; i++)
            {
                double az = System.Convert.ToDouble(dgvAzDs[0, i].Value);
                double ds = System.Convert.ToDouble(dgvAzDs[1, i].Value);
                if (!azDsDic.ContainsKey(az))
                {
                    azDsDic.Add(az, ds);
                }
            }
            if (azDsDic.Count < 1)
            {
                MessageBox.Show("Nothing specified for offset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Exploding Samples");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();
            DateTime dt1 = DateTime.Now;

            try
            {
                IFeatureClass ftrCls  = ftrDic[smpFtrNm];
                string        outNm   = smpFtrNm + "_explode";
                IFeatureClass outFtr  = geoUtil.explodePoints(ftrDic[smpFtrNm], linkFld, azDsDic, outNm);
                IDataset      dSet    = (IDataset)outFtr;
                string        outPath = dSet.Workspace.PathName + "\\" + outNm;
                rp.addMessage("New exploded feature class is stored at the following location:\n\t" + outPath);
                DateTime dt2     = DateTime.Now;
                TimeSpan ts      = dt2.Subtract(dt1);
                string   prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                if (MessageBox.Show("Do you want to add layer to map?", "Add Layer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    IFeatureLayer ftrLyr = new FeatureLayerClass();
                    ftrLyr.FeatureClass = outFtr;
                    ftrLyr.Name         = outNm;
                    mp.AddLayer((ILayer)ftrLyr);
                }
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }