private void AxTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap pMap = null; ILayer pLayer = null; object legendgp = null; object index = null; esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index); //点击测试,点击图例打开符号选择器 if (e.button == 1) { ILegendGroup pLegendGroup = new LegendGroup(); ILegendClass pLegendClass = new LegendClass(); pLegendGroup = (ILegendGroup)legendgp; if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass) { pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString())); if (pLegendClass == null) { return; } FormSymbolSelector dlg = new FormSymbolSelector(pLegendClass, pLayer); if (dlg != null) { dlg.ShowDialog(); m_pTocControl.Update(); m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } } } }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在汇总...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; SampleSummary summary = new SampleSummary(_pSampleLayer, _pSurveyLayer, cmbFieldVillage.Text, cmbFieldID.Text, cmbFieldCropType.Text, cmbCropName.Text, cmbFieldArea.Text, txtOut.Text); string msg = ""; if (!summary.Summary(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (DialogResult.OK == XtraMessageBox.Show("汇总完成!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { //MapAPI.AddShpFileToMap(txtOut.Text); BLL.EnviVars.instance.MapControl.Refresh(); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } finally { frmWait.Close(); XtraMessageBox.Show("汇总完成!"); _pMapControl.Refresh(); _pTOCControl.Update(); } }
private void SaveChanges(DataTable editedRow) { try { ITable aeTable = _FeatureLayer.FeatureClass as ITable; int fieldCount = aeTable.Fields.FieldCount; int fidIndex = aeTable.FindField("FID"); IRow pRow = null; foreach (DataRow iRow in editedRow.Rows) { ICursor pCursor = aeTable.Update(null, true); while ((pRow = pCursor.NextRow()) != null) { if (pRow.get_Value(fidIndex).ToString() == iRow[fidIndex].ToString()) { for (int i = 2; i < fieldCount; i++) { pRow.set_Value(i, iRow[i]); } pCursor.UpdateRow(pRow); } } if (pCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor); } } _CurrentTable.AcceptChanges(); XtraMessageBox.Show("保存成功!"); MapAPI.UniqueValueRender(_FeatureLayer, "分层"); (_pMapControl.Map as IActiveView).Extent = _FeatureLayer.AreaOfInterest; _pMapControl.Refresh(); _pTOCControl.Update(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { ITableConversion conver = new TableConversion(); DataTable dt = conver.AETableToDataTable(_pFLayer.FeatureClass); //添加主键以提高处理速度 dt.PrimaryKey = new DataColumn[] { dt.Columns["FID"] }; AutoLayer auto = new AutoLayer(); _pFDt = auto.OptimalStratifying(dt, _lyrField, _lyrNum); ITable pTable = _pFLayer.FeatureClass as ITable; //添加分层字段 string fName = "FCBH"; if (pTable.FindField(fName) < 0) { IField layerField = new FieldClass(); IFieldEdit fieldEdit = layerField as IFieldEdit; fieldEdit.Name_2 = fName; fieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger; pTable.AddField(layerField); } //字段赋值 ICursor pCursor = pTable.Update(null, false); IRow pRow = null; int layerIndex = pTable.FindField(fName); if (layerIndex < 0) { XtraMessageBox.Show("添加分层字段失败!"); return; } while ((pRow = pCursor.NextRow()) != null) { string value = pRow.get_Value(0).ToString(); //改用find接口以二叉树查找,效率提高百倍级别 DataRow test = _pFDt.Rows.Find(value); if (test == null) { continue; } pRow.set_Value(layerIndex, test[fName]); pCursor.UpdateRow(pRow); //原始遍历方法 //foreach(DataRow dRow in _pFDt.Rows) //{ // if (value == dRow["FID"].ToString()) // { // pRow.set_Value(layerIndex, dRow[fName]); // pCursor.UpdateRow(pRow); // } //} } Marshal.ReleaseComObject(pCursor); XtraMessageBox.Show("分层完毕!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); { SampleData.layerField = fName; MapAPI.UniqueValueRender(_pFLayer, fName); (_pMapControl.Map as IActiveView).Extent = _pFLayer.AreaOfInterest; _pMapControl.Refresh(); _pTOCControl.Update(); } }
//ÅжÏÓÒ¼ü²Ëµ¥ÏîÊÇ·ñ»ÒÉ«²»¿ÉÓà //public override bool Enabled //{ // get // { // //bool enabled = !(currentLayer is IRasterLayer); // return true; // } //} #endregion private void SetupFeaturePropertySheet(ILayer layer) { if (layer == null) { return; } ESRI.ArcGIS.Framework.IComPropertySheet pComPropSheet; pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheet(); pComPropSheet.Title = layer.Name + " - properties"; ESRI.ArcGIS.esriSystem.UID pPPUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pComPropSheet.AddCategoryID(pPPUID); // General.... ESRI.ArcGIS.Framework.IPropertyPage pGenPage = new ESRI.ArcGIS.CartoUI.GeneralLayerPropPageClass(); pComPropSheet.AddPage(pGenPage); // Source ESRI.ArcGIS.Framework.IPropertyPage pSrcPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSourcePropertyPageClass(); pComPropSheet.AddPage(pSrcPage); // Selection... ESRI.ArcGIS.Framework.IPropertyPage pSelectPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSelectionPropertyPageClass(); pComPropSheet.AddPage(pSelectPage); // Display.... ESRI.ArcGIS.Framework.IPropertyPage pDispPage = new ESRI.ArcGIS.CartoUI.FeatureLayerDisplayPropertyPageClass(); pComPropSheet.AddPage(pDispPage); // Symbology.... ESRI.ArcGIS.Framework.IPropertyPage pDrawPage = new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass(); pComPropSheet.AddPage(pDrawPage); // Fields... ESRI.ArcGIS.Framework.IPropertyPage pFieldsPage = new ESRI.ArcGIS.CartoUI.LayerFieldsPropertyPageClass(); pComPropSheet.AddPage(pFieldsPage); // Definition Query... ESRI.ArcGIS.Framework.IPropertyPage pQueryPage = new ESRI.ArcGIS.CartoUI.LayerDefinitionQueryPropertyPageClass(); pComPropSheet.AddPage(pQueryPage); // Labels.... ESRI.ArcGIS.Framework.IPropertyPage pSelPage = new ESRI.ArcGIS.CartoUI.LayerLabelsPropertyPageClass(); pComPropSheet.AddPage(pSelPage); // Joins & Relates.... ESRI.ArcGIS.Framework.IPropertyPage pJoinPage = new ESRI.ArcGIS.ArcMapUI.JoinRelatePageClass(); pComPropSheet.AddPage(pJoinPage); // Setup layer link ESRI.ArcGIS.esriSystem.ISet pMySet = new ESRI.ArcGIS.esriSystem.SetClass(); pMySet.Add(layer); pMySet.Reset(); // make the symbology tab active pComPropSheet.ActivePage = 4; // show the property sheet bool bOK = pComPropSheet.EditProperties(pMySet, 0); m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); tocControl.Update(); //¸üÐÂĿ¼Ê÷ }