public void UpdateFeatureInfos(MapUtil.FeatureInformations featureInfos, Point mousePosition) { this.lsvFeatureProperties.Items.Clear(); if (featureInfos == null) { this.Hide(); } else { this.lsvFeatureProperties.Items.Clear(); Dictionary <string, string> .KeyCollection oFieldsCollection = featureInfos.FieldsAndValuesCollection.Keys; string sValue; foreach (string sFieldName in oFieldsCollection) { this.lsvFeatureProperties.Items.Add(sFieldName); featureInfos.FieldsAndValuesCollection.TryGetValue(sFieldName, out sValue); this.lsvFeatureProperties.Items[this.lsvFeatureProperties.Items.Count - 1].SubItems.Add(sValue); } this.labLayerInfos.Text = string.Format("ͼ²ã : {0}", featureInfos.CurrentLayerInfos.AliasName); if (!this.Visible) { this.Show(); } this.Location = mousePosition; this.Activate(); } }
private void mapControl_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e) { MapObjects2.Point oMousePosition = mapControl.ToMapPoint(e.x, e.y); MapUtil.MapOperation oMapOper = new GPSTrackingMonitor.MapUtil.MapOperation(); switch (GlobeVariables.CurrentOperation) { case GPSTrackingMonitor.MapUtil.MapOperationType.ZoomIn: oMapOper.ZoomInMap(mapControl.TrackRectangle(),ref mapControl); break; case GPSTrackingMonitor.MapUtil.MapOperationType.ZoomOut: oMapOper.ZoomOutMap(mapControl.TrackRectangle(), ref mapControl); break; case GPSTrackingMonitor.MapUtil.MapOperationType.Pan: mapControl.Pan(); break; case GPSTrackingMonitor.MapUtil.MapOperationType.Measure: this._measureLine = mapControl.TrackLine(); this.labMeasure.Text = string.Format("长度 : {0} 米", oMapOper.ComputeDistance(this._measureLine).ToString()); break; case GPSTrackingMonitor.MapUtil.MapOperationType.Identify: MapUtil.FeatureInformations oFeatureInfos = oMapOper.GetIdentifyFeatureInfos(oMousePosition, this.mapControl,GlobeVariables.MapInfosCollection); this._frmIdentify.UpdateFeatureInfos(oFeatureInfos, MousePosition); break; case GPSTrackingMonitor.MapUtil.MapOperationType.FetchPoint: this.OnPointFetched(oMousePosition); break; default: break; } }
public FeatureInformations GetIdentifyFeatureInfos(MapObjects2.Point mousePosition, AxMapObjects2.AxMap mapControl, MapProject.MapStruct mapInfosCollection) { FeatureInformations oFeatureInfos = null; foreach (ILayerStruct oLayerInfos in mapInfosCollection.Layers) { if (oLayerInfos.LayerType != (short)LayerTypeConstants.moMapLayer) { continue; } MapUtil.MapOperation oMapOper = new MapOperation(); MapObjects2.MapLayer oMapLayer = oMapOper.GetLayerByName(mapControl, oLayerInfos.AliasName) as MapObjects2.MapLayer; if (oMapLayer.Visible == false) { continue; } Recordset oSelectedRecords = oMapLayer.SearchShape(mousePosition, SearchMethodConstants.moAreaIntersect, ""); if (oSelectedRecords.EOF) { continue; } oSelectedRecords.MoveFirst(); oFeatureInfos = new FeatureInformations(); oFeatureInfos.CurrentLayerInfos = oLayerInfos; oFeatureInfos.Geometry = oSelectedRecords.Fields.Item("shape").Value; TableDesc oTableDesc = oSelectedRecords.TableDesc; oFeatureInfos.FieldsAndValuesCollection = new Dictionary <string, string>(); int iFieldsCount = oTableDesc.FieldCount; string sFieldName = ""; string sValue = ""; for (short i = 0; i < iFieldsCount; i++) { sFieldName = oTableDesc.get_FieldName(i); sValue = oSelectedRecords.Fields.Item(sFieldName).ValueAsString; oFeatureInfos.FieldsAndValuesCollection.Add(sFieldName, sValue); } break; } return(oFeatureInfos); }