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

📄 frmline.cs

📁 地理信息 地理信息 地理信息 地理信息
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MainSystem
{
	/// <summary>
	/// Summary description for frmLine.
	/// </summary>
	public class frmLine : System.Windows.Forms.Form
	{
		private frmMain	_frmMain = null;
		private string	_szLineName = "";

		private System.Windows.Forms.Label _label_transfline;
		private System.Windows.Forms.Label _label_Sta;
		private System.Windows.Forms.ListBox _listBox_Line;
		private System.Windows.Forms.ListBox _listBox_sta;
		private System.Windows.Forms.Label _label_line;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmLine(frmMain frmMain,string szLineName)
		{
			_frmMain = frmMain;
			_szLineName = szLineName;
			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._label_transfline = new System.Windows.Forms.Label();
			this._label_Sta = new System.Windows.Forms.Label();
			this._listBox_Line = new System.Windows.Forms.ListBox();
			this._listBox_sta = new System.Windows.Forms.ListBox();
			this._label_line = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// _label_transfline
			// 
			this._label_transfline.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this._label_transfline.Location = new System.Drawing.Point(160, 32);
			this._label_transfline.Name = "_label_transfline";
			this._label_transfline.Size = new System.Drawing.Size(128, 16);
			this._label_transfline.TabIndex = 9;
			this._label_transfline.Text = "在此站可转的车:";
			// 
			// _label_Sta
			// 
			this._label_Sta.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this._label_Sta.Location = new System.Drawing.Point(8, 32);
			this._label_Sta.Name = "_label_Sta";
			this._label_Sta.Size = new System.Drawing.Size(128, 16);
			this._label_Sta.TabIndex = 8;
			this._label_Sta.Text = "经过的公交车站:";
			// 
			// _listBox_Line
			// 
			this._listBox_Line.ItemHeight = 12;
			this._listBox_Line.Location = new System.Drawing.Point(160, 48);
			this._listBox_Line.Name = "_listBox_Line";
			this._listBox_Line.Size = new System.Drawing.Size(128, 196);
			this._listBox_Line.TabIndex = 7;
			// 
			// _listBox_sta
			// 
			this._listBox_sta.ItemHeight = 12;
			this._listBox_sta.Location = new System.Drawing.Point(8, 48);
			this._listBox_sta.Name = "_listBox_sta";
			this._listBox_sta.Size = new System.Drawing.Size(144, 196);
			this._listBox_sta.TabIndex = 6;
			this._listBox_sta.DoubleClick += new System.EventHandler(this._listBox_sta_DoubleClick);
			this._listBox_sta.SelectedIndexChanged += new System.EventHandler(this._listBox_sta_SelectedIndexChanged);
			// 
			// _label_line
			// 
			this._label_line.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this._label_line.Location = new System.Drawing.Point(8, 8);
			this._label_line.Name = "_label_line";
			this._label_line.Size = new System.Drawing.Size(248, 24);
			this._label_line.TabIndex = 5;
			this._label_line.Text = "公交路线:";
			// 
			// frmLine
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(296, 253);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this._label_transfline,
																		  this._label_Sta,
																		  this._listBox_Line,
																		  this._listBox_sta,
																		  this._label_line});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmLine";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "公交路线信息";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.frmLine_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void _listBox_sta_DoubleClick(object sender, System.EventArgs e)
		{
			string szName = _listBox_sta.Text;
			string szLayer = _frmMain._environment.GetLayerName(szName,"地名索引");   
			string szTable = _frmMain._environment.GetTableName(szName,"地名索引");
			
			int nIndex =  _frmMain._environment.GetLayerIndexByName(szTable); 

			if (nIndex < 0)
				return;

			MapObjects2.Recordset rs;
			rs = _frmMain._environment.m_layerInfos[nIndex].layer.SearchExpression("名称 like '"+szName +"'");
			if (rs != null)
			{
				rs.MoveFirst();
 
				if (!rs.EOF) 
				{

					MapObjects2.Point pt = (MapObjects2.Point)rs.Fields.Item("shape").Value;
		
					if (!_frmMain.IsWithin(_frmMain._map.Extent, pt))  
					{
						_frmMain._map.CenterAt(pt.X,pt.Y );   
					}

					if (_frmMain._environment.m_layerInfos[nIndex].nCharacterIndex >= 0 && _frmMain._environment.m_layerInfos[nIndex].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePoint )
					{
						_frmMain._environment.m_selectedSymbol = new MapObjects2.Symbol();
 
						_frmMain._environment.m_selectedSymbol.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;
						_frmMain._environment.m_selectedSymbol.Font.Name  = _frmMain._environment.m_layerInfos[nIndex].szFontName;
						_frmMain._environment.m_selectedSymbol.Style = 4;
						_frmMain._environment.m_selectedSymbol.Size = (short)_frmMain._environment.m_layerInfos[nIndex].nSymSize;
						_frmMain._environment.m_selectedSymbol.CharacterIndex = (short)_frmMain._environment.m_layerInfos[nIndex].nCharacterIndex;
						_frmMain._environment.m_selectedSymbol.Color = 0xff;
					}
					else
						_frmMain._environment.m_selectedSymbol = null;

					_frmMain._environment.m_selectedFeature = rs.Fields.Item("shape").Value;
					_frmMain._map.FlashShape(_frmMain._environment.m_selectedFeature, 4);
					_frmMain._map.Extent = _frmMain._map.Extent; 		
				}
			}	
		}

		private void frmLine_Load(object sender, System.EventArgs e)
		{
			this._label_line.Text  = "线路名称:"+_szLineName;
			LoadStationListBox();
		}

		private void LoadStationListBox()
		{
			this._listBox_sta.Items.Clear();
  
			if ("" == _szLineName)
				return ;
			
			System.Data.DataTable typeTbl = this._frmMain._environment.m_dataSet.Tables["公交车站路线"];
			System.Data.DataRow[] rowstypes = typeTbl.Select("线路名='"+_szLineName+"'","顺序");			
			int nIndex = 1;

			foreach (System.Data.DataRow myRow in rowstypes)
			{
				this._listBox_sta.Items.Add(myRow["站名"]);  
				nIndex ++;
			}			
		}

		private void _listBox_sta_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (_listBox_sta.Text != "")
				LoadLineList(_listBox_sta.Text);
		}

		private void LoadLineList(string szStaName)
		{
			if ("" == szStaName)
				return ;

			this._listBox_Line.Items.Clear();  
			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_Line.Items.Add(myRow["线路名"]);  
			}		
		}

	}
}

⌨️ 快捷键说明

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