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

📄 mainfrm.cs

📁 能够在PDA上运行的地图控件
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using LineViewLib;	//(矢量图控件)

namespace GisCtlDemo
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class MainFrm : System.Windows.Forms.Form
	{
		#region 自定义变量
		/// <summary>
		/// 矢量图控件
		/// </summary>
		private LineViewCtl m_LineViewer;
		/// <summary>
		/// 缓存最近一次选中的菜单项
		/// </summary>
		private MenuItem	m_LastCheckedMenuItem=null;

		#endregion

		#region 窗体设计器变量

		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem mnDrawDemo;
		private System.Windows.Forms.MenuItem mnOpenPic;
		private System.Windows.Forms.MenuItem mnSavePic;
		private System.Windows.Forms.MenuItem mnLayerMgr;
		private System.Windows.Forms.MenuItem mnNaviDlg;
		private System.Windows.Forms.MenuItem mnClosePic;
		private System.Windows.Forms.MenuItem mnExit;
		private System.Windows.Forms.MenuItem menuItem10;
		private System.Windows.Forms.MenuItem mnAbout;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.ToolBarButton toolBarButton5;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.MenuItem mnCurTool;
		private System.Windows.Forms.MenuItem mnToolPan;
		private System.Windows.Forms.MenuItem mnToolZoomRect;
		private System.Windows.Forms.MenuItem mnToolSelObj;
		private System.Windows.Forms.MenuItem mnToolSetCenter;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.MenuItem mnOptionsDlg;
		private System.Windows.Forms.MainMenu mainMenu1;
		#endregion

		public MainFrm()
		{
			InitializeComponent();
			//创建单线图浏览控件!
			this.m_LineViewer=new LineViewCtl();
			//设置在客户区位置
			this.m_LineViewer.Bounds=new Rectangle(0,0,this.Width,this.Height);
			//Init是一个重要的函数,必须创建后调用
			this.m_LineViewer.Init();
			this.m_LineViewer.Parent=this;
			this.m_LineViewer.MapObjectDbClk+=new MapObjectEventHandler(m_LineViewer_MapObjectDbClk);
		}
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}
		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainFrm));
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.mnExit = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.mnAbout = new System.Windows.Forms.MenuItem();
			this.menuItem10 = new System.Windows.Forms.MenuItem();
			this.mnDrawDemo = new System.Windows.Forms.MenuItem();
			this.mnOpenPic = new System.Windows.Forms.MenuItem();
			this.mnClosePic = new System.Windows.Forms.MenuItem();
			this.mnSavePic = new System.Windows.Forms.MenuItem();
			this.mnLayerMgr = new System.Windows.Forms.MenuItem();
			this.mnNaviDlg = new System.Windows.Forms.MenuItem();
			this.mnCurTool = new System.Windows.Forms.MenuItem();
			this.mnToolPan = new System.Windows.Forms.MenuItem();
			this.mnToolZoomRect = new System.Windows.Forms.MenuItem();
			this.mnToolSelObj = new System.Windows.Forms.MenuItem();
			this.mnToolSetCenter = new System.Windows.Forms.MenuItem();
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.mnOptionsDlg = new System.Windows.Forms.MenuItem();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.Add(this.menuItem1);
			// 
			// menuItem1
			// 
			this.menuItem1.MenuItems.Add(this.mnExit);
			this.menuItem1.MenuItems.Add(this.menuItem3);
			this.menuItem1.MenuItems.Add(this.mnAbout);
			this.menuItem1.MenuItems.Add(this.menuItem10);
			this.menuItem1.MenuItems.Add(this.mnDrawDemo);
			this.menuItem1.MenuItems.Add(this.mnOpenPic);
			this.menuItem1.MenuItems.Add(this.mnSavePic);
			this.menuItem1.MenuItems.Add(this.mnClosePic);
			this.menuItem1.MenuItems.Add(this.mnNaviDlg);
			this.menuItem1.MenuItems.Add(this.mnLayerMgr);
			this.menuItem1.MenuItems.Add(this.mnOptionsDlg);
			this.menuItem1.MenuItems.Add(this.menuItem2);
			this.menuItem1.MenuItems.Add(this.mnCurTool);
			this.menuItem1.Text = "矢量图控件";
			// 
			// mnExit
			// 
			this.mnExit.Text = "退出程序 exit";
			this.mnExit.Click += new System.EventHandler(this.mnExit_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Text = "-";
			// 
			// mnAbout
			// 
			this.mnAbout.Text = "关于本程序 about";
			this.mnAbout.Click += new System.EventHandler(this.mnAbout_Click);
			// 
			// menuItem10
			// 
			this.menuItem10.Text = "-";
			// 
			// mnDrawDemo
			// 
			this.mnDrawDemo.Text = "绘制样例 demo";
			this.mnDrawDemo.Click += new System.EventHandler(this.mnDrawDemo_Click);
			// 
			// mnOpenPic
			// 
			this.mnOpenPic.Text = "打开图形 open";
			this.mnOpenPic.Click += new System.EventHandler(this.mnOpenPic_Click);
			// 
			// mnClosePic
			// 
			this.mnClosePic.Text = "关闭图形 close";
			this.mnClosePic.Click += new System.EventHandler(this.mnClosePic_Click);
			// 
			// mnSavePic
			// 
			this.mnSavePic.Text = "保存图形 save";
			this.mnSavePic.Click += new System.EventHandler(this.mnSavePic_Click);
			// 
			// mnLayerMgr
			// 
			this.mnLayerMgr.Text = "图层管理 layer";
			this.mnLayerMgr.Click += new System.EventHandler(this.mnLayerMgr_Click);
			// 
			// mnNaviDlg
			// 
			this.mnNaviDlg.Text = "导航器 navi";
			this.mnNaviDlg.Click += new System.EventHandler(this.mnNaviDlg_Click);
			// 
			// mnCurTool
			// 
			this.mnCurTool.MenuItems.Add(this.mnToolPan);
			this.mnCurTool.MenuItems.Add(this.mnToolZoomRect);
			this.mnCurTool.MenuItems.Add(this.mnToolSelObj);
			this.mnCurTool.MenuItems.Add(this.mnToolSetCenter);
			this.mnCurTool.Text = "当前工具 tool";
			// 
			// mnToolPan
			// 
			this.mnToolPan.Text = "平移 pan";
			this.mnToolPan.Click += new System.EventHandler(this.mnToolPan_Click);
			// 
			// mnToolZoomRect
			// 
			this.mnToolZoomRect.Text = "矩形缩放 rect";
			this.mnToolZoomRect.Click += new System.EventHandler(this.mnToolZoomRect_Click);
			// 
			// mnToolSelObj
			// 
			this.mnToolSelObj.Text = "选取对象 capture";
			this.mnToolSelObj.Click += new System.EventHandler(this.mnToolSelObj_Click);
			// 
			// mnToolSetCenter
			// 
			this.mnToolSetCenter.Text = "设置中心点 center";
			this.mnToolSetCenter.Click += new System.EventHandler(this.mnToolSetCenter_Click);
			// 
			// toolBar1
			// 
			this.toolBar1.Buttons.Add(this.toolBarButton1);
			this.toolBar1.Buttons.Add(this.toolBarButton2);
			this.toolBar1.Buttons.Add(this.toolBarButton3);
			this.toolBar1.Buttons.Add(this.toolBarButton4);
			this.toolBar1.Buttons.Add(this.toolBarButton5);
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 1;
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 3;
			// 
			// toolBarButton5
			// 
			this.toolBarButton5.ImageIndex = 4;
			// 
			// imageList1
			// 
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource1"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource2"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource3"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource4"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource5"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource6"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource7"))));
			this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource8"))));
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			// 
			// menuItem2
			// 
			this.menuItem2.Text = "-";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 8;
			// 
			// mnOptionsDlg
			// 
			this.mnOptionsDlg.Text = "选项设置 option";
			this.mnOptionsDlg.Click += new System.EventHandler(this.mnOptionsDlg_Click);
			// 
			// MainFrm
			// 
			this.ClientSize = new System.Drawing.Size(240, 258);
			this.Controls.Add(this.toolBar1);
			this.Menu = this.mainMenu1;
			this.Text = "矢量图控件DEMO";

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>

		static void Main() 
		{
			Application.Run(new MainFrm());
		}

		/// <summary>
		/// 地图对象双击事件
		/// </summary>
		/// <param name="obj"></param>
		/// <param name="atlayer"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="cx"></param>
		/// <param name="cy"></param>
		private void m_LineViewer_MapObjectDbClk(IMapObject obj, LineViewLib.Layer atlayer, int x, int y, double cx, double cy)
		{
			string format="对象类型: {0} 所在图层:{1}\r\n鼠标客户区坐标: ({2},{3})\r\n鼠标地图坐标:({4},{5})";
			string info=string.Format(format,obj.MAPOBJECT_TYPE,atlayer.Name,x,y,Math.Round(cx,4),Math.Round(cy,4));
			MessageBox.Show(info,"地图对象信息",MessageBoxButtons.OK,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
		}

		#region MenuItem Click事件处理

		/// <summary>
		/// 退出
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mnExit_Click(object sender, System.EventArgs e)

⌨️ 快捷键说明

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