/// <summary> /// /// </summary> /// <param name="collection"></param> /// <param name="mouselocation"></param> /// <returns></returns> private bool CheckIsMouseInFeatureCollection(FeatureCollection collection, Point mouselocation) { screen_rect = new System.Drawing.Rectangle(mouselocation.X - 2, mouselocation.Y - 2, 4, 4); GisSmartTools.Geometry.Rectangle maprect_select = ToMapRect(screen_rect); Filter_Envelop filter_edit_selected = new Filter_Envelop(maprect_select, editmanager.rstransform); for (int i = 0; i < collection.featureList.Count; i++) { if (filter_edit_selected.Evaluate(collection.featureList[i])) { return(true); } } return(false); }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { RSTransform rstransform = new RSTransform_WGS84_WEBMOCARTO(); switch (MapOption) { case MapOptionStatus.ZoomIn: if ((screen_rect.Width <= 4 && screen_rect.Height <= 4)) { PointD upPoint = new PointD(e.X, e.Y); PointD sMapPoint = ToMapPoint(upPoint); ZoomByCenter(sMapPoint, mcZoomRation); mapcontrol_refresh(); } else { zoominbyrectangle(screen_rect); mapcontrol_refresh(); } break; case MapOptionStatus.Identify: if (screen_rect.Width <= 4 && screen_rect.Height <= 4) { screen_rect = new System.Drawing.Rectangle(e.X - interval, e.Y - interval, 2 * interval, 2 * interval); } GisSmartTools.Geometry.Rectangle maprect = ToMapRect(screen_rect); if (mapcontent.layerlist.Count == 0) { return; } if (focuslayer == null) { focuslayer = mapcontent.layerlist[0]; } //获取坐标转换接口函数 Filter_Envelop filter = new Filter_Envelop(maprect, rstransform); FeatureCollection collection = focuslayer.featuresource.GetFeatures(filter); if (collection.featureList.Count != 0) { paintadditionalfeaturecollection(collection); RaiseAfterSelectedFeaturesEvent(collection); } else { mapcontrol_refresh(); } break; case MapOptionStatus.Pan: break; case MapOptionStatus.Edit: if (e.Button == System.Windows.Forms.MouseButtons.Left) { switch (editmanager.editstatus) { case EditStatus.editing: editmanager.Addpoint(editmanager.rstransform.targetToSource(ToMapPoint(new PointD(e.X, e.Y)))); break; case EditStatus.finished: if (screen_rect.Width <= 4 && screen_rect.Height <= 4) { screen_rect = new System.Drawing.Rectangle(e.X - interval, e.Y - interval, 2 * interval, 2 * interval); } GisSmartTools.Geometry.Rectangle maprect_select_edit = ToMapRect(screen_rect); Layer tmplayer = this.mapcontent.GetLayerByName(editmanager.layername); if (tmplayer == null) { this.mapcontrol_refresh(); return; } //获取坐标转换接口函数 Filter_Envelop filter_select_edit = new Filter_Envelop(maprect_select_edit, rstransform); editmanager.selectedFeatureCollection = tmplayer.featuresource.GetFeatures(filter_select_edit); if (editmanager.selectedFeatureCollection.featureList.Count != 0) { paintadditionalfeaturecollection(editmanager.selectedFeatureCollection); editmanager.editstatus = EditStatus.selected; } else { mapcontrol_refresh(); } break; } } break; case MapOptionStatus.select: if (screen_rect.Width <= 4 && screen_rect.Height <= 4) { screen_rect = new System.Drawing.Rectangle(e.X - interval, e.Y - interval, 2 * interval, 2 * interval); } GisSmartTools.Geometry.Rectangle maprect_select = ToMapRect(screen_rect); if (mapcontent.layerlist.Count == 0) { return; } if (focuslayer == null) { focuslayer = mapcontent.layerlist[0]; } //获取坐标转换接口函数 Filter_Envelop filter_select = new Filter_Envelop(maprect_select, rstransform); FeatureCollection collection_select = focuslayer.featuresource.GetFeatures(filter_select); if (collection_select.featureList.Count != 0) { paintadditionalfeaturecollection(collection_select); } else { mapcontrol_refresh(); } break; } }