//鼠标按下 private void EagleEyeMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { try { if (EagleEyeMapControl.Map.LayerCount > 0) { //按下鼠标左键移动矩形框 if (e.button == 1) { //如果指针落在鹰眼的矩形框中,标记可移动 if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax) { bCanDrag = true; } pMoveRectPoint = new PointClass(); pMoveRectPoint.PutCoords(e.mapX, e.mapY); //记录点击的第一个点的坐标 } //按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle(); IPoint pTempPoint = new PointClass(); pTempPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2); Map.Extent = pEnvelope; //矩形框的高宽和数据试图的高宽不一定成正比,这里做一个中心调整 Map.CenterAt(pTempPoint); } } } catch (Exception exception) { Console.WriteLine(exception); } }
private void EagleEyeMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (EagleEyeMapControl.Map.LayerCount > 0) { //按下鼠标左键移动矩形框 if (e.button == 1) { //如果指针落在矩形框中,标记可移动 if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax) { bCanDrag = true; } pMoveRectPoint = new PointClass(); pMoveRectPoint.PutCoords(e.mapX, e.mapY);//记录点击的第一个坐标 } //按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle(); IPoint pTemPoint = new PointClass(); pTemPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2); mainMapControl.Extent = pEnvelope; //矩形框的高宽和数据视图的高度不一定成正比,这里要做一个中心调整 mainMapControl.CenterAt(pTemPoint); } } }
/// <summary> /// 鹰眼地图控制器按下事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EagleEyeMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { //if (EagleEyeMapControl.Map.LayerCount > 0) //{ // // 按下鼠标左键,移动矩形框 // if (e.button == 1) // { // if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax) // { // CanDrag = true; // } // MoveRectPoint = new PointClass(); // // 记录点击的第一个点的坐标 // MoveRectPoint.PutCoords(e.mapX, e.mapY); // } // //按下鼠标右键绘制矩形框 // else if (e.button == 2) // { // IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle(); // IPoint pTempPoint = new PointClass(); // pTempPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2); // MainMapControl.Extent = pEnvelope; // //矩形框的高宽和数据试图的高宽不一定成正比,这里做一个中心调整 // MainMapControl.CenterAt(pTempPoint); // } //} if (EagleEyeMapControl.Map.LayerCount > 0) { //按下鼠标左键移动矩形框 if (e.button == 1) { //如果指针落在鹰眼的矩形框中,标记可移动 if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax) { CanDrag = true; } MoveRectPoint = new PointClass(); MoveRectPoint.PutCoords(e.mapX, e.mapY); //记录点击的第一个点的坐标 } //按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle(); IPoint pTempPoint = new PointClass(); pTempPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2); MainMapControl.Extent = pEnvelope; //矩形框的高宽和数据试图的高宽不一定成正比,这里做一个中心调整 MainMapControl.CenterAt(pTempPoint); } } }
private void EagleEyeMapControl_OnMouseUp(object sender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseUpEvent e) { if (EagleEyeMapControl.Map.LayerCount > 0) { if (e.button == 1) { if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax) { bCanDrag = true; } pMoveRectPoint = new PointClass(); pMoveRectPoint.PutCoords(e.mapX, e.mapY); } else if (e.button == 2) { IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle(); IPoint pTemPoint = new PointClass(); pTemPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2); axMapControl3.Extent = pEnvelope; //对矩形做一个中心调整 axMapControl3.CenterAt(pTemPoint); } } }