鹰眼功能

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;
        }
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值