Example #1
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (this.method_2())
     {
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
         try
         {
             IEnvelope extent  = (this.ifeatureClass_0 as IGeoDataset).Extent;
             ITinEdit  tinEdit = new Tin() as ITinEdit;
             tinEdit.InitNew(extent);
             tinEdit.StartEditing();
             IField pHeightField = null;
             bool   flag         = false;
             if (this.cboHeightField.Text != "")
             {
                 if (this.cboHeightField.SelectedIndex == 0)
                 {
                     flag = true;
                 }
                 else
                 {
                     int num = this.ifeatureClass_0.FindField(this.cboHeightField.Text);
                     if (num != -1)
                     {
                         pHeightField = this.ifeatureClass_0.Fields.get_Field(num);
                     }
                 }
             }
             IField pTagValueField = null;
             object obj            = flag;
             tinEdit.AddFromFeatureClass(this.ifeatureClass_0, null, pHeightField, pTagValueField, (esriTinSurfaceType)this.cboTinSurfaceType.SelectedIndex, ref obj);
             object obj2     = true;
             string tempPath = System.IO.Path.GetTempPath();
             int    num2     = 0;
             string text     = tempPath + "tmptin";
             while (Directory.Exists(text))
             {
                 text = tempPath + "tmptin" + num2++.ToString();
             }
             tinEdit.SaveAs(text, ref obj2);
             tinEdit.StopEditing(true);
             if (this.m_pMap != null)
             {
                 ILayerFactoryHelper layerFactoryHelper = new LayerFactoryHelper();
                 IEnumLayer          enumLayer          = layerFactoryHelper.CreateLayersFromName((tinEdit as IDataset).FullName);
                 enumLayer.Reset();
                 ILayer pLayer = enumLayer.Next();
                 this.m_pMap.AddLayer(pLayer);
             }
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             base.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
         catch (Exception exception_)
         {
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             System.Windows.Forms.MessageBox.Show("无法创建TIN,请确保输入要素的是否合适!");
             CErrorLog.writeErrorLog(this, exception_, "");
         }
     }
 }