using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MapInfo.Mapping;
using MapInfo.Geometry;
using MapInfo.Data;
using MapInfo.Engine;
using MapInfo.Styles;
namespace EagleEyeMap
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.mapControl1.Map.Load(MapLoader.CreateFromFile(@"E:\PJ\fiber2\bin\center\debug\Map\CZ\*.gst"));
this.mapControl1.Map.Zoom = new Distance(10, DistanceUnit.Kilometer);
this.mapControl2.Map.Load(MapLoader.CreateFromFile(@"E:\PJ\fiber2\bin\center\debug\Map\CZ\*.gst"));
this.mapControl2.Map.Zoom = new Distance(160, DistanceUnit.Kilometer);
}
private void mapControl1_ViewerChanged(object sender, EventArgs e)
{
Table tableTemp = Session.Current.Catalog.GetTable("EagleEyeTemp");
DRect rect = mapControl1.Map.Bounds;
FeatureGeometry fg = new MapInfo.Geometry.Rectangle(mapControl1.Map.GetDisplayCoordSys(), rect);
SimpleLineStyle vLine = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Pixel), 2, Color.Blue,true);
SimpleInterior vInter = new SimpleInterior(9, Color.Blue, Color.Blue);
CompositeStyle cStyle = new CompositeStyle(new AreaStyle(vLine, vInter), null, null, null);
Feature f = new Feature(fg, cStyle);
tableTemp.InsertFeature(f);
if (mapControl2.Map != null)
{
DPoint[] StartEnd = new DPoint[2];
StartEnd[0].x = 0;
StartEnd[0].y = fg.Centroid.y;
StartEnd[1].x = mapControl2.Map.GetDisplayCoordSys().Bounds.x2;
StartEnd[1].y = fg.Centroid.y;
FeatureGeometry line1 = new MultiPolygon(mapControl1.Map.GetDisplayCoordSys(), CurveSegmentType.Linear, StartEnd);
SimpleLineStyle vLineLine1 = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Point), 2, Color.Blue);
SimpleInterior vInterLine1 = new SimpleInterior(9, Color.Blue, Color.Blue, true);
CompositeStyle cStyleLine1 = new CompositeStyle(new AreaStyle(vLineLine1, vInterLine1), null, null, null);
Feature fLine1 = new Feature(line1, cStyleLine1);
tableTemp.InsertFeature(fLine1);
StartEnd[0].x = fg.Centroid.x;
StartEnd[0].y = 0;
StartEnd[1].x = fg.Centroid.x;
StartEnd[1].y = mapControl2.Map.GetDisplayCoordSys().Bounds.y1;
FeatureGeometry line2 = new MultiPolygon(mapControl1.Map.GetDisplayCoordSys(), CurveSegmentType.Linear, StartEnd);
SimpleLineStyle vLineLine2 = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Point), 2, Color.Blue);
SimpleInterior vInterLine2 = new SimpleInterior(9, Color.Blue, Color.Blue, true);
CompositeStyle cStyleLine2 = new CompositeStyle(new AreaStyle(vLineLine2, vInterLine2), null, null, null);
Feature fLine2 = new Feature(line2, cStyleLine2);
tableTemp.InsertFeature(fLine2);
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.mapControl2.MouseWheelSupport = new MouseWheelSupport(MouseWheelBehavior.None, 10, 5);
TableInfoMemTable ti = new TableInfoMemTable("EagleEyeTemp");
ti.Temporary = true;
Column column;
column = new GeometryColumn(mapControl2.Map.GetDisplayCoordSys());
column.Alias = "MI_Geometry";
column.DataType = MIDbType.FeatureGeometry;
ti.Columns.Add(column);
//ti.Columns.Add(column);
column = new Column();
column.Alias = "MI_Style";
column.DataType = MIDbType.Style;
ti.Columns.Add(column);
Table table = Session.Current.Catalog.CreateTable(ti);
FeatureLayer eagleEye = new FeatureLayer(table, "EagleEye", "MyEagleEye");
//mapControl2.Map.Layers.Insert(0, eagleEye);
mapControl1.Map.Layers.Add(eagleEye);
mapControl2.Tools.LeftButtonTool = "Arrow";
}
private void mapControl2_MouseClick(object sender, MouseEventArgs e)
{
DPoint pt = new DPoint();
mapControl2.Map.DisplayTransform.FromDisplay(e.Location, out pt);
mapControl1.Map.Center = pt;
}
}
}
鹰眼功能
最新推荐文章于 2024-05-15 15:02:10 发布