📄 form1.cs
字号:
pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
pExport.PixelBounds = pPixelBoundsEnv;
int hDC = pExport.StartExporting();
pActiveView.Output(hDC,(int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
}
private void m_View_Pan_Click(object sender, System.EventArgs e) // 平移
{
ICommand pCommand ;
pCommand = new ControlsMapPanToolClass() ;
pCommand.OnCreate(axMap1.Object );
axMap1.CurrentTool =(ITool) pCommand;
iMapAction = 4;
statusBarPanel1.Text ="漫游";
}
private void m_Tool_Length_Click(object sender, System.EventArgs e)
{
iMapAction = 5;
statusBarPanel1.Text ="测距离";
ITool obj = new ControlsMapPanToolClass() ;
axMap1.CurrentTool = obj;
}
private void m_Tool_Area_Click(object sender, System.EventArgs e)
{
iMapAction = 6;
statusBarPanel1.Text ="测面积";
ITool obj = new ControlsMapPanToolClass() ;
axMap1.CurrentTool = obj;
}
private void m_Tool_Angle_Click(object sender, System.EventArgs e)
{
iMapAction = 7;
statusBarPanel1.Text ="测角度";
ITool obj = new ControlsMapPanToolClass() ;
axMap1.CurrentTool = obj;
}
public void FlashShape(IGeometry pGeometry)
{
pGeometry.SpatialReference = axMap1.SpatialReference ;
pGeometry.SnapToSpatialReference();
switch (pGeometry.GeometryType)
{
case esriGeometryType.esriGeometryPoint:
IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
axMap1.FlashShape(pGeometry,3,500,pMarkerSymbol);
break;
case esriGeometryType.esriGeometryPolyline :
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
axMap1.FlashShape(pGeometry,3,500,pLineSymbol);
break;
case esriGeometryType.esriGeometryPolygon :
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
axMap1.FlashShape(pGeometry,3,500,pFillSymbol);
break;
}
}
private void axMap1_OnSelectionChanged(object sender, System.EventArgs e)
{
if (iMapAction != 1 )
return ;
ITableSelection pTable;
ILayer pLayer;
if ( pForm.Visible == false )
{
pForm.Close();
pForm = null;
pForm = new AttributeList();
pForm.Owner = this ;
}
else
{
pForm.ClearSelection();
}
for ( int i=0 ; i< axMap1.LayerCount; i++)
{
pTable = (ITableSelection) axMap1.get_Layer(i) ;
pLayer = axMap1.get_Layer(i) ;
pForm.AddSelection( pTable.SelectionSet, pLayer.Name );
pTable.Clear();
}
pForm.Show() ;
}
private void axMap1_OnMouseMove(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseMoveEvent e)
{
statusBarPanel2.Text = e.x.ToString();
statusBarPanel3.Text = e.y.ToString();
switch (iMapAction)
{
case 5:
#region //测长度
if (pTool.IsSurveying )
{
pTool.MoveTo(axMap1.ToMapPoint(e.x,e.y ));
statusBarPanel1.Text ="总长度:" + pTool.totalLength.ToString()
+"; 当前线段长度:" + pTool.currentLength.ToString();
}
break;
#endregion
case 6:
#region //测面积
if (pTool.IsSurveying )
{
pTool.MoveTo(axMap1.ToMapPoint(e.x,e.y ));
statusBarPanel1.Text ="面积:" + pTool.Area.ToString();
}
break;
#endregion
case 7:
#region //测角度
if (pTool.IsSurveying )
{
pTool.MoveTo(axMap1.ToMapPoint(e.x,e.y ));
statusBarPanel1.Text ="方向角:" + pTool.Direction.ToString()
+ ", 夹角:" + pTool.Angle.ToString() ;
}
break;
#endregion
case 8:
pEditor.NewFeatureMouseMove(e.x,e.y );
break;
case 10: //移动
pEditor.MoveFeatureMouseMove(e.x ,e.y );
break;
case 12:
pEditor.EditFeatureMouseMove(e.x,e.y );
break;
}
}
private void axMap1_OnMouseDown(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent e)
{
object obj ;
switch (iMapAction)
{
case 5:
#region //测长度
if (e.button == 1)
{
if ( !pTool.IsSurveying )
pTool.LengthStart(axMap1.ToMapPoint(e.x,e.y ));
else
pTool.AddPoint(axMap1.ToMapPoint(e.x,e.y ));
}
else
{
if ( pTool.IsSurveying )
{
obj = new SimpleLineSymbolClass() ;
axMap1.DrawShape(pTool.SurveyEnd(axMap1.ToMapPoint(e.x,e.y )),ref obj);
statusBarPanel1.Text ="测距离";
}
}
break;
#endregion
case 6:
#region //测面积
if (e.button == 1)
{
if ( !pTool.IsSurveying )
pTool.AreaStart(axMap1.ToMapPoint(e.x,e.y ));
else
pTool.AddPoint(axMap1.ToMapPoint(e.x,e.y ));
}
else
{
if ( pTool.IsSurveying )
{
obj = new SimpleFillSymbolClass() ;
axMap1.DrawShape( pTool.SurveyEnd(axMap1.ToMapPoint(e.x,e.y )),ref obj);
statusBarPanel1.Text ="测面积";
}
}
break;
#endregion
case 7:
#region //测角度
if (e.button == 1)
{
if ( !pTool.IsSurveying )
pTool.AngleStart(axMap1.ToMapPoint(e.x,e.y ));
else
pTool.AddPoint(axMap1.ToMapPoint(e.x,e.y ));
}
else
{
if ( pTool.IsSurveying )
{
obj = new SimpleLineSymbolClass();
axMap1.DrawShape(pTool.SurveyEnd(axMap1.ToMapPoint(e.x,e.y )), ref obj);
statusBarPanel1.Text ="测角度";
}
}
break;
#endregion
case 8:
#region //新建
if (e.button ==1)
pEditor.NewFeatureMouseDown(e.x ,e.y );
else
{
pEditor.NewFeatureEnd();
axMap1.Refresh();
}
break;
#endregion
case 9: //删除
pEditor.SelectMouseDown(e.x,e.y );
break;
case 10: //移动
pEditor.MoveFeatureMouseDown(e.x,e.y );
break;
case 12:
#region //编辑节点
pEditor.EditFeatureMouseDown(e.x,e.y );
break;
#endregion
}
}
private void axMap1_OnMouseUp(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseUpEvent e)
{
switch (iMapAction)
{
case 9: //删除
pEditor.DeleteSelectedFeature();
break;
case 10: //移动
pEditor.MoveFeatureEnd();
break;
case 12: //编辑节点
pEditor.EditFeatureEnd();
break;
}
}
private void m_Tool_Refresh_Click(object sender, System.EventArgs e)
{
axMap1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground ,null,null);
}
private void m_Theme_Lable_Click(object sender, System.EventArgs e)
{
IGeoFeatureLayer pGeoFeatureLayer =(IGeoFeatureLayer) axMap1.get_Layer(0);
pGeoFeatureLayer.AnnotationProperties.Clear();
IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl = pGeoFeatureLayer.AnnotationProperties;
ILabelEngineLayerProperties pLabelEngine;
pLabelEngine = new LabelEngineLayerPropertiesClass() ;
pLabelEngine.Expression = "[CITY_NAME] & vbCrlf & \"(\" & [STATE_NAME] & \")\"" ;
IAnnotateLayerProperties pAnnoLayerProps = (IAnnotateLayerProperties) pLabelEngine ;
pAnnoLayerPropsColl.Add(pAnnoLayerProps);
pGeoFeatureLayer.DisplayAnnotation = true;
axMap1.ActiveView.Refresh();
}
private void m_Theme_BarChart_Click(object sender, System.EventArgs e)
{
IGeoFeatureLayer layer;
try
{
IChartRenderer pChartRenderer = new ChartRendererClass() as IChartRenderer ;
IRendererFields pRendererField = (IRendererFields) pChartRenderer;
pRendererField.AddField( "AGE_UNDER5","AGE_UNDER5");
pRendererField.AddField("AGE_5_17","AGE_5_17");
pRendererField.AddField("AGE_18_64","AGE_18_64");
pRendererField.AddField("AGE_65_UP","AGE_65_UP");
IBarChartSymbol pBarChartSymbol =(IBarChartSymbol) new BarChartSymbolClass();
pBarChartSymbol.Width = 6;
IChartSymbol pChartSymbol =(IChartSymbol) pBarChartSymbol;
pChartSymbol.MaxValue = 5000000;
IMarkerSymbol pMarkerSymbol =(IMarkerSymbol) pBarChartSymbol;
pMarkerSymbol.Size = 25;
ISymbolArray pSymbolArray = (ISymbolArray) pBarChartSymbol;
IFillSymbol pFillSymbol;
pFillSymbol =(IFillSymbol) new SimpleFillSymbolClass(); //under 5
pFillSymbol.Color = GetRGBColor(213, 212, 252);
pSymbolArray.AddSymbol((ISymbol) pFillSymbol);
pFillSymbol =(IFillSymbol) new SimpleFillSymbolClass(); //5-17
pFillSymbol.Color = GetRGBColor(193, 252, 179);
pSymbolArray.AddSymbol((ISymbol) pFillSymbol);
pFillSymbol =(IFillSymbol) new SimpleFillSymbolClass(); //18-64
pFillSymbol.Color = GetRGBColor(213, 212, 252);
pSymbolArray.AddSymbol((ISymbol) pFillSymbol);
pFillSymbol =(IFillSymbol) new SimpleFillSymbolClass(); //65-up
pFillSymbol.Color = GetRGBColor(193, 252, 179);
pSymbolArray.AddSymbol((ISymbol) pFillSymbol);
pFillSymbol =(IFillSymbol) new SimpleFillSymbolClass();
pFillSymbol.Color = GetRGBColor(239, 228, 190);
pChartRenderer.ChartSymbol =(IChartSymbol) pBarChartSymbol;
pChartRenderer.BaseSymbol =(ISymbol) pFillSymbol;
pChartRenderer.Label = "Population";
pChartRenderer.UseOverposter = false;
layer=(IGeoFeatureLayer) axMap1.get_Layer(2);
layer.Renderer =(IFeatureRenderer) pChartRenderer;
axMap1.ActiveView.Refresh();
axTOC1.SetBuddyControl(axMap1.Object ) ;
axTOC1.Refresh();
}
catch (Exception err)
{
Console.WriteLine(err.Message );
}
}
private void m_Theme_BreakClass_Click(object sender, System.EventArgs e)
{
// ITable pTable ;
// IClassify pClassify ;
// ITableHistogram pTableHistogram ;
// IHistogram pHistogram ;
// object dataFrequency;
// object dataValues ;
//
// pTable = (ITable) axMap1.get_Layer(2);
// pTableHistogram = new BasicTableHistogramClass() ;
// pHistogram =(IHistogram) pTableHistogram;
//
// pTableHistogram.Field = "POP1990";
// pTableHistogram.Table = pTable;
// pHistogram.GetHistogram( out dataValues, out dataFrequency);
//
// pClassify = new EqualIntervalClass();
// pClassify.SetHistogramData(dataValues, dataFrequency);
double[] Classes ={9920007,19840014, 29760021} ;
int ClassesCount = 3;
// int numDesiredClasses = 3;
// pClassify.Classify(ref numDesiredClasses);
// Classes =(double[]) pClassify.ClassBreaks;
// ClassesCount = Classes.GetUpperBound(1);
IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();
pClassBreaksRenderer.Field = "POP1990";
pClassBreaksRenderer.BreakCount = ClassesCount;
pClassBreaksRenderer.SortClassesAscending = true;
IHsvColor pFromColor = new HsvColorClass() ;
pFromColor.Hue = 60 ; // Yellow;
pFromColor.Saturation = 100;
pFromColor.Value = 96;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -