/// <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); }
public void zoominbyrectangle(System.Drawing.Rectangle screenrect) { GisSmartTools.Geometry.Rectangle rect = ToMapRect(screenrect); moffsetX = rect.minX; moffsetY = rect.maxY; double scale_x = (rect.maxX - rect.minX) / bitmap_X; double scale_y = (rect.maxY - rect.minY) / bitmap_Y; if (scale_x < scale_y) { DisplayScale = scale_y; } else { DisplayScale = scale_x; } RaiseDisplayScaleChanged(this); }
/// <summary> /// 该函数赋予显示参数的初值,同时可以用于显示全图的功能 /// </summary> /// <param name="mapcontent"></param> public void SetDefaultoffsetandDisplayScale(mapcontent mapcontent) { Geometry.Rectangle rect = mapcontent.GetRefernectRectangle(); if (rect.minX >= rect.maxX || rect.minY >= rect.maxY) { DisplayScale = 1; moffsetX = 0; moffsetY = 0; return; } double scale_x = (rect.maxX - rect.minX) / bitmap_X; double scale_y = (rect.maxY - rect.minY) / bitmap_Y; if (scale_x < scale_y) { DisplayScale = scale_y; } else { DisplayScale = scale_x; } moffsetX = rect.minX; moffsetY = rect.maxY; }
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; } }