SpatialQueryControl.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. //======================================================================
  2. //
  3. //
  4. //
  5. // CLR 版本: 4.0.30319.1
  6. // 命名空间: Tofly.SearchUI.Win
  7. // 类 名: SpatialQueryControl
  8. // 创 建 人: 徐 健
  9. // 创建时间: 2013/04/16 19:35:14
  10. // 修 改 人:
  11. // 修改时间:
  12. //
  13. //======================================================================
  14. using System.Windows.Forms;
  15. using System.Data;
  16. using System.Collections.Generic;
  17. using Tofly.SearchUI.Query;
  18. using Tofly.CoreUI.Win.Control;
  19. using Tofly.CoreUI.Control;
  20. using Tofly.CoreUI.Plot;
  21. namespace Tofly.SearchUI.Win
  22. {
  23. /// <summary>
  24. /// 空间查询Control
  25. /// </summary>
  26. [Tofly.Core.Stereotype.Component(IsSingleton = "false", Name = "SpatialQueryControl")]
  27. public partial class SpatialQueryControl : UserControlClass, ISpatialQueryControl
  28. {
  29. public SpatialQueryControl()
  30. {
  31. InitializeComponent();
  32. }
  33. #region ISpatialQueryControl 成员
  34. public ITreeControl pTreeSelectLayer
  35. {
  36. get { return this.treeControlLayer; }
  37. }
  38. public IComboBox pComboLayer
  39. {
  40. get { return this.comboBoxLayer; }
  41. }
  42. public IComboBox pComboCondition
  43. {
  44. get { return this.comboBoxCondition; }
  45. }
  46. public IComboBox pComboSelectEnum
  47. {
  48. get { return this.comboBoxSelectEnum; }
  49. }
  50. public IPictureEidt pPictureEdit
  51. {
  52. get { return null; }
  53. }
  54. public IMemoEdit pMemoEdit
  55. {
  56. get { return this.memoEdit; }
  57. }
  58. public IButton pButtonOK
  59. {
  60. get { return this.buttonOK; }
  61. }
  62. public ICheckBox pCheckBoxSelect
  63. {
  64. get { return this.checkBoxSelect; }
  65. }
  66. public ICheckBox pCheckBoxHC2
  67. {
  68. get { return this.checkBoxHC2; }
  69. }
  70. public ISpinEdit pSpinEditHC2
  71. {
  72. get { return this.spinEditHC2; }
  73. }
  74. public IComboBox pComboBoxHCUnit2
  75. {
  76. get { return this.comboBoxHCUnits2; }
  77. }
  78. public int SeletionCount
  79. {
  80. get { return 0; }
  81. set
  82. {
  83. this.labelClass2.Text = "(已选中" + value.ToString() + "个要素)";
  84. Application.DoEvents();
  85. }
  86. }
  87. public void InitDiscribe()
  88. {
  89. string QueryLayerName = this.comboBoxLayer.Text;
  90. if (string.IsNullOrEmpty(QueryLayerName))
  91. {
  92. this.memoEdit.Text = "";
  93. return;
  94. }
  95. if (this.comboBoxCondition.SelectedIndex < 0)
  96. {
  97. this.memoEdit.Text = "";
  98. return;
  99. }
  100. List<object> LstCheckedRow = this.treeControlLayer.GetCheckedNodeDatas();
  101. string SourceLayerName = "";
  102. for (int i = 0; i < LstCheckedRow.Count; i++)
  103. {
  104. DataRow pDr = LstCheckedRow[i] as DataRow;
  105. if (string.IsNullOrEmpty(SourceLayerName))
  106. SourceLayerName += pDr[0].ToString();
  107. else
  108. SourceLayerName += "," + pDr[0].ToString();
  109. }
  110. if (string.IsNullOrEmpty(SourceLayerName))
  111. {
  112. this.memoEdit.Text = "";
  113. return;
  114. }
  115. string[] strCaption = new string[11];
  116. strCaption[0] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它与[" + QueryLayerName + "]相交";
  117. strCaption[1] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它与[" + QueryLayerName + "]在指定的距离内";
  118. strCaption[2] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它完全包含[" + QueryLayerName + "]";
  119. strCaption[3] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它完全被[" + QueryLayerName + "]包含";
  120. strCaption[4] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它中心落在[" + QueryLayerName + "]";
  121. strCaption[5] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它与[" + QueryLayerName + "]有共享边";
  122. strCaption[6] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它与[" + QueryLayerName + "]边界接触";
  123. strCaption[7] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它与[" + QueryLayerName + "]几何形状完全相同";
  124. strCaption[8] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它被[" + QueryLayerName + "]外边界穿过";
  125. strCaption[9] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它包含[" + QueryLayerName + "]";
  126. strCaption[10] = "蓝色为[" + SourceLayerName + "]中被选中的元素,因为它被[" + QueryLayerName + "]包含";
  127. Dictionary<string, string> typeDescripPair = new Dictionary<string, string>();
  128. typeDescripPair.Add("相交", strCaption[0]);
  129. typeDescripPair.Add("在指定的距离内", strCaption[1]);
  130. typeDescripPair.Add("完全包含", strCaption[2]);
  131. typeDescripPair.Add("完全被包含", strCaption[3]);
  132. typeDescripPair.Add("中心落在", strCaption[4]);
  133. typeDescripPair.Add("有共享边", strCaption[5]);
  134. typeDescripPair.Add("边界接触", strCaption[6]);
  135. typeDescripPair.Add("几何形状完全相同", strCaption[7]);
  136. typeDescripPair.Add("被外边界穿过", strCaption[8]);
  137. typeDescripPair.Add("包含", strCaption[9]);
  138. typeDescripPair.Add("被包含", strCaption[10]);
  139. DataRow row = this.pComboCondition.SelectedValue as DataRow;
  140. this.memoEdit.Text = typeDescripPair[row[0].ToString()] ;
  141. //this.pictureEdit.EditValue = this.imageList1.Images[this.comboBoxCondition.SelectedIndex];
  142. }
  143. #endregion
  144. private void SpatialQueryControl_Load(object sender, System.EventArgs e)
  145. {
  146. InitUnitsCombox();
  147. this.comboBoxSelectEnum.SelectedIndex = 0;
  148. this.spinEditHC2.Enabled = false;
  149. this.comboBoxHCUnits2.Enabled = false;
  150. this.memoEdit.Properties.ReadOnly = true;
  151. //this.pictureEdit.EditValue = this.imageList1.Images[0];
  152. }
  153. private void InitUnitsCombox()
  154. {
  155. #region 加载缓冲单位
  156. DataTable HCUnitsComboDT = new DataTable();
  157. HCUnitsComboDT.Columns.Add("单位"); HCUnitsComboDT.Columns.Add("CODE");
  158. List<string> LstHCUnits = new List<string>();
  159. LstHCUnits.Add("厘米"); LstHCUnits.Add("分米"); LstHCUnits.Add("米"); LstHCUnits.Add("千米");
  160. for (int i = 0; i < LstHCUnits.Count; i++)
  161. {
  162. DataRow HCUnitsRow = HCUnitsComboDT.NewRow();
  163. HCUnitsRow[0] = LstHCUnits[i]; HCUnitsRow[1] = i;
  164. HCUnitsComboDT.Rows.Add(HCUnitsRow);
  165. }
  166. this.comboBoxHCUnits2.DisplayFieldName = "单位";
  167. this.comboBoxHCUnits2.CodeFieldName = "CODE";
  168. this.comboBoxHCUnits2.DataSource = HCUnitsComboDT;
  169. #endregion
  170. #region 加载选择集方式
  171. DataTable SelectEnumDT = new DataTable();
  172. SelectEnumDT.Columns.Add("结果"); SelectEnumDT.Columns.Add("CODE");
  173. List<string> LstSelectEnum = new List<string>();
  174. LstSelectEnum.Add("创建一个新的选择集"); LstSelectEnum.Add("增加到当前选择集");
  175. LstSelectEnum.Add("从当前选择集移除"); LstSelectEnum.Add("从当前选择集选择");
  176. PluginGISType plugingistype = (PluginGISType)Core.ServiceLocator.ServiceLocatorFactory.
  177. ServiceLocator.GetInstance<int>(Core.ServiceLocator.ServiceLocatorKeys.CurGISType);
  178. if (plugingistype == PluginGISType.SuperMap)
  179. LstSelectEnum.Remove("从当前选择集选择");
  180. for (int i = 0; i < LstSelectEnum.Count; i++)
  181. {
  182. DataRow SelectEnumRow = SelectEnumDT.NewRow();
  183. SelectEnumRow[0] = LstSelectEnum[i]; SelectEnumRow[1] = i;
  184. SelectEnumDT.Rows.Add(SelectEnumRow);
  185. }
  186. this.comboBoxSelectEnum.DisplayFieldName = "结果";
  187. this.comboBoxSelectEnum.CodeFieldName = "CODE";
  188. this.comboBoxSelectEnum.DataSource = SelectEnumDT;
  189. #endregion
  190. }
  191. }
  192. }