⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.cs

📁 最主要的描述了鹰眼功能的实现其中还有源码。谢谢大家下载!
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
//用户添加命名空间
using MapInfo.Windows.Dialogs;
using MapInfo.Mapping;
using MapInfo.Engine ;
using MapInfo.Data;
using MapInfo.Geometry;
using MapInfo.Styles;
using MapInfo.Tools;


namespace prjTNT
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class frmMain : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mnuMain;
		private System.Windows.Forms.MenuItem mnuFile;
		private System.Windows.Forms.MenuItem mnuOpenMap;
		private System.Windows.Forms.MenuItem mnuExit;
		private System.Windows.Forms.MenuItem mnuLine1;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton1;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton2;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton3;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton4;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton5;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton6;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton7;
		private MapInfo.Windows.Controls.MapToolBarButton mapToolBarButton9;
		private System.Windows.Forms.MenuItem mnuView;
		private System.Windows.Forms.MenuItem mnuDispToolBar;
		private System.Windows.Forms.MenuItem mnuDispEye;
		private MapInfo.Windows.Controls.MapToolBar mapToolBarMain;
		private System.Windows.Forms.StatusBar statusBarMain;
		private System.Windows.Forms.Panel panEye;
		private MapInfo.Windows.Controls.MapControl mapMain;
		private System.Windows.Forms.MenuItem mnuStatusBar;
		private MapInfo.Windows.Controls.MapControl mapEye;
        private System.Windows.Forms.ToolBarButton toolViewEntire;
		private System.Windows.Forms.ToolBarButton toolSelectNone;
		private System.ComponentModel.IContainer components=null;
		private System.Windows.Forms.ToolBarButton toolBarRuler;

		//用户定义变量		
		private bool boolEyeMove ;
		private double dblDistance;
		private System.Windows.Forms.ToolBarButton toolBarArea;
		private MapInfo.Geometry.DPoint dptStart;
		private System.Collections.ArrayList arrlstPoints=new ArrayList();
		private MapInfo.Geometry.DPoint dptFirstPoint;

		
		public frmMain()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			InitUserAddProc();		
	

			
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.mnuMain = new System.Windows.Forms.MainMenu();
			this.mnuFile = new System.Windows.Forms.MenuItem();
			this.mnuOpenMap = new System.Windows.Forms.MenuItem();
			this.mnuLine1 = new System.Windows.Forms.MenuItem();
			this.mnuExit = new System.Windows.Forms.MenuItem();
			this.mnuView = new System.Windows.Forms.MenuItem();
			this.mnuDispToolBar = new System.Windows.Forms.MenuItem();
			this.mnuStatusBar = new System.Windows.Forms.MenuItem();
			this.mnuDispEye = new System.Windows.Forms.MenuItem();
			this.mapToolBarMain = new MapInfo.Windows.Controls.MapToolBar();
			this.mapToolBarButton1 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton2 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.toolViewEntire = new System.Windows.Forms.ToolBarButton();
			this.mapToolBarButton4 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton3 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton5 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton6 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton7 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.mapToolBarButton9 = new MapInfo.Windows.Controls.MapToolBarButton();
			this.toolSelectNone = new System.Windows.Forms.ToolBarButton();
			this.toolBarRuler = new System.Windows.Forms.ToolBarButton();
			this.toolBarArea = new System.Windows.Forms.ToolBarButton();
			this.mapMain = new MapInfo.Windows.Controls.MapControl();
			this.statusBarMain = new System.Windows.Forms.StatusBar();
			this.panEye = new System.Windows.Forms.Panel();
			this.mapEye = new MapInfo.Windows.Controls.MapControl();
			this.panEye.SuspendLayout();
			this.SuspendLayout();
			// 
			// mnuMain
			// 
			this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnuFile,
																					this.mnuView});
			// 
			// mnuFile
			// 
			this.mnuFile.Index = 0;
			this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnuOpenMap,
																					this.mnuLine1,
																					this.mnuExit});
			this.mnuFile.Text = "文件(&F)";
			// 
			// mnuOpenMap
			// 
			this.mnuOpenMap.Index = 0;
			this.mnuOpenMap.Text = "打开地图(&O)";
			this.mnuOpenMap.Click += new System.EventHandler(this.mnuOpenMap_Click);
			// 
			// mnuLine1
			// 
			this.mnuLine1.Index = 1;
			this.mnuLine1.Text = "-";
			// 
			// mnuExit
			// 
			this.mnuExit.Index = 2;
			this.mnuExit.Text = "退出(&X)";
			this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
			// 
			// mnuView
			// 
			this.mnuView.Index = 1;
			this.mnuView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnuDispToolBar,
																					this.mnuStatusBar,
																					this.mnuDispEye});
			this.mnuView.Text = "视图(&V)";
			// 
			// mnuDispToolBar
			// 
			this.mnuDispToolBar.Checked = true;
			this.mnuDispToolBar.Index = 0;
			this.mnuDispToolBar.Text = "显示工具栏";
			this.mnuDispToolBar.Click += new System.EventHandler(this.mnuDispToolBar_Click);
			// 
			// mnuStatusBar
			// 
			this.mnuStatusBar.Checked = true;
			this.mnuStatusBar.Index = 1;
			this.mnuStatusBar.Text = "显示状态栏";
			this.mnuStatusBar.Click += new System.EventHandler(this.mnuStatusBar_Click);
			// 
			// mnuDispEye
			// 
			this.mnuDispEye.Index = 2;
			this.mnuDispEye.Text = "显示鹰眼";
			this.mnuDispEye.Click += new System.EventHandler(this.mnuDispEye_Click);
			// 
			// mapToolBarMain
			// 
			this.mapToolBarMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																							  this.mapToolBarButton1,
																							  this.mapToolBarButton2,
																							  this.toolViewEntire,
																							  this.mapToolBarButton4,
																							  this.mapToolBarButton3,
																							  this.mapToolBarButton5,
																							  this.mapToolBarButton6,
																							  this.mapToolBarButton7,
																							  this.mapToolBarButton9,
																							  this.toolSelectNone,
																							  this.toolBarRuler,
																							  this.toolBarArea});
			this.mapToolBarMain.DropDownArrows = true;
			this.mapToolBarMain.Location = new System.Drawing.Point(0, 0);
			this.mapToolBarMain.MapControl = this.mapMain;
			this.mapToolBarMain.Name = "mapToolBarMain";
			this.mapToolBarMain.ShowToolTips = true;
			this.mapToolBarMain.Size = new System.Drawing.Size(696, 28);
			this.mapToolBarMain.TabIndex = 0;
			this.mapToolBarMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.mapToolBarMain_ButtonClick);
			// 
			// mapToolBarButton1
			// 
			this.mapToolBarButton1.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.ZoomIn;
			this.mapToolBarButton1.ToolTipText = "放大";
			// 
			// mapToolBarButton2
			// 
			this.mapToolBarButton2.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.ZoomOut;
			this.mapToolBarButton2.ToolTipText = "缩小";
			// 
			// toolViewEntire
			// 
			this.toolViewEntire.Enabled = false;
			this.toolViewEntire.ImageIndex = 54;
			this.toolViewEntire.Tag = "viewEntire";
			this.toolViewEntire.ToolTipText = "整图显示";
			// 
			// mapToolBarButton4
			// 
			this.mapToolBarButton4.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.Pan;
			this.mapToolBarButton4.ToolTipText = "平移";
			// 
			// mapToolBarButton3
			// 
			this.mapToolBarButton3.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.Center;
			this.mapToolBarButton3.ToolTipText = "居中";
			// 
			// mapToolBarButton5
			// 
			this.mapToolBarButton5.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.Select;
			this.mapToolBarButton5.ToolTipText = "选择";
			// 
			// mapToolBarButton6
			// 
			this.mapToolBarButton6.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.SelectRectangle;
			this.mapToolBarButton6.ToolTipText = "框选";
			// 
			// mapToolBarButton7
			// 
			this.mapToolBarButton7.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.SelectRadius;
			this.mapToolBarButton7.ToolTipText = "圆选";
			// 
			// mapToolBarButton9
			// 
			this.mapToolBarButton9.ButtonType = MapInfo.Windows.Controls.MapToolButtonType.SelectPolygon;
			this.mapToolBarButton9.ToolTipText = "多边形选择";
			// 
			// toolSelectNone
			// 
			this.toolSelectNone.Enabled = false;
			this.toolSelectNone.ImageIndex = 48;
			this.toolSelectNone.Tag = "selectNone";
			this.toolSelectNone.ToolTipText = "撤销选择";
			// 
			// toolBarRuler
			// 
			this.toolBarRuler.Enabled = false;
			this.toolBarRuler.ImageIndex = 11;
			this.toolBarRuler.Tag = "ruler";
			this.toolBarRuler.ToolTipText = "测量距离";
			// 
			// toolBarArea
			// 
			this.toolBarArea.Enabled = false;
			this.toolBarArea.ImageIndex = 30;
			this.toolBarArea.Tag = "Area";
			this.toolBarArea.ToolTipText = "测量面积";
			// 
			// mapMain
			// 
			this.mapMain.Dock = System.Windows.Forms.DockStyle.Fill;
			this.mapMain.IgnoreLostFocusEvent = false;
			this.mapMain.Location = new System.Drawing.Point(0, 28);
			this.mapMain.Name = "mapMain";
			this.mapMain.Size = new System.Drawing.Size(696, 474);
			this.mapMain.TabIndex = 1;
			this.mapMain.Text = "mapMain";
			// 
			// statusBarMain
			// 
			this.statusBarMain.Location = new System.Drawing.Point(0, 480);
			this.statusBarMain.Name = "statusBarMain";
			this.statusBarMain.Size = new System.Drawing.Size(696, 22);
			this.statusBarMain.TabIndex = 2;
			// 
			// panEye
			// 
			this.panEye.BackColor = System.Drawing.Color.White;
			this.panEye.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.panEye.Controls.Add(this.mapEye);
			this.panEye.Location = new System.Drawing.Point(416, 264);
			this.panEye.Name = "panEye";
			this.panEye.Size = new System.Drawing.Size(280, 216);
			this.panEye.TabIndex = 3;
			this.panEye.Visible = false;
			// 
			// mapEye
			// 
			this.mapEye.Dock = System.Windows.Forms.DockStyle.Fill;
			this.mapEye.IgnoreLostFocusEvent = false;
			this.mapEye.Location = new System.Drawing.Point(0, 0);
			this.mapEye.Name = "mapEye";
			this.mapEye.Size = new System.Drawing.Size(278, 214);
			this.mapEye.TabIndex = 0;
			this.mapEye.Text = "mapControl2";
			this.mapEye.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mapEye_MouseUp);
			this.mapEye.MouseMove += new System.Windows.Forms.MouseEventHandler(this.mapEye_MouseMove);
			this.mapEye.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mapEye_MouseDown);
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(696, 502);
			this.Controls.Add(this.panEye);
			this.Controls.Add(this.statusBarMain);
			this.Controls.Add(this.mapMain);
			this.Controls.Add(this.mapToolBarMain);
			this.ImeMode = System.Windows.Forms.ImeMode.On;
			this.Menu = this.mnuMain;
			this.Name = "frmMain";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Resize += new System.EventHandler(this.frmMain_Resize);
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);
			this.Load += new System.EventHandler(this.frmMain_Load);
			this.panEye.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void InitUserAddProc()
		{
			//添加地图变化事件
			mapMain.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged);

			//添加鼠标点击地图后事件
			this.mapMain.Tools.Used += new MapInfo.Tools.ToolUsedEventHandler(Tools_Used);

			//添加自定义测量距离
			mapMain.Tools.Add("DistanceTool", new CustomPolylineMapTool(true,true,true,	mapMain.Viewer, mapMain.Handle.ToInt32(), mapMain.Tools,mapMain.Tools.MouseToolProperties, mapMain.Tools.MapToolProperties));

			//添加自定义测量面积
			mapMain.Tools.Add("AreaTool", new CustomPolygonMapTool(true,true,true,	mapMain.Viewer, mapMain.Handle.ToInt32(), mapMain.Tools,mapMain.Tools.MouseToolProperties, mapMain.Tools.MapToolProperties));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -