//画范围 private void btnSelRange_Click(object sender, EventArgs e) { DrawPolygonToolClass drawPolygon = new DrawPolygonToolClass(true, this); drawPolygon.OnCreate(_Hook.MapControl); _Hook.MapControl.CurrentTool = drawPolygon as ITool; }
/// <summary> /// 将导入的范围在工作库中建立一个图副范围图层, cyf 20110621 /// </summary> /// <param name="in_pMapRange"></param> /// <param name="ex"></param> //private void CreateMapFrameLayerInWorkSpace(IGeometry in_pMapRange, out Exception ex) //{ // ex = null; // //////第一步:获取工作库的Workspace // if (this.m_WorkFeatureDataset == null) { ex = new Exception("工作库的工作空间不能为空"); return; } // //////第二步:在工作空间中建立一个图副范围图层 // try // { // IFields fields = new FieldsClass(); // IFieldsEdit fsEdit = fields as IFieldsEdit; // //添加Object字段 // IField newfield2 = new FieldClass(); // IFieldEdit fieldEdit2 = newfield2 as IFieldEdit; // fieldEdit2.Name_2 = "OBJECTID"; // fieldEdit2.Type_2 = esriFieldType.esriFieldTypeOID; // fieldEdit2.AliasName_2 = "OBJECTID"; // newfield2 = fieldEdit2 as IField; // fsEdit.AddField(newfield2); // //添加Geometry字段 // IField newfield1 = new FieldClass(); // IFieldEdit fieldEdit1 = newfield1 as IFieldEdit; // fieldEdit1.Name_2 = "SHAPE"; // fieldEdit1.Type_2 = esriFieldType.esriFieldTypeGeometry; // IGeometryDef geoDef = new GeometryDefClass(); // IGeometryDefEdit geoDefEdit = geoDef as IGeometryDefEdit; // geoDefEdit.SpatialReference_2 = (this.m_WorkFeatureDataset as IGeoDataset).SpatialReference; // geoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon; // fieldEdit1.GeometryDef_2 = geoDefEdit as GeometryDef; // newfield1 = fieldEdit1 as IField; // fsEdit.AddField(newfield1); // fields = fsEdit as IFields; // ////////建立要素集 // IFeatureClass pMapFrameFeaCls = null; // pMapFrameFeaCls = ModData.GetFeaClsSetInEnum("MapFrameLayer", this.m_WorkFeatureDataset.Subsets); // if (pMapFrameFeaCls == null) // { // //////不存在则建立 // pMapFrameFeaCls = this.m_WorkFeatureDataset.CreateFeatureClass("MapFrameLayer", fields, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); // } // ////////第三部将图副范写入图副范围图层//////// // IWorkspaceEdit WsEdit = this.m_WorkFeatureDataset.Workspace as IWorkspaceEdit; // WsEdit.StartEditing(true); // WsEdit.StartEditOperation(); // IFeature NewFea = pMapFrameFeaCls.CreateFeature(); // NewFea.Shape = in_pMapRange; // NewFea.Store(); // WsEdit.StopEditOperation(); // WsEdit.StopEditing(true); // ////////第四步:记录此图层,加载至图层控件中 // this.m_MapFrameClass = pMapFrameFeaCls; // DeleteLayerByName("MapFrameLayer"); // IFeatureLayer NewMapFrameLayer = new FeatureLayerClass(); // NewMapFrameLayer.FeatureClass = pMapFrameFeaCls; // NewMapFrameLayer.Name = "MapFrameLayer"; // this.m_HookHelp.FocusMap.AddLayer(NewMapFrameLayer as ILayer); // this.m_HookHelp.FocusMap.MoveLayer((NewMapFrameLayer as ILayer), this.m_HookHelp.FocusMap.LayerCount); // } // catch (Exception eError) // { // //****************************************** // //系统运行日志 // if (ModData.SysLog == null) // ModData.SysLog = new clsWriteSystemFunctionLog(); // ModData.SysLog.Write(eError); // //****************************************** // ex = eError; // } //} //依照底图划范围 private void RadioBtnDrawRange_CheckedChanged(object sender, EventArgs e) { if (RadioBtnDrawRange.Checked) { RadioBtnDrawRange.Checked = true; DrawPolygonToolClass drawPolygon = new DrawPolygonToolClass(true, this); drawPolygon.OnCreate(axMapControl1.Object as IMapControlDefault); axMapControl1.CurrentTool = drawPolygon as ITool; } else { RadioBtnDrawRange.Checked = false; } }