frmLine.cs
上传用户:xum6868
上传日期:2009-12-02
资源大小:102k
文件大小:8k
源码类别:

GIS编程

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace MainSystem
  7. {
  8. /// <summary>
  9. /// Summary description for frmLine.
  10. /// </summary>
  11. public class frmLine : System.Windows.Forms.Form
  12. {
  13. private frmMain _frmMain = null;
  14. private string _szLineName = "";
  15. private System.Windows.Forms.Label _label_transfline;
  16. private System.Windows.Forms.Label _label_Sta;
  17. private System.Windows.Forms.ListBox _listBox_Line;
  18. private System.Windows.Forms.ListBox _listBox_sta;
  19. private System.Windows.Forms.Label _label_line;
  20. /// <summary>
  21. /// Required designer variable.
  22. /// </summary>
  23. private System.ComponentModel.Container components = null;
  24. public frmLine(frmMain frmMain,string szLineName)
  25. {
  26. _frmMain = frmMain;
  27. _szLineName = szLineName;
  28. InitializeComponent();
  29. }
  30. /// <summary>
  31. /// Clean up any resources being used.
  32. /// </summary>
  33. protected override void Dispose( bool disposing )
  34. {
  35. if( disposing )
  36. {
  37. if(components != null)
  38. {
  39. components.Dispose();
  40. }
  41. }
  42. base.Dispose( disposing );
  43. }
  44. #region Windows Form Designer generated code
  45. /// <summary>
  46. /// Required method for Designer support - do not modify
  47. /// the contents of this method with the code editor.
  48. /// </summary>
  49. private void InitializeComponent()
  50. {
  51. this._label_transfline = new System.Windows.Forms.Label();
  52. this._label_Sta = new System.Windows.Forms.Label();
  53. this._listBox_Line = new System.Windows.Forms.ListBox();
  54. this._listBox_sta = new System.Windows.Forms.ListBox();
  55. this._label_line = new System.Windows.Forms.Label();
  56. this.SuspendLayout();
  57. // 
  58. // _label_transfline
  59. // 
  60. this._label_transfline.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  61. this._label_transfline.Location = new System.Drawing.Point(160, 32);
  62. this._label_transfline.Name = "_label_transfline";
  63. this._label_transfline.Size = new System.Drawing.Size(128, 16);
  64. this._label_transfline.TabIndex = 9;
  65. this._label_transfline.Text = "在此站可转的车:";
  66. // 
  67. // _label_Sta
  68. // 
  69. this._label_Sta.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  70. this._label_Sta.Location = new System.Drawing.Point(8, 32);
  71. this._label_Sta.Name = "_label_Sta";
  72. this._label_Sta.Size = new System.Drawing.Size(128, 16);
  73. this._label_Sta.TabIndex = 8;
  74. this._label_Sta.Text = "经过的公交车站:";
  75. // 
  76. // _listBox_Line
  77. // 
  78. this._listBox_Line.ItemHeight = 12;
  79. this._listBox_Line.Location = new System.Drawing.Point(160, 48);
  80. this._listBox_Line.Name = "_listBox_Line";
  81. this._listBox_Line.Size = new System.Drawing.Size(128, 196);
  82. this._listBox_Line.TabIndex = 7;
  83. // 
  84. // _listBox_sta
  85. // 
  86. this._listBox_sta.ItemHeight = 12;
  87. this._listBox_sta.Location = new System.Drawing.Point(8, 48);
  88. this._listBox_sta.Name = "_listBox_sta";
  89. this._listBox_sta.Size = new System.Drawing.Size(144, 196);
  90. this._listBox_sta.TabIndex = 6;
  91. this._listBox_sta.DoubleClick += new System.EventHandler(this._listBox_sta_DoubleClick);
  92. this._listBox_sta.SelectedIndexChanged += new System.EventHandler(this._listBox_sta_SelectedIndexChanged);
  93. // 
  94. // _label_line
  95. // 
  96. this._label_line.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  97. this._label_line.Location = new System.Drawing.Point(8, 8);
  98. this._label_line.Name = "_label_line";
  99. this._label_line.Size = new System.Drawing.Size(248, 24);
  100. this._label_line.TabIndex = 5;
  101. this._label_line.Text = "公交路线:";
  102. // 
  103. // frmLine
  104. // 
  105. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  106. this.ClientSize = new System.Drawing.Size(296, 253);
  107. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  108.   this._label_transfline,
  109.   this._label_Sta,
  110.   this._listBox_Line,
  111.   this._listBox_sta,
  112.   this._label_line});
  113. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
  114. this.MaximizeBox = false;
  115. this.MinimizeBox = false;
  116. this.Name = "frmLine";
  117. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  118. this.Text = "公交路线信息";
  119. this.TopMost = true;
  120. this.Load += new System.EventHandler(this.frmLine_Load);
  121. this.ResumeLayout(false);
  122. }
  123. #endregion
  124. private void _listBox_sta_DoubleClick(object sender, System.EventArgs e)
  125. {
  126. string szName = _listBox_sta.Text;
  127. string szLayer = _frmMain._environment.GetLayerName(szName,"地名索引");   
  128. string szTable = _frmMain._environment.GetTableName(szName,"地名索引");
  129. int nIndex =  _frmMain._environment.GetLayerIndexByName(szTable); 
  130. if (nIndex < 0)
  131. return;
  132. MapObjects2.Recordset rs;
  133. rs = _frmMain._environment.m_layerInfos[nIndex].layer.SearchExpression("名称 like '"+szName +"'");
  134. if (rs != null)
  135. {
  136. rs.MoveFirst();
  137.  
  138. if (!rs.EOF) 
  139. {
  140. MapObjects2.Point pt = (MapObjects2.Point)rs.Fields.Item("shape").Value;
  141. if (!_frmMain.IsWithin(_frmMain._map.Extent, pt))  
  142. {
  143. _frmMain._map.CenterAt(pt.X,pt.Y );   
  144. }
  145. if (_frmMain._environment.m_layerInfos[nIndex].nCharacterIndex >= 0 && _frmMain._environment.m_layerInfos[nIndex].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePoint )
  146. {
  147. _frmMain._environment.m_selectedSymbol = new MapObjects2.Symbol();
  148.  
  149. _frmMain._environment.m_selectedSymbol.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;
  150. _frmMain._environment.m_selectedSymbol.Font.Name  = _frmMain._environment.m_layerInfos[nIndex].szFontName;
  151. _frmMain._environment.m_selectedSymbol.Style = 4;
  152. _frmMain._environment.m_selectedSymbol.Size = (short)_frmMain._environment.m_layerInfos[nIndex].nSymSize;
  153. _frmMain._environment.m_selectedSymbol.CharacterIndex = (short)_frmMain._environment.m_layerInfos[nIndex].nCharacterIndex;
  154. _frmMain._environment.m_selectedSymbol.Color = 0xff;
  155. }
  156. else
  157. _frmMain._environment.m_selectedSymbol = null;
  158. _frmMain._environment.m_selectedFeature = rs.Fields.Item("shape").Value;
  159. _frmMain._map.FlashShape(_frmMain._environment.m_selectedFeature, 4);
  160. _frmMain._map.Extent = _frmMain._map.Extent; 
  161. }
  162. }
  163. }
  164. private void frmLine_Load(object sender, System.EventArgs e)
  165. {
  166. this._label_line.Text  = "线路名称:"+_szLineName;
  167. LoadStationListBox();
  168. }
  169. private void LoadStationListBox()
  170. {
  171. this._listBox_sta.Items.Clear();
  172.   
  173. if ("" == _szLineName)
  174. return ;
  175. System.Data.DataTable typeTbl = this._frmMain._environment.m_dataSet.Tables["公交车站路线"];
  176. System.Data.DataRow[] rowstypes = typeTbl.Select("线路名='"+_szLineName+"'","顺序");
  177. int nIndex = 1;
  178. foreach (System.Data.DataRow myRow in rowstypes)
  179. {
  180. this._listBox_sta.Items.Add(myRow["站名"]);  
  181. nIndex ++;
  182. }
  183. }
  184. private void _listBox_sta_SelectedIndexChanged(object sender, System.EventArgs e)
  185. {
  186. if (_listBox_sta.Text != "")
  187. LoadLineList(_listBox_sta.Text);
  188. }
  189. private void LoadLineList(string szStaName)
  190. {
  191. if ("" == szStaName)
  192. return ;
  193. this._listBox_Line.Items.Clear();  
  194. System.Data.DataTable typeTbl = this._frmMain._environment.m_dataSet.Tables["公交车站路线"];
  195. string szFilter = "站名='"+szStaName+"'";
  196. if (_frmMain._environment.m_szBusFilter != "")
  197. {
  198. szFilter += " And ";
  199. szFilter += _frmMain._environment.m_szBusFilter;
  200. }
  201. System.Data.DataRow[] rowstypes = typeTbl.Select(szFilter);
  202. foreach (System.Data.DataRow myRow in rowstypes)
  203. {
  204. this._listBox_Line.Items.Add(myRow["线路名"]);  
  205. }
  206. }
  207. }
  208. }