c#制作Symbol选择对话框
现在要实现双击toccontrol中的某一层的symbol调出symbol选择对话框.vb中有示例实现了类似于arcmap中的symbol选择对话框,用到了ISymbolSelector接口. 你看的是AO的例子,在ENGINE中是没有这个接口的,不过这个例子转换成C#的代码如下:
private void axTOCCtl_OnDoubleClick(object nder, ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnDoubleClickEvent e)
{
IBasicMap map = null;
object pOther = null;
object index = null;
if (e.button==1)
{
m_TOCControl.HitTest(e.x, e.y, ref m_TocItem, ref map, ref m_TocLayer, ref pOther, ref index);
System.Drawing.Point pos=new System.Drawing.Point(e.x,e.y);
if (this.m_TocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
{
ESRI.ArcGIS.Carto.ILegendClass pLC=new LegendClassClass();
ESRI.ArcGIS.Carto.ILegendGroup pLG=new LegendGroupClass();
if(pOther is ILegendGroup)
{
pLG=(ILegendGroup)pOther;
}
_Class((int)index);
ISymbol pSym;
pSym=pLC.Symbol;
ESRI.ArcGIS.DisplayUI.ISymbolSelector pSS=new ESRI.ArcGIS.DisplayUI.SymbolSelectorClass();
bool bOK=fal;
汽车违章查询系统
pSS.AddSymbol(pSym);
bOK=pSS.SelectSymbol(0);
if (bOK)
{
pLC.Symbol=pSS.GetSymbolAt(0);
}
this.axMapCtl.ActiveView.Refresh();
this.axTOCCtl.Refresh();
}
}
}
那么在c#中怎么实现呢?有相应的接口吗?
如何实现在MAP空间里选择一块区域打印
如何实现在MAP空间里选择一块区域打印?用ARCENGINE里的对象实现,大家都来说说啊
把选择的区域对每一个图层做区域切割进保存为shap文件在本地.
在对每一个图层做shap文件保存的时候,同时把保存好的shap文件用本地文件的方式加载到一个MapControl控件(或者其它控件,我是自己用PictureBox来显示地图的).
然后通过控件把显示的地图数据打印出来就可以了.
其中对图层进行切割的代码如下:
'‖=================================================
'‖TrimFeatureClass2ShpFile: 裁剪到shape文件
'‖
'‖pFC: 裁剪的实体类
'‖pPolygon: 裁剪的范围
'‖strShpFileName: 输出的shape文件名
'‖bShowProgress: 是否显示进度条
'‖pTrimedFeatureClass:输出的FeatureClass
'‖返回:输出的FeatureClass,nothing - 失败
'‖=================================================
Public Function TrimFeatureClass2ShpFile(pFC As esriGeoDataba.IFeatureClass, pPolygon As esriGeometry.IPolygon, strShpFileName As String, bShowProgress As Boolean) As esriGeoDataba.IFeatureClass
飞信活动
On Error GoTo ErrorHandler
Set TrimFeatureClass2ShpFile = Nothing
Dim i As Long
Dim pos As Long
Dim pFeatureCursor As esriGeoDataba.IFeatureCursor
Dim pFeature As esriGeoDataba.IFeature
Dim pNewFeatureCursor As esriGeoDataba.IFeatureCursor
Dim pTopologicalOperator As esriGeometry.ITopologicalOperator
Dim pGeometry As esriGeometry.IGeometry
Dim pFeatureBuffer As esriGeoDataba.IFeatureBuffer
Dim pFeatureCount As Long
Dim pTrimedFeatureClass As IFeatureClass
Dim nOldPercent As Integer
'获取数据库系统时间
Dim pSpatialFilter As esriGeoDataba.ISpatialFilter
Set pSpatialFilter = New SpatialFilter
Dim pFeatureLayer As esriCarto.IFeatureLayer
With pSpatialFilter
'一分一档设置筛选器实体
Set .Geometry = pPolygon
'设置筛选字段
.GeometryField = pFC.ShapeFieldName
'设置空间关系
非主流土味情话 .SpatialRel = esriSpatialRelIntercts
'设置查询顺序
.SearchOrder = esriSearchOrderSpatial
End With
'获取筛选的实体个数
pFeatureCount = pFC.FeatureCount(pSpatialFilter)
'判断筛选个数为0
If pFeatureCount = 0 Then
Set pSpatialFilter = Nothing
Exit Function
End If
'创建新的SHAPE文件
Set pTrimedFeatureClass = CreateNewShapefile(pFC, strShpFileName)
'判断实体类为空
If pTrimedFeatureClass Is Nothing Then
'设置对象为空
Set pSpatialFilter = Nothing
Exit Function
End If
'获取实体指针
Set pFeatureCursor = pFC.Search(pSpatialFilter, Fal)
Set pSpatialFilter = Nothing
'获取实体
Set pFeature = pFeatureCursor.NextFeature
nOldPercent = 0
'获取插入实体指针
Set pNewFeatureCursor = pTrimedFeatureClass.Inrt(True)
'判断实体不为空
Do While Not pFeature Is Nothing
'创建实体缓冲
Set pFeatureBuffer = pTrimedFeatureClass.CreateFeatureBuffer
If pFC.ShapeType = esriGeometryPolygon Then
' 若实体类型为面,则做相交
Set pTopologicalOperator = pPolygon
Set pGeometry = pTopologicalOperator.InterSect(pFeature.Shape, esriGeometry2Dimension)
ElIf pFC.ShapeType = esriGeometryPolyline Then
'若实体类型为线
Set pGeometry = PolygonInterctPolyline(pPolygon, pFeature.Shape)
ElIf pFC.ShapeType = esriGeometryPoint Then
' 若实体类型为点,则全是
Set pGeometry = pFeature.Shape
ElIf pFC.ShapeType = esriGeometryMultipoint Then
' 若实体类型为多点
Set pGeometry = PolygonInterctMultiPoint(pPolygon, pFeature.Shape)
El
MsgBox "不做任何裁剪!"
' 若实体类型为除点、线、面外的类型,不做裁剪游园不值译文
Exit Function
End If
'判断实体不为空
If Not pGeometry Is Nothing Then
If Not pGeometry.IsEmpty Then
'获取实体
Set pFeatureBuffer.Shape = pGeometry
For i = 0 To pFeature.Fields.fieldCount - 1
' 因shape字段最长只能为10位,故只比较前10位
pos= pFeatureBuffer.Fields.FindField(Left(pFeature.Fields.field(i).Name, 10))
If pos >= 0 Then
'判断实体字段类型不为几何类型并且不为OID类型并且字段可编辑并且字段不为空
If Not pFeatureBuffer.Fields.field(pos).Type = esriFieldTypeGeometry And _Not pFeatureBuffer.Fields.field(pos).Type=esriFieldTypeOIDAnd _pFeatureBuffer.Fields.field(pos).Editable And _Not IsNull(pFeature.value(i)) Then
'获取字段值
pFeatureBuffer.value(pos) = pFeature.value(i)余诗曼
End If
End If
Next i
'插入实体
pNewFeatureCursor.InrtFeature pFeatureBuffer
End If
End If
被动语态的构成 '女一获取实体
Set pFeature = pFeatureCursor.NextFeature
If bShowProgress Then
With frmProgress
'进度条当前值加一
.ProgressBar1.value = .ProgressBar1.value + 1
If Int(.ProgressBar1.value * 100 / .ProgressBar1.Max) > nOldPercent Then
.Statuslbl1.Caption = "正在导出" & pFC.AliasName & "层,请稍候..." & Format(.ProgressBar1.value / .ProgressBar1.Max, "###%")
nOldPercent = Int(.ProgressBar1.value * 100 / .ProgressBar1.Max)
pNewFeatureCursor.Flush
DoEvents
End If
End With
End If
Loop
pNewFeatureCursor.Flush