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

📄 mapdisplay.cs

📁 c#编写的汽车销售公司erp进销存系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using CallCenter.BusinessInterfaces.BaseForms;
using CallCenter.Modules;
using CallCenter.BusinessLayer;
using CallCenter.BusinessInterfaces;
using CallCenter.BusinessInterfaces.BaseForms.Models;

namespace CallCenter.BusinessInterfaces.MainForms
{
	/// <summary>
	/// MapDisplay 的摘要说明。
	/// </summary>
	public class MapDisplay : System.Windows.Forms.Form
	{
		private System.ComponentModel.IContainer components;
		private double dis=0,dissum=0;
		private System.Windows.Forms.Timer timer1;
		private AxMapXLib.AxMap axMap1;
	
		public MapDisplay()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}
		public MapDisplay(int x,int y)
		{
			
		}
		public MapDisplay(AxMapXLib.AxMap map)
		{
			InitializeComponent();
			DisplaySpOnMap("yuan");
			
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		[System.Runtime.InteropServices.DllImport("user32")]
		private static extern bool AnimateWindow(IntPtr hwnd,int dwTime, int dwFlags);
		const int AW_HOR_POSITIVE = 0x0001;
		const int AW_HOR_NEGATIVE = 0x0002;
		const int AW_VER_POSITIVE = 0x0004;
		const int AW_VER_NEGATIVE = 0x0008;
		const int AW_CENTER = 0x0010;
		const int AW_HIDE = 0x10000;
		const int AW_ACTIVATE = 0x20000;
		const int AW_SLIDE = 0x40000;
		private DevExpress.XtraEditors.PanelControl panelControl1;
		private DevExpress.XtraEditors.PanelControl panelControl2;
		private DevExpress.XtraEditors.SimpleButton btnOut;
		private DevExpress.XtraEditors.SimpleButton btnMove;
		private DevExpress.XtraEditors.SimpleButton btnIn;
		private DevExpress.XtraEditors.SimpleButton btCancel;
		private DevExpress.XtraEditors.SimpleButton simpleButton1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		const int AW_BLEND = 0x80000;		

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MapDisplay));
			this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
			this.axMap1 = new AxMapXLib.AxMap();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
			this.btnIn = new DevExpress.XtraEditors.SimpleButton();
			this.btnMove = new DevExpress.XtraEditors.SimpleButton();
			this.btnOut = new DevExpress.XtraEditors.SimpleButton();
			this.panelControl2 = new DevExpress.XtraEditors.PanelControl();
			this.btCancel = new DevExpress.XtraEditors.SimpleButton();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
			this.panelControl1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.axMap1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.panelControl2)).BeginInit();
			this.panelControl2.SuspendLayout();
			this.SuspendLayout();
			// 
			// panelControl1
			// 
			this.panelControl1.Appearance.BackColor = System.Drawing.Color.Transparent;
			this.panelControl1.Appearance.Options.UseBackColor = true;
			this.panelControl1.Controls.Add(this.axMap1);
			this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panelControl1.Location = new System.Drawing.Point(0, 40);
			this.panelControl1.Name = "panelControl1";
			this.panelControl1.Size = new System.Drawing.Size(664, 365);
			this.panelControl1.TabIndex = 4;
			this.panelControl1.Text = "panelControl1";
			// 
			// axMap1
			// 
			this.axMap1.ContainingControl = this;
			this.axMap1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.axMap1.Enabled = true;
			this.axMap1.Location = new System.Drawing.Point(2, 2);
			this.axMap1.Name = "axMap1";
			this.axMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap1.OcxState")));
			this.axMap1.Size = new System.Drawing.Size(660, 361);
			this.axMap1.TabIndex = 3;
			this.axMap1.PolyToolUsed += new AxMapXLib.CMapXEvents_PolyToolUsedEventHandler(this.axMap1_PolyToolUsed);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(136, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(120, 23);
			this.label2.TabIndex = 2;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(112, 23);
			this.label1.TabIndex = 1;
			// 
			// simpleButton1
			// 
			this.simpleButton1.Location = new System.Drawing.Point(264, 8);
			this.simpleButton1.Name = "simpleButton1";
			this.simpleButton1.TabIndex = 0;
			this.simpleButton1.Text = "测距";
			this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
			// 
			// btnIn
			// 
			this.btnIn.Location = new System.Drawing.Point(504, 8);
			this.btnIn.Name = "btnIn";
			this.btnIn.TabIndex = 2;
			this.btnIn.Text = "缩 小";
			this.btnIn.Click += new System.EventHandler(this.btnIn_Click);
			// 
			// btnMove
			// 
			this.btnMove.Location = new System.Drawing.Point(584, 8);
			this.btnMove.Name = "btnMove";
			this.btnMove.TabIndex = 1;
			this.btnMove.Text = "拖 放";
			this.btnMove.Click += new System.EventHandler(this.btnMove_Click);
			// 
			// btnOut
			// 
			this.btnOut.Location = new System.Drawing.Point(424, 8);
			this.btnOut.Name = "btnOut";
			this.btnOut.TabIndex = 0;
			this.btnOut.Tag = "";
			this.btnOut.Text = "放 大";
			this.btnOut.Click += new System.EventHandler(this.button1_Click_1);
			// 
			// panelControl2
			// 
			this.panelControl2.Controls.Add(this.btnIn);
			this.panelControl2.Controls.Add(this.btnMove);
			this.panelControl2.Controls.Add(this.btnOut);
			this.panelControl2.Controls.Add(this.btCancel);
			this.panelControl2.Controls.Add(this.simpleButton1);
			this.panelControl2.Controls.Add(this.label1);
			this.panelControl2.Controls.Add(this.label2);
			this.panelControl2.Dock = System.Windows.Forms.DockStyle.Top;
			this.panelControl2.Location = new System.Drawing.Point(0, 0);
			this.panelControl2.Name = "panelControl2";
			this.panelControl2.Size = new System.Drawing.Size(664, 40);
			this.panelControl2.TabIndex = 0;
			// 
			// btCancel
			// 
			this.btCancel.Location = new System.Drawing.Point(344, 8);
			this.btCancel.Name = "btCancel";
			this.btCancel.TabIndex = 0;
			this.btCancel.Text = "取 消";
			this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// MapDisplay
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(131)), ((System.Byte)(194)), ((System.Byte)(231)));
			this.ClientSize = new System.Drawing.Size(664, 405);
			this.Controls.Add(this.panelControl1);
			this.Controls.Add(this.panelControl2);
			this.Location = new System.Drawing.Point(450, 170);
			this.Name = "MapDisplay";
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "地图";
			this.TopMost = true;
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MapDisplay_Closing);
			this.Load += new System.EventHandler(this.MapDisplay_Load);
			this.Closed += new System.EventHandler(this.MapDisplay_Closed);
			((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
			this.panelControl1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.axMap1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.panelControl2)).EndInit();
			this.panelControl2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void MapDisplay_Load(object sender, System.EventArgs e)
		{
			
//			AnimateWindow(this.Handle,1000, AW_CENTER | AW_ACTIVATE);
			
		}
		private void DisplaySpOnMap(string displayArea)
		{
			
			this.axMap1.Layers[displayArea].Selection.ClearSelection();
			for(int i=0;i<ServiceProviderForm.SPList.Count;i++)
			{
				try
				{
					ServiceProviderInfo spInfo = (ServiceProviderInfo)ServiceProviderForm.SPList[i];
					MapXLib.Feature fea = this.axMap1.Layers[displayArea].GetFeatureByKey(spInfo.position.ToString());
					if(fea!=null)
					{
						this.axMap1.Layers[displayArea].Selection.Add(fea);
						
					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
					
				}
			}
		}
		private void MapDisplay_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_HIDE | AW_VER_NEGATIVE);
		}

		private void button1_Click_1(object sender, System.EventArgs e)
		{
			axMap1.CurrentTool=MapXLib.ToolConstants.miZoomInTool;
		}

		private void btnMove_Click(object sender, System.EventArgs e)
		{
			axMap1.CurrentTool=MapXLib.ToolConstants.miPanTool;
		}

		private void btnIn_Click(object sender, System.EventArgs e)
		{
			axMap1.CurrentTool=MapXLib.ToolConstants.miZoomOutTool;			
		}

		private void btCancel_Click(object sender, System.EventArgs e)
		{
			this.axMap1.CurrentTool=MapXLib.ToolConstants.miArrowTool;
		}

		private void MapDisplay_Closed(object sender, System.EventArgs e)
		{
			ShareClass.winstate="close";
		}

		private void simpleButton1_Click(object sender, System.EventArgs e)
		{
			axMap1.CreateCustomTool(100,MapXLib.ToolTypeConstants.miToolTypePoly,MapXLib.CursorConstants.miCrossCursor,null,null,null);
			axMap1.CurrentTool=(MapXLib.ToolConstants)100;
		}

		private void axMap1_PolyToolUsed(object sender, AxMapXLib.CMapXEvents_PolyToolUsedEvent e)
		{
			MapXLib.PointsClass pts=new MapXLib.PointsClass();
			switch(e.flags)
			{
				case (int)MapXLib.ToolFlagConstants.miToolInProgress:
					pts=(MapXLib.PointsClass)e.points;
					dis=axMap1.Distance(pts._Item(pts.Count -1).X,pts._Item(pts.Count -1).Y,pts._Item(pts.Count).X,pts._Item(pts.Count).Y);
					dissum+=dis;
					break;
				default:
					dis=0;
					dissum=0;
					break;

			}
			this.label1.Text="距离:"+dis.ToString("#.00")+"公里";
			this.label2.Text="总距:"+dissum.ToString("#.00")+"公里";
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			try
			{


								//记录目前正在处理的节点图标
								MapXLib.Feature CurCusSym=this.axMap1.Layers["yuan"].GetFeatureByKey("20");//new MapXLib.Feature();
								//两个交替显示的图标
								MapXLib.Style NewStyle=new MapXLib.Style();
								MapXLib.Style OldStyle =new MapXLib.Style();
								//用于更换图标的布尔值
								MapXLib.Layer lyr =this.axMap1.Layers["yuan"];//._Item("yuan");
								MapXLib.FeatureFactory FeaFac =this.axMap1.FeatureFactory;
				  
								NewStyle.SymbolType =MapXLib.SymbolTypeConstants.miSymbolTypeBitmap;
								NewStyle.SymbolBitmapSize = 20;
								NewStyle.SymbolBitmapTransparent = true;
								NewStyle.SymbolBitmapName = "red.BMP"; //(要显示的第一张图片)
				
								OldStyle.SymbolType =MapXLib.SymbolTypeConstants.miSymbolTypeBitmap;
								OldStyle.SymbolBitmapSize = 20;
								OldStyle.SymbolBitmapTransparent = true;
								OldStyle.SymbolBitmapName = "gray.BMP";  // (要显示的第二张图片)
				    
								this.axMap1.AutoRedraw=false;  //   (禁止自动刷新)
								lyr.Editable=true;
								if(blnold ==true)//     (如果正显示第一张图片,就替换为第二张图片) 
								{
									CurCusSym.Style = OldStyle;
									blnold = false;
								}
								else
								{
									CurCusSym.Style = NewStyle;//  (如果正显示第一张图片,就替换为第二张图片) 
									blnold = true;
								}
//									CurCusSym.Update(null,1);
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		bool blnold=false;
		private void timer1_Tick(object sender, System.EventArgs e)
		{
			try
			{

//				//记录目前正在处理的节点图标
//				MapXLib.Feature CurCusSym=this.axMap1.Layers["yuan"].GetFeatureByKey("20");//new MapXLib.Feature();
//				//两个交替显示的图标
//				MapXLib.Style NewStyle=new MapXLib.Style();
//				MapXLib.Style OldStyle =new MapXLib.Style();
//				//用于更换图标的布尔值
//				
//				MapXLib.Layer lyr =this.axMap1.Layers["yuan"];//._Item("yuan");
//				MapXLib.FeatureFactory FeaFac =this.axMap1.FeatureFactory;
//				   
//				NewStyle.SymbolType =MapXLib.SymbolTypeConstants.miSymbolTypeBitmap;
//				NewStyle.SymbolBitmapSize = 24;
//				NewStyle.SymbolBitmapTransparent = true;
//				NewStyle.SymbolBitmapName = "red.BMP";   //(要显示的第一张图片)
//				
//				OldStyle.SymbolType =MapXLib.SymbolTypeConstants.miSymbolTypeBitmap;
//				OldStyle.SymbolBitmapSize = 1;
//				OldStyle.SymbolBitmapTransparent = true;
//				OldStyle.SymbolBitmapName = "gray.BMP";  // (要显示的第二张图片)
//				    
//				this.axMap1.AutoRedraw=false;  //   (禁止自动刷新)
//				lyr.Editable=true;
//				if(blnold ==true)//     (如果正显示第一张图片,就替换为第二张图片) 
//				{
//					CurCusSym.Style = OldStyle;
//					blnold = false;
//				}
//				else
//				{
//					CurCusSym.Style = NewStyle;//  (如果正显示第一张图片,就替换为第二张图片) 
//					blnold = true;
//				}
//				//CurCusSym.Update(null,null);
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
			

		}


	}
}

⌨️ 快捷键说明

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