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

📄 frmstation.cs

📁 公布ilrbuivbiu复合带搜ifd回复地鸥鸟个能否地偶女男的
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MainSystem
{
	/// <summary>
	/// Summary description for frmStation.
	/// </summary>
	public class frmStation : System.Windows.Forms.Form
	{
		private frmMain	_frmMain;
		private string	_szStaName;

		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label _label2;
		private System.Windows.Forms.Label _label_Statation;
		private System.Windows.Forms.ListBox _listBox;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmStation(frmMain frmMain, string szStaName)
		{
			_frmMain = frmMain;
			_szStaName = szStaName;
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this._label2 = new System.Windows.Forms.Label();
			this._label_Statation = new System.Windows.Forms.Label();
			this._listBox = new System.Windows.Forms.ListBox();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Enabled = false;
			this.button1.Location = new System.Drawing.Point(152, 8);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(56, 24);
			this.button1.TabIndex = 7;
			this.button1.Text = "定位";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// _label2
			// 
			this._label2.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this._label2.Font = new System.Drawing.Font("SimSun", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this._label2.Location = new System.Drawing.Point(8, 32);
			this._label2.Name = "_label2";
			this._label2.Size = new System.Drawing.Size(200, 24);
			this._label2.TabIndex = 6;
			// 
			// _label_Statation
			// 
			this._label_Statation.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this._label_Statation.Font = new System.Drawing.Font("SimSun", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this._label_Statation.Location = new System.Drawing.Point(8, 8);
			this._label_Statation.Name = "_label_Statation";
			this._label_Statation.Size = new System.Drawing.Size(200, 24);
			this._label_Statation.TabIndex = 5;
			// 
			// _listBox
			// 
			this._listBox.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this._listBox.ItemHeight = 12;
			this._listBox.Location = new System.Drawing.Point(8, 56);
			this._listBox.Name = "_listBox";
			this._listBox.Size = new System.Drawing.Size(200, 220);
			this._listBox.TabIndex = 4;
			this._listBox.DoubleClick += new System.EventHandler(this._listBox_DoubleClick);
			this._listBox.SelectedIndexChanged += new System.EventHandler(this._listBox_SelectedIndexChanged);
			// 
			// frmStation
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(224, 277);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button1,
																		  this._label2,
																		  this._label_Statation,
																		  this._listBox});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmStation";
			this.Text = "车站信息";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.frmStation_Load);
			this.ResumeLayout(false);

		}
		#endregion

		//功能:单击按钮,定位指定的公交路线
		private void button1_Click(object sender, System.EventArgs e)
		{
			string szName = _listBox.Text;			//公交路线名称
			string szLayer = CEnvironment.BUSLINE_LAYERNAME;//公交路线所在图层名称

			MapObjects2.MapLayer ly = (MapObjects2.MapLayer)_frmMain._map.Layers.Item((object)szLayer);
			if (ly == null)
				return;

			MapObjects2.Recordset rs = ly.SearchExpression("名称 like '"+szName +"'");;
			if (null == rs)
			{
				MessageBox.Show("地图上没有这条公交线路!","北京市地理信息公众查询系统",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}
			
			rs.MoveFirst(); 
			if (rs.EOF)
			{
				MessageBox.Show("地图上没有这条公交线路!","北京市地理信息公众查询系统",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}

			//在地图找到了这条线路,画出来
			//首先定位
			MapObjects2.Point pt;
			MapObjects2.Line line = (MapObjects2.Line)rs.Fields.Item("shape").Value;
			pt = line.Extent.Center;
					
			if (!_frmMain.IsWithin(_frmMain._map.Extent, pt))  
			{
				_frmMain._map.CenterAt(pt.X,pt.Y );   
			}

			//其次设置_environment.m_drawLine和_environment.m_buses
			MapObjects2.Points	pts;
			pts = (MapObjects2.Points)line.Parts.Item(0);

			_frmMain._environment.m_drawLine = null;
			_frmMain._environment.m_drawLine = new MLine[1];
			_frmMain._environment.m_drawLine[0] = new MLine();
			_frmMain._environment.m_drawLine[0].nPointNumber = pts.Count;
			_frmMain._environment.m_drawLine[0].pPoint = new MPoint[pts.Count];

			for (int i = 0; i < pts.Count; i ++)
			{
				pt = (MapObjects2.Point)pts.Item(i);
				_frmMain._environment.m_drawLine[0].pPoint[i] = new MPoint();
				_frmMain._environment.m_drawLine[0].pPoint[i].x = pt.X;
				_frmMain._environment.m_drawLine[0].pPoint[i].y = pt.Y;							
			}

			_frmMain._environment.m_buses = new Buses();
			int nCount = 0;
			if(!_frmMain._environment.GetStation(szName, _frmMain._environment.m_buses,ref nCount)) 
				_frmMain._environment.m_buses = null;
			else
				_frmMain._environment.m_buses.nNum = nCount; 

			//闪烁,重画
			_frmMain._map.FlashShape(rs.Fields.Item("shape").Value, 4);
			_frmMain._map.Extent = _frmMain._map.Extent; 	
		}

		private void frmStation_Load(object sender, System.EventArgs e)
		{
			this._label_Statation.Text  = " 车站名称:"+this._szStaName;
			this._label2.Text = "经过"+this._szStaName+"的公交线路:";
			LoadListBox();
		}

		private void LoadListBox()
		{
			_listBox.Items.Clear();  
			if ("" == _szStaName)
				return ;
			
			System.Data.DataTable typeTbl = this._frmMain._environment.m_dataSet.Tables["公交车站路线"];
			string szFilter = "站名='"+_szStaName+"'";
			if (_frmMain._environment.m_szBusFilter != "")
			{
				szFilter += " And ";
				szFilter += _frmMain._environment.m_szBusFilter;
			}

			System.Data.DataRow[] rowstypes = typeTbl.Select(szFilter);
			foreach (System.Data.DataRow myRow in rowstypes)
			{
				this._listBox.Items.Add(myRow["线路名"]);  
			}
		}

		private void _listBox_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (_listBox.Text != "")
				button1.Enabled = true;
			else
				button1.Enabled = false;
		}

		private void _listBox_DoubleClick(object sender, System.EventArgs e)
		{
			if (_listBox.Text == "")
				return;

			frmLine frm = new frmLine(this._frmMain,_listBox.Text );
			this.Visible = false;
			frm.ShowDialog(this._frmMain);		
			this.Close(); 
		}


	}
}

⌨️ 快捷键说明

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